Skip to content

Commit

Permalink
Fix TODO directive out of bounds acccess (#13756)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Oct 15, 2024
1 parent 04b636c commit 72ac6cd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@
# hack: hack
# FIXME: fixme
# fixme: fixme

# test # TODO: todo


# #d#
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<'a> TodoDirective<'a> {
// Shrink the subset to check for the next phrase starting with "#".
if let Some(new_offset) = trimmed.find('#') {
relative_offset += TextSize::try_from(new_offset).unwrap();
subset = &subset[relative_offset.to_usize()..];
subset = &comment[relative_offset.to_usize()..];
} else {
break;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ T00.py:7:3: FIX001 Line contains FIXME, consider resolving the issue
|

T00.py:8:3: FIX001 Line contains FIXME, consider resolving the issue
|
6 | # hack: hack
7 | # FIXME: fixme
8 | # fixme: fixme
| ^^^^^ FIX001
|


|
6 | # hack: hack
7 | # FIXME: fixme
8 | # fixme: fixme
| ^^^^^ FIX001
9 |
10 | # test # TODO: todo
|
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,10 @@ T00.py:2:3: FIX002 Line contains TODO, consider resolving the issue
4 | # xxx: xxx
|


T00.py:10:10: FIX002 Line contains TODO, consider resolving the issue
|
8 | # fixme: fixme
9 |
10 | # test # TODO: todo
| ^^^^ FIX002
|

0 comments on commit 72ac6cd

Please sign in to comment.