-
Notifications
You must be signed in to change notification settings - Fork 925
checkstyle line numbers are offset #1386
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
sgtm |
work around for rust-lang/rustfmt#1386
ideally we'd have a begin and end of the mismatch for #1384 |
Is it possible to raise the priority or give me mentoring on how to correct this bug? |
What exactly is the ask, to have the If so, I can submit a PR with a fix |
I think this would be a good solution, thanks! |
Well this is turning out to be more complicated than I'd anticipated 😄 The biggest question I have is around what the expected or "correct" checkstyle xml content should be in this context as it's not clear to me what folks are using the checkstyle output for. For a contrived example, take this source file: 1|fn add(x: i32,
2|y: i32) -> i32 {
3| x + y
4|}
5|
6|
7|fn multiply(a: i32,
8|b: i32) -> i32 {
9| a * b
10| } With standard config options, this would be formatted to: 1|fn add(x: i32, y: i32) -> i32 {
2| x + y
3|}
4|
5|fn multiply(a: i32, b: i32) -> i32 {
6| a * b
7|} If the checkstyle line numbers correspond to the formatted file, then we could reflect the mismatched lines with something like this: <error line="1" severity="warning" message="Should be `fn add(x: i32, y: i32) -> i32 {`" />
<error line="2" severity="warning" message="Should be ` x + y`" />
<error line="5" severity="warning" message="Should be `fn multiply(a: i32, b: i32) -> i32 {`" />
<error line="6" severity="warning" message="Should be ` a * b`" />
<error line="7" severity="warning" message="Should be `}`" /> Things get a little tricky though when lines are removed as part of formatting. Take that closing Would folks expect any/all of those other lines (3, 4, and/or 8-10) to be included in the checkstyle xml as well? |
in src/rustfmt_diff.rs line 41 line number is offset by context_queue to start the line at the start of the patch
but will make the output of checkstyle incorrect.
this affects PR1384
would adding be another member to Mismatch with the real line number be ok?
The text was updated successfully, but these errors were encountered: