ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Add easier way to gather all available rules from ruff

Open qarmin opened this issue 1 year ago • 3 comments

Since 0.2.0 version, my fuzzer CI stopped working.

In CI, first I start to search for broken files, minimize sample size and at the end minimize number of rules, that are needed to produce problem.

Minimization of rules is done via this steps:

  • getting all rules from ruff - this is done via ruff rule --all command and manually parsing all rules in ()
  • splitting available rules by half and checking if ruff still produce error
  • repeating until found minimal amount of rules

0.2.0 version removed rule PLR1706 which is still available in ruff rule --all with section ## Removal and ruff started to fail each time with message

ruff failed
  Cause: Rule `PLR1706` was removed and cannot be selected.

At least for now I can modify a little rule parser, but probably this will be more problematic in future.

So maybe ruff could produce simple list of rules(enabled/removed etc.) like AN001,AN002 or export them to json file via rull rule --export a.json or ruff rule --available-simple?

qarmin avatar Feb 08 '24 08:02 qarmin

Does ruff rule --all --output-format json work for this?

charliermarsh avatar Feb 10 '24 23:02 charliermarsh

Eh.., I searched for a similar option but did not find it.

It would be good to add to this json the fields "removed'': bool and "deprecated'': bool to avoid having to parse explanation field.

qarmin avatar Feb 11 '24 06:02 qarmin

Yes I was just about to open a feature request for this; currently the JSON output does not contain any information regarding whether a rule still exists. Either there should be a key or there should be a flag to exclude removed rules.

ofek avatar Feb 18 '24 18:02 ofek