-
Notifications
You must be signed in to change notification settings - Fork 36
refactor: unify LintingResult and Formatter APIs #1568
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
Conversation
Benchmark for 35acae2Click to view benchmark
|
Benchmark for f9cb68eClick to view benchmark
|
601bd51
to
28022fd
Compare
Benchmark for 4655a09Click to view benchmark
|
28022fd
to
aed4fd3
Compare
Benchmark for de62ed4Click to view benchmark
|
4025609
to
aa887f2
Compare
Benchmark for 50edd6aClick to view benchmark
|
Benchmark for cfcf121Click to view benchmark
|
aa887f2
to
80a07e7
Compare
Benchmark for bea2fd3Click to view benchmark
|
Benchmark for 73afa82Click to view benchmark
|
80a07e7
to
a5b0784
Compare
Benchmark for 4171ecdClick to view benchmark
|
Benchmark for e745452Click to view benchmark
|
Benchmark for bffc66cClick to view benchmark
|
f28d428
to
3dd2e24
Compare
Benchmark for a957ab8Click to view benchmark
|
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.
Looks good! Just needs a rebase
3dd2e24
to
953ca34
Compare
Benchmark for 20baa4eClick to view benchmark
|
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.
Pull Request Overview
This PR refactors the LintingResult
and Formatter
APIs by encapsulating fields, introducing iterator methods, and unifying formatter signatures.
- Encapsulated
LintingResult
andLintedFile
internals and added public accessors (violations()
,len()
,has_unfixable_violations()
,into_violations()
,IntoIterator
). - Updated all call sites, tests, and formatters to use the new methods and updated
Formatter
trait to only two functions:dispatch_file_violations(&LintedFile)
andcompletion_message(count: usize)
. - Adjusted CLI and WASM code to match new APIs and updated expected outputs in JSON test fixtures.
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
crates/lsp/src/lib.rs | Switched from .violations field to .into_violations() |
crates/lib/tests/rules.rs | Renamed result variables and replaced get_violations calls |
crates/lib/src/core/rules/noqa.rs | Replaced get_violations with violations() in tests |
crates/lib/src/core/linter/linting_result.rs | Made fields private, added new , len , has_* , and IntoIterator |
crates/lib/src/core/linter/linted_file.rs | Encapsulated fields, added constructors and getters |
crates/lib/src/core/linter/core.rs | Updated creation of LintingResult and removed header dispatch |
crates/lib/src/cli/json.rs | Updated imports and formatter method signatures |
crates/lib/src/cli/github_annotation_native_formatter.rs | Updated formatter signature and violation iteration |
crates/lib/src/cli/formatters.rs | Simplified Formatter trait and refactored implementations |
crates/lib-wasm/src/lib.rs | Updated WASM linter to use .violations() and clone messages |
crates/cli/tests/json/*.stdout | Updated expected JSON output ordering |
crates/cli-python/tests/json/*.stdout | Updated expected JSON output ordering |
crates/cli-lib/src/commands_lint.rs | Changed completion_message to accept file count |
crates/cli-lib/src/commands_fix.rs | Refactored run_fix to use new API methods |
Comments suppressed due to low confidence (2)
crates/lib/tests/rules.rs:227
- [nitpick] Variable
file
here refers to a linting result; consider renaming it toresult
orlinted_file
for consistency with thePass
case.
let file = linter.lint_string_wrapped(&fail_str, false);
crates/lib/src/core/linter/linted_file.rs:17
- The attribute
#[expect(dead_code)]
is not a valid lint attribute; to allow dead code, use#[allow(dead_code)]
instead.
#[expect(dead_code)]
No description provided.