Update scripts to add and sort rules#3747
Update scripts to add and sort rules#3747JonathanPlasse wants to merge 47 commits intoastral-sh:mainfrom JonathanPlasse:sort-rules
Conversation
PR Check ResultsBenchmarkLinuxWindows |
|
CI will now fail if the rules are not sorted. |
|
Only thing remaining, adding the instructions in |
|
Currently there are 24 plugins that uses the old architecture:
Ideally, all plugins should be updated to use the new rules architecture as currently the files will be generated but will need manual tweaking with the old architecture. |
|
Ready for review. |
|
This is ready to merge as is.
|
|
I finished converting all old architectures to the new one. |
|
|
| r"(?s)Rule::(.*?),.*?Path::new\(" | ||
| r'(?:"(?:.*?)?([A-Z]+)([0-9]+)?|.+?)(?:.*?)?(_[0-9]+)?(?:.(?:pyi?|txt))?"' |
There was a problem hiding this comment.
Would you like some documentation for the regex?
|
Hey @JonathanPlasse - sorry to let this one sit for so long. I really appreciate the work here, but after discussion with some other maintainers, we've opted not to merge this. The main concern is that we're signing up for ongoing maintenance of these Python scripts which are getting increasingly complex and will need to change whenever we change implementation details of the rule files. In other words: they're parsing a lot of Rust code via regex and otherwise, and that Python parsing code will likely need modifications over time. As one example: the current version doesn't handle feature flags, and so is broken in the Ruff rules. I'm sure we could fix that bug, but it's just an example of the kind of thing we'll run into over time. Again, thank you for putting it together and sorry for the extensive delay. |
The aim of this PR is to reintroduce the use of
add_rule.pyandadd_plugin.pyinCONTRIBUTING.md.This PR also fixes the sorting of rules, this means that all new code will be sorted correctly.
The CI job to test these scripts has been improved and should test all cases.