-
Notifications
You must be signed in to change notification settings - Fork 924
excessively long lines complicates CI based format validation #1832
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
Comments
Would disabling |
That would seem to work around this particular case. I'm not sure whether or not it's a general answer though. The documentation of the exit codes suggests that the 'impossible to format' case is general in nature:
I'm not sure it the intent is for such cases to be a formatting policy violation or not. If that is indeed the case, then yeah - for anything that one would like to let through despite it not being possible to format, turning off the appropriate option seems reasonable. I took a look at https://github.com/rust-lang-nursery/rustfmt/blob/74f5a515ef025ed629cf3cf1c04ed783c9a371c6/src/lib.rs#L446 and surrounding code, and I'm not yet sure how to, or whether, those cases are differentiated. The comment (https://github.com/rust-lang-nursery/rustfmt/blob/74f5a515ef025ed629cf3cf1c04ed783c9a371c6/src/lib.rs#L627) suggests that error is used only when it cannot be corrected, but yet I see nothing different about the application of TraillingWhitespace (https://github.com/rust-lang-nursery/rustfmt/blob/74f5a515ef025ed629cf3cf1c04ed783c9a371c6/src/lib.rs#L662) which presumably can always be corrected. Basically I was considering whether the error message here should tell the user about the switch being available, but I don't know the rustfmt code base yet. My overall motivation is for I am new to rustfmt and of course defer to others, but my current thoughts are:
Modes of operation which cause failures for other reasons seem best left as opt-in behaviors in order to promote painless widespread adoption. Thoughts? |
A possible solution is discussed in #1977 (comment) Closing this issue in favour of #1977 |
(Disclaimer: I'm not actually implementing CI validation at the moment as I'm mostly learning rust, so it's a hypothetical. But it's one of the first things I'd do if Rust were to be adopted where I work, for example, and I'm intending on doing so with Travis on my personal stuff as well.)
I ran into the impossibility case:
This is because I have a comment with a long URL in it:
https://github.com/scode/tunytools/blob/master/src/bin/numstats.rs#L94
If I want to implement a CI check that ensures code is formatted, I would use the diffing mode to get a user friendly diff along with looking for exit code 4:
However since the case of impossible-to-format has an exit code of 3, and it takes precedence, I now cannot, by exit code, differentiate between "the file is otherwise fine, but there's an impossible-to-format case in it" and "the file would have been changed". The only way I see to do this would be to look at what goes to stdout, rather than pay attention to the exit code.
Because it seems reasonable to have a maximum line length policy that is allowed to be violated in certain cases such as including a link without breaking it up (though reasonable people can disagree), it seems like it would be preferable to allow this through. I can think of a few options:
Additionally:
The text was updated successfully, but these errors were encountered: