Skip to content
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

Used --statistics option does hide the rule violations #14451

Open
ssbarnea opened this issue Nov 19, 2024 · 1 comment
Open

Used --statistics option does hide the rule violations #14451

ssbarnea opened this issue Nov 19, 2024 · 1 comment
Labels
cli Related to the command-line interface needs-design Needs further design before implementation

Comments

@ssbarnea
Copy link

The fact that ruff check --statistics does disabled the output of effective line violations makes it impossible to us this as an addon option for improved output, especially when using ruff using as a pre-commit hook.

If that was its initial intention, it was implemented wrongly because it should have being just --output-format=statistics if it replaces the output.

This could be sorted by ensuring that --statistics does not affect the output format and that is output goes to stderr so it would not break tools that might process the standard output formats, which could be machine parseable.

Story: As an user, I want to see some stats about found violations, after they are listed.

@MichaReiser MichaReiser added the cli Related to the command-line interface label Nov 20, 2024
@MichaReiser
Copy link
Member

I understand your use case. But just writing to stderr is not necessarily a solution because --statistics also impacts other output formats.

❯ uvx ruff check . --statistics --output-format json > output.json

test on  main [$✘!?] via 🐍 v3.12.7 
❯ bat output.json
───────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: output.json
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ [
   2   │   {
   3   │     "code": "I001",
   4   │     "name": "unsorted-imports",
   5   │     "count": 6,
   6   │     "fixable": true
   7   │   }
   8   │ ]

I think the ask here is to make --statistics additive. Ruff should include the statistics in the output in addition to the individual diagnostics. But I'm not 100% sure about that. This requires fleshing out the UX first

@MichaReiser MichaReiser added the needs-design Needs further design before implementation label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface needs-design Needs further design before implementation
Projects
None yet
Development

No branches or pull requests

2 participants