Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gvozdvmozgu
Copy link
Collaborator

No description provided.

Copy link

github-actions bot commented May 1, 2025

Benchmark for 35acae2

Click to view benchmark
Test Base PR %
DepthMap::from_parent 39.7±0.31µs 39.6±0.28µs -0.25%
fix_complex_query 9.7±0.11ms 9.9±0.71ms +2.06%
fix_superlong 113.7±7.70ms 119.8±15.99ms +5.36%
parse_complex_query 2.8±0.05µs 2.9±0.03µs +3.57%
parse_expression_recursion 5.1±0.03µs 5.1±0.12µs 0.00%
parse_simple_query 802.3±15.14ns 837.3±69.96ns +4.36%

Copy link

github-actions bot commented May 1, 2025

Benchmark for f9cb68e

Click to view benchmark
Test Base PR %
DepthMap::from_parent 40.1±0.23µs 39.7±0.54µs -1.00%
fix_complex_query 9.3±0.13ms 9.7±0.79ms +4.30%
fix_superlong 91.8±6.71ms 101.7±14.49ms +10.78%
parse_complex_query 2.9±0.03µs 2.9±0.05µs 0.00%
parse_expression_recursion 5.1±0.06µs 5.0±0.07µs -1.96%
parse_simple_query 814.3±6.96ns 803.8±17.10ns -1.29%

@gvozdvmozgu gvozdvmozgu force-pushed the linting-result-formatter-api branch from 601bd51 to 28022fd Compare May 1, 2025 19:02
Copy link

github-actions bot commented May 1, 2025

Benchmark for 4655a09

Click to view benchmark
Test Base PR %
DepthMap::from_parent 40.7±0.44µs 40.0±0.26µs -1.72%
fix_complex_query 9.3±0.16ms 9.7±0.66ms +4.30%
fix_superlong 93.4±6.31ms 106.5±17.48ms +14.03%
parse_complex_query 2.8±0.04µs 2.9±0.06µs +3.57%
parse_expression_recursion 5.0±0.11µs 5.1±0.08µs +2.00%
parse_simple_query 794.6±8.96ns 801.8±20.25ns +0.91%

@gvozdvmozgu gvozdvmozgu force-pushed the linting-result-formatter-api branch from 28022fd to aed4fd3 Compare May 1, 2025 19:28
Copy link

github-actions bot commented May 1, 2025

Benchmark for de62ed4

Click to view benchmark
Test Base PR %
DepthMap::from_parent 39.7±0.29µs 40.0±0.54µs +0.76%
fix_complex_query 9.2±0.11ms 9.4±0.43ms +2.17%
fix_superlong 98.5±6.37ms 100.7±8.97ms +2.23%
parse_complex_query 2.8±0.03µs 2.8±0.03µs 0.00%
parse_expression_recursion 5.0±0.06µs 5.2±0.06µs +4.00%
parse_simple_query 789.6±11.16ns 813.5±12.11ns +3.03%

@gvozdvmozgu gvozdvmozgu force-pushed the linting-result-formatter-api branch 3 times, most recently from 4025609 to aa887f2 Compare May 1, 2025 20:35
Copy link

github-actions bot commented May 1, 2025

Benchmark for 50edd6a

Click to view benchmark
Test Base PR %
DepthMap::from_parent 40.3±0.38µs 40.4±1.11µs +0.25%
fix_complex_query 9.2±0.11ms 9.6±0.56ms +4.35%
fix_superlong 94.8±7.50ms 103.6±7.51ms +9.28%
parse_complex_query 2.9±0.04µs 3.0±0.03µs +3.45%
parse_expression_recursion 5.0±0.08µs 5.1±0.07µs +2.00%
parse_simple_query 810.9±14.45ns 813.8±8.89ns +0.36%

Copy link

github-actions bot commented May 1, 2025

Benchmark for cfcf121

Click to view benchmark
Test Base PR %
DepthMap::from_parent 39.7±0.30µs 39.6±0.25µs -0.25%
fix_complex_query 9.2±0.09ms 9.5±0.58ms +3.26%
fix_superlong 92.2±6.29ms 106.0±32.97ms +14.97%
parse_complex_query 2.9±0.03µs 2.8±0.03µs -3.45%
parse_expression_recursion 5.1±0.05µs 5.0±0.05µs -1.96%
parse_simple_query 811.7±9.25ns 807.8±14.26ns -0.48%

@gvozdvmozgu gvozdvmozgu force-pushed the linting-result-formatter-api branch from e8414d6 to aa887f2 Compare May 1, 2025 21:47
@gvozdvmozgu gvozdvmozgu force-pushed the linting-result-formatter-api branch from aa887f2 to 80a07e7 Compare May 1, 2025 21:48
Copy link

github-actions bot commented May 1, 2025

Benchmark for bea2fd3

Click to view benchmark
Test Base PR %
DepthMap::from_parent 40.6±0.22µs 40.0±0.28µs -1.48%
fix_complex_query 9.4±0.11ms 9.7±0.69ms +3.19%
fix_superlong 99.6±6.87ms 105.8±15.14ms +6.22%
parse_complex_query 2.8±0.04µs 3.0±0.03µs +7.14%
parse_expression_recursion 5.0±0.04µs 5.1±0.06µs +2.00%
parse_simple_query 784.5±12.87ns 793.4±15.30ns +1.13%

Copy link

github-actions bot commented May 1, 2025

Benchmark for 73afa82

Click to view benchmark
Test Base PR %
DepthMap::from_parent 40.2±1.09µs 39.7±0.28µs -1.24%
fix_complex_query 9.4±0.13ms 9.6±0.64ms +2.13%
fix_superlong 99.3±6.26ms 110.6±16.78ms +11.38%
parse_complex_query 2.9±0.03µs 2.8±0.05µs -3.45%
parse_expression_recursion 5.0±0.04µs 5.3±0.14µs +6.00%
parse_simple_query 796.1±9.71ns 799.8±29.49ns +0.46%

@gvozdvmozgu gvozdvmozgu requested a review from Copilot May 2, 2025 16:42
Copy link

@Copilot Copilot AI left a 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 APIs for handling linting results and formatter outputs. It unifies the interfaces by replacing uses of get_violations with violations or into_violations, updates method signatures (e.g. dispatch_file_violations and completion_message), and adjusts tests and callers accordingly.

  • Updated API usage for linting results and violation collection
  • Refactored formatter interfaces and test assertions
  • Unified methods across linter, CLI, and WASM integrations

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/lsp/src/lib.rs Updated violation extraction by using into_violations()
crates/lib/tests/rules.rs Renamed variables and updated assertions to call violations()
crates/lib/src/core/rules/noqa.rs Replaced get_violations calls with violations()
crates/lib/src/core/linter/linting_result.rs Refactored to use a new() constructor and added an IntoIterator implementation
crates/lib/src/core/linter/linted_file.rs Updated violation API; added accessor methods and sorting in new()
crates/lib/src/core/linter/core.rs Refactored instantiation of LintedFile and updated violation dispatch
crates/lib/src/cli/json.rs Updated to use violations() and the accessor for path
crates/lib/src/cli/github_annotation_native_formatter.rs Updated violation dispatch using violation.rule_code() and the new API
crates/lib/src/cli/formatters.rs Adjusted formatter interface methods and test expectations
crates/lib-wasm/src/lib.rs Refactored diagnostic construction to use immutable violation references
crates/cli-lib/src/commands_lint.rs Updated invocation of completion_message with file count parameter
crates/cli-lib/src/commands_fix.rs Streamlined fix logic by using new violation handling API
Files not reviewed (2)
  • crates/cli-python/tests/json/test_fail_whitespace_before_comma.stdout: Language not supported
  • crates/cli/tests/json/test_fail_whitespace_before_comma.stdout: Language not supported

@gvozdvmozgu gvozdvmozgu requested a review from benfdking May 4, 2025 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant