Commit 9925910
authored
Add a
Summary
--
This PR adds a macro-generated method to retrieve the `Rule` associated
with a given `Violation` struct, which makes it substantially cheaper
than parsing from the rule name. The rule is then converted to a
`NoqaCode` for storage on the `Message` (and eventually on the new
diagnostic type). The `ViolationMetadata::rule_name` method was now
unused, so the `rule` method replaces it.
Several types had to be moved from the `ruff_diagnostics` crate to the
`ruff_linter` crate to make this work, namely the `Violation` traits and
the old `Diagnostic` type, which had a constructor generic over a
`Violation`.
It's actually a fairly small PR, minus the hundreds of import changes.
The main changes are in these files:
-
[crates/ruff_linter/src/message/mod.rs](https://github.com/astral-sh/ruff/pull/18234/files#diff-139754ea310d75f28307008d21c771a190038bd106efe3b9267cc2d6c0fa0921)
-
[crates/ruff_diagnostics/src/lib.rs](https://github.com/astral-sh/ruff/pull/18234/files#diff-8e8ea5c586935bf21ea439f24253fcfd5955d2cb130f5377c2fa7bfee3ea3a81)
-
[crates/ruff_linter/src/diagnostic.rs](https://github.com/astral-sh/ruff/pull/18234/files#diff-1d0c9aad90d8f9446079c5be5f284150d97797158715bd9729e6f1f70246297a)
-
[crates/ruff_linter/src/lib.rs](https://github.com/astral-sh/ruff/pull/18234/files#diff-eb93ef7e78a612f5fa9145412c75cf6b1a5cefba1c2233e4a11a880a1ce1fbcc)
Test Plan
--
Existing testsViolationMetadata::rule method (#18234)1 parent a3ee6bb commit 9925910
709 files changed
Lines changed: 931 additions & 888 deletions
File tree
- crates
- ruff_dev
- src
- ruff_diagnostics
- src
- ruff_linter/src
- checkers
- ast
- analyze
- fix
- importer
- message
- rules
- airflow/rules
- eradicate/rules
- fastapi/rules
- flake8_2020/rules
- flake8_annotations
- rules
- flake8_async/rules
- flake8_bandit/rules
- flake8_blind_except/rules
- flake8_boolean_trap/rules
- flake8_bugbear/rules
- flake8_builtins/rules
- flake8_commas/rules
- flake8_comprehensions
- rules
- flake8_copyright/rules
- flake8_datetimez/rules
- flake8_debugger/rules
- flake8_django/rules
- flake8_errmsg/rules
- flake8_executable/rules
- flake8_fixme/rules
- flake8_future_annotations/rules
- flake8_gettext/rules
- flake8_implicit_str_concat/rules
- flake8_import_conventions/rules
- flake8_logging_format
- rules
- flake8_logging/rules
- flake8_no_pep420/rules
- flake8_pie/rules
- flake8_print/rules
- flake8_pyi/rules
- flake8_pytest_style/rules
- flake8_quotes/rules
- flake8_raise/rules
- flake8_return/rules
- flake8_self/rules
- flake8_simplify/rules
- flake8_slots/rules
- flake8_tidy_imports/rules
- flake8_todos/rules
- flake8_type_checking
- rules
- flake8_unused_arguments/rules
- flake8_use_pathlib
- rules
- flynt/rules
- isort/rules
- mccabe/rules
- numpy/rules
- pandas_vet/rules
- pep8_naming/rules
- perflint/rules
- pycodestyle/rules
- logical_lines
- pydoclint/rules
- pydocstyle/rules
- pyflakes
- rules
- pygrep_hooks/rules
- pylint/rules
- pyupgrade/rules
- pep695
- refurb
- rules
- ruff/rules
- tryceratops/rules
- settings
- ruff_macros/src
- ruff_server/src/server/api/requests
- ruff/src
- commands
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
353 | 352 | | |
354 | 353 | | |
355 | 354 | | |
356 | 355 | | |
357 | 356 | | |
358 | 357 | | |
359 | 358 | | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | 4 | | |
7 | | - | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
11 | | - | |
0 commit comments