ruff/crates/ruff_linter/src
Steve C f6b6f0df67
[`ruff`] Fix panic in unused `# noqa` removal with multi-byte space (`RUF100`) (#10682)
## Summary

Currently, [this
line](716688d44e/crates/ruff_linter/src/fix/edits.rs (L101))
assumes that the `noqa` comment begins with an octothorpe followed by a
space. (`# `) With anyone's random code, this of course is not always
true.

When there's a multi-byte character after the leading octothorpe, such
as
[`\u0085`](https://www.fileformat.info/info/unicode/char/85/index.htm),
we try slicing from within the character, causing a panic.

To fix this, the logic has been changed to remove unused `noqa`
directives and keep any trailing comments, or removing the whole comment
if the comment is just the unused `noqa`

Fixes #10097.

## Test Plan

`cargo test`
2024-04-01 01:00:37 +00:00
..
checkers [`pylint`] Implement `modified-iterating-set` (`E4703`) (#10473) 2024-03-31 14:37:49 +00:00
comments Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
cst Wrap expressions in parentheses when negating (#10346) 2024-03-11 18:20:55 -04:00
docstrings [`pydocstyle-D405`] Allow using `parameters` as a sub-section header (#9894) 2024-02-08 21:54:32 -05:00
fix [`ruff`] Fix panic in unused `# noqa` removal with multi-byte space (`RUF100`) (#10682) 2024-04-01 01:00:37 +00:00
importer Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
lex Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
message Feature: Add SARIF output support (#9078) 2023-12-13 00:33:19 -05:00
registry `--show-settings` displays active settings in a far more readable format (#9464) 2024-01-12 14:30:29 -05:00
rules [`ruff`] Fix panic in unused `# noqa` removal with multi-byte space (`RUF100`) (#10682) 2024-04-01 01:00:37 +00:00
settings [`flake8-boolean-trap`] Add setting for user defined allowed boolean trap (#10531) 2024-03-30 00:26:12 +00:00
snapshots Detect automagic-like assignments in notebooks (#9653) 2024-01-29 12:55:44 +00:00
codes.rs [`pylint`] Implement `modified-iterating-set` (`E4703`) (#10473) 2024-03-31 14:37:49 +00:00
directives.rs Track quoting style in the tokenizer (#10256) 2024-03-08 08:40:06 +00:00
doc_lines.rs Split `Constant` to individual literal nodes (#8064) 2023-10-30 12:13:23 +05:30
fs.rs Rename `ruff` crate to `ruff_linter` (#7529) 2023-09-20 08:38:27 +02:00
lib.rs Rename `Autofix` to `Fix` (#7657) 2023-09-28 10:53:05 +00:00
line_width.rs `--show-settings` displays active settings in a far more readable format (#9464) 2024-01-12 14:30:29 -05:00
linter.rs [`pycodestyle`] Implement `redundant-backslash` (`E502`) (#10292) 2024-03-11 21:15:06 -04:00
logging.rs Make `--config` and `--isolated` global flags (#10150) 2024-03-04 11:19:40 +00:00
noqa.rs Respect external codes in file-level exemptions (#10203) 2024-03-03 00:20:36 +00:00
packaging.rs Nested namespace packages support (#10541) 2024-03-24 22:53:32 -04:00
pyproject_toml.rs Update pyproject-toml to 0.8 (#8351) 2023-10-30 10:05:37 +00:00
registry.rs Put flake8-logging next to the other flake8 plugins in registry (#10587) 2024-03-25 20:23:31 +00:00
renamer.rs Correctly handle references in `__all__` definitions when renaming symbols in autofixes (#10527) 2024-03-22 20:06:35 +00:00
rule_redirects.rs Bump version to 0.2.0 (#9762) 2024-02-01 17:10:33 -06:00
rule_selector.rs Fix clippy unused variable warning (#9902) 2024-02-08 22:13:31 +00:00
source_kind.rs CLI: Color entire line in Diffs (#10183) 2024-03-01 13:53:45 +01:00
test.rs Update Rust to v1.77 (#10510) 2024-03-21 12:10:33 -04:00
upstream_categories.rs Fix pylint upstream categories not showing in docs (#10441) 2024-03-18 01:27:39 +00:00