rust-lang / rust-lang/rust-clippy
[Tracking issue] Rearrange location of some of the existing lints
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Currently, the lint rules grouped as "methods" reside in clippy_lints/src/methods as there are a number of rules belonging to the "methods" group.
However, although the other groups such as "loops", "types", "transmute" and "misc" also have many relavent rules, they reside not in clippy_lints/src/<group_name> but in clippy_lints/src.
It would be great to have these groups located under <group_name> directory just like "methods". So I open this issue to do this refactoring and to keep track of it.
-
loops (done by @nahuakang & @Y-Nak #6824) -
types (done by @Y-Nak #6724) -
transmute (done by @magurotuna #6716) -
functions (done by @Y-Nak #6990) -
methods (also needs to be refactored because currently most of rule implementation are included inclippy_lints/src/methods/mod.rs. Would be good if the implementations went toclippy_lints/src/methods/<lint_name>.rs.) (done by @TaKO8Ki #6886) - misc (instead of creating a new directory named
misc, split the lints one by one, and move them into where they fit most. ) - misc_early (same as
misc) (in progress by @TaKO8Ki #7166, #7208) - matches (in progress by @Y-Nak)
How to rearrange is like the following, proposed by @flip1995 on zulip
I would keep the declare_clippy_lint! in the mod.rs Best case would be that mod.rs only contains the lint definitions and the LintPass impl. Utility functions of the module should probably go in methods/utils.rs and then reexported for the module in mod.rs.
proposed by @camsteffen:
For each lint, create a new module at clippy_lints/src/<group_name>/<lint_name>.rs. Within that module, add a function fn check(cx, ..) (with any needed arguments) and move the implementation there.
CC @nahuakang @camsteffen
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing layout under clippy_lints/src, especially methods/mod.rs and the remaining misc, misc_early, and matches lint modules. Review the linked work in #7166, #7208, and the in-progress matches effort before choosing an unclaimed portion. Done means the selected lint implementations are arranged in appropriate modules while declarations and LintPass integration remain correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100