-
Notifications
You must be signed in to change notification settings - Fork 1.7k
run rustfmt on the repository #398(Updated) #438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The tests passed, I will take a look at the output to see if everything is good 👍 |
@prertik I think we should remove the rustfmt.toml file altogether. It was meant for an old version of rustfmt, but it has changed significantly since then and most of the options are probably irrelevant now. Could I ask you to remove the config file and run rustfmt again? :) |
Yeah about rustfmt.toml, I had to configure it to pass the test as you can see certain changes. If we remove rustfmt.toml, the rustfmt would operate in default condition which is having |
Wouldn't it make more sense to just shorten the overly long lines instead of increasing the max width above 120 characters? If you have a really long string literal, you can break it over a newline by adding a Like this: let some_really_long_string: &'static str = "this is a very long and uninteresting string \
which I've wrapped over multiple lines."; Also, in doc comments you typically want to wrap them at 80 characters anyway. I know there are one or two examples with really long overhanging lines, but it'd probably be better to either move the comments above or delete them outright if they don't add anything extra to the example... I think uncle bob is quoted as saying, "comments are apologies for badly written code [or poor naming]". |
Yes, I think it would be better to drop the config file. Resolve the issues with lines being too long and see if the output is acceptable. If the default style works for us, we should embrace it. |
Thanks @Michael-F-Bryan for the feedback. Alright @azerupi, I will do that. I will send a new pull request and will close this one. |
@prertik For future reference you can use |
Thanks @budziq. Actually, i used to do |
And how about setting fn_call_style to |
Yeah, I guess it takes care of the extra line from block(default). But, I think the block has been made default for a reason i.e. being community standard. |
Shouldn't we follow community standard? In Ruby, community standard is held at highest order. |
Be that as it may, but rustftmt.toml facility was also made for a reason ;). Please note that the rust community standard is in constant flux (4months ago its output on our repo was different and arguably/subjectively nicer).
It had a little more time to coalesce. Ours is stil wip. Imho additional 2lines per invocation is just adding noise. |
So, what should I do @budziq? Should I add rustfmt.toml and redo everything? :( |
If there would be some changes it would not be redoing everything a single run of find ./src -iname "*.rs" | xargs rustfmt should do the trick (if you're on a nix'y environment) But anyhow I would wait on a decision from owner 👍 |
Redoing everything should be relatively easy, no? rustfmt comes with a cargo sub-command to run it on the whole crate: I agree with everyone that some lines that are expanded would be better left as one line.If we can play with the configuration file and find some options that work better, great! Otherwise, I would be inclined to merge with the options that result in the best formatting and open an issue on rustfmt to give feedback. |
So, just to be clear, I have to change the |
See what everything looks like when you tweak Personally I don't mind what style we use, the biggest thing for me, and most probably the others, is that hitting save in my editor (I have format-on-save turned on) or running |
How about I change every indentation to |
This looks fine to me. How about you @budziq, @azerupi, @Michael-F-Bryan? |
looks good to me 👍 |
This line |
👍 |
(theme_dir.join("ayu-highlight.css"), &mut theme.ayu_highlight_css), | ||
(theme_dir.join("jquery.js"), &mut theme.jquery), | ||
]; | ||
let files = vec![(theme_dir.join("index.hbs"), &mut theme.index), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a little strange.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, about this I made a array_layout = "Visual"
in the rustfmt.toml because everyone here seemed to prefer the visual layout rather than the block. I think it looks OK. If you follow the codes from lines 67 to down, it looks structured and having uniform "Visual" layout, I think would be better in this repo as I think it creates a linear structure of codes.
That's my 2 cents on this.
I think it's pretty good. There are still a couple of weird edge cases, but we can refine the config later if we find better defaults. |
@azerupi, does that mean this is good to merge? |
Yes, I think we can merge this PR. We can still tweak the settings when we discover better defaults. I wonder if we can find a way to force or encourage the use of rustfmt for PRs. Maybe a pass in Travis? The only problem is that I don't want to block PRs on style, but I do want to make it obvious for us and the author of the PR that rustfmt was not run. |
Hmm... that's hard. Usually I have my editor set up so every time I hit save it'll format the document. Then every now and again you run I guess we could periodically make a |
Yeah, I totally agree with @Michael-F-Bryan. Periodically running cargo fmt and using the configuration file present as rustfmt.toml in this repo would be ideal. |
done. Thanks @prertik ! |
rustfmt the repository rust-lang#398
Repository was formatted using rustfmt-nightly. The max_width needed to be increased to remove errors of width being more than the default 120. Some error still persist like:
error: left behind trailing whitespace
---> /mdBook/src/utils/mod.rs:178
and with the fix of code snippets being destroyed from doc comments.