rust-lang / rust-lang/rust-clippy

[Tracking issue] Rearrange location of some of the existing lints

Open
#6,680 30 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-an-interesting-project C-tracking-issue E-medium
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 in clippy_lints/src/methods/mod.rs. Would be good if the implementations went to clippy_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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.