-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
fix(analyzer): suppression comment fails with inner comments in functions #4714
base: next
Are you sure you want to change the base?
Conversation
ff1d948
to
3628241
Compare
CodSpeed Performance ReportMerging #4714 will degrade performances by 16.66%Comparing Summary
Benchmarks breakdown
|
3628241
to
f4a8048
Compare
Would it make sense to add a cli test for this particular case? Just so we have something to make sure this doesn't break in the future. |
We already have tests for suppressions where we enable multiple rules. You can add a new one in this file: biome/crates/biome_js_analyze/src/lib.rs Lines 719 to 766 in 3914be8
|
@ematipico i run the test case you show to me, we i change this const SOURCE: &str = "
// biome-ignore-start lint/suspicious/noDoubleEquals: single rule
// biome-ignore-start lint/style/useConst: single rule
a == b;
let c;
// biome-ignore-end lint/suspicious/noDoubleEquals: single rule
a == b;
let c;
"; to: const SOURCE: &str = "
// biome-ignore-start lint/suspicious/noDoubleEquals: single rule
a == b;
let c;
// biome-ignore-end lint/suspicious/noDoubleEquals: single rule
a == b;
let c;
"; It can also pass the test, is this correct? |
Changing the source code isn't enough, you need to check the assertions too. I don't remember them right now, but if you change source input, you need to make sure that the assertions make sense with the new input. Looking at the code, it should fail. |
f4a8048
to
58d2499
Compare
Ordering::Equal | ||
} | ||
.partition_point(|suppression| { | ||
suppression.text_range.end() < entry.text_range.start() |
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.
based on the Rust documentation for partition_point, is my understanding correct that the order suppression.text_range.end() < entry.text_range.start()
follows Rust conventions for finding the boundary point of non-overlapping ranges?
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.
yes, i think this will be the right way here
Summary
closes: #4519
This is a little change, but it's hard for me to find and fix it.
Use the case from the issue as examples:
There are two suppression comments in the code:
In the logic of the https://github.com/biomejs/biome/blob/main/crates/biome_analyze/src/lib.rs#L371 , the method
flush_matches
will choose the second suppression for the code:function (bar: string)
, so it will not match the rulelint/complexity/useArrowFunction
but matchlint/style/noParameterAssign
. So it will cause the problem of the issue describes.I just change the logic of
self.suppressions.line_suppressions.binary_search(|suppression| {...})
and change the priority of thesuppresion_range
.Test Plan
Sorry, i can't add test case for this change, because this test case need to enable two rules (
lint/complexity/useArrowFunction
andlint/style/noParameterAssign
) for a test file, now the biome rule's test case ofbiome_js_analyzer
is generated by the directory name(only allow enable single rule in a file). But i test my pr at my local file, and it can be passed: i change the code ofquick_test
and enable two rules for a test case and it can work.