-
-
Notifications
You must be signed in to change notification settings - Fork 514
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
cli: patch | ||
biome_analyze: patch | ||
--- | ||
|
||
# Suppression comment should not fail with inner comments in functions | ||
|
||
The follwing code: | ||
|
||
```ts | ||
// biome-ignore lint/complexity/useArrowFunction: not work | ||
const foo0 = function (bar: string) { | ||
// biome-ignore lint/style/noParameterAssign: work | ||
bar = "baz"; | ||
}; | ||
``` | ||
|
||
The suppression comment `// biome-ignore lint/style/noParameterAssign: work` will not be invalid. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
use biome_console::markup; | ||
use biome_parser::AnyParse; | ||
use std::cmp::Ordering; | ||
use std::collections::{BTreeMap, BinaryHeap}; | ||
use std::fmt::{Debug, Display, Formatter}; | ||
use std::ops; | ||
|
@@ -448,19 +447,15 @@ where | |
let index = | ||
self.suppressions | ||
.line_suppressions | ||
.binary_search_by(|suppression| { | ||
if suppression.text_range.end() < entry.text_range.start() { | ||
Ordering::Less | ||
} else if entry.text_range.end() < suppression.text_range.start() { | ||
Ordering::Greater | ||
} else { | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, i think this will be the right way here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks
ematipico marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
index | ||
.ok() | ||
.map(|index| &mut self.suppressions.line_suppressions[index]) | ||
if index >= self.suppressions.line_suppressions.len() { | ||
None | ||
} else { | ||
Some(&mut self.suppressions.line_suppressions[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.
You must add the cli package too. Please read the contribution guide regarding the changesets
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.
done