Skip to content

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

Open

Description

@magurotuna

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.

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

Activity

  1. added
    C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.
    E-mediumCall for participation: Medium difficulty level problem and requires some initial experience.
    on Feb 6, 2021
  2. nahuakang commented on Feb 6, 2021

    @nahuakang
    Contributor

    @magurotuna @camsteffen Shall we kick this off sometime this month? I could focus on loops since I just came from it (and there are only 18 lints). But I think for methods we'd need to split carefully since it has 50+ lints 🤔

  3. flip1995 commented on Feb 6, 2021

    @flip1995
    Member

    Also feel free to split this not only in multiple commits, but also in multiple PRs.

  4. camsteffen commented on Feb 6, 2021

    @camsteffen
    Contributor

    @nahuakang Sure! But frankly I don't want to promise anything from me at this point. For organization, I would recommend we comment here on what group you're currently working on. But you don't have to do an entire group.

  5. phansch commented on Feb 7, 2021

    @phansch
    Contributor

    clippy_lints/src/<group_name>/<lint_name>.rs

    If group_name refers to lint groups like restriction or pedantic, it's worth noting that these change quite often compared to lint names. So, if someone changes the lint group of a lint they will have to move it to the correct directory as well, adding some extra work. Not sure if that's fine?

    If it just refers to unrelated group names, ignore what I said =)

  6. nahuakang commented on Feb 7, 2021

    @nahuakang
    Contributor

    @phansch The group_name would be methods or loops so that new contributors have an easier time finding lints or understanding the structure of the repo 😁 You are right that it shouldn't be the lint group categories.

  7. magurotuna commented on Feb 7, 2021

    @magurotuna
    ContributorAuthor

    I'll work on "transmute" group :)

  8. Y-Nak commented on Feb 9, 2021

    @Y-Nak
    Contributor

    I'll work on types!

  9. flip1995 commented on Feb 14, 2021

    @flip1995
    Member

    @Y-Nak @nahuakang @magurotuna Do you want to cross-review your PRs to make sure that you all used the same "style" for the restructuring, so the Clippy code is consistent? That would be a big help for me reviewing those PRs because I don't have to compare them to eachother.

  10. nahuakang commented on Feb 14, 2021

    @nahuakang
    Contributor

    Can do. Mine is ready for review. @Y-Nak @magurotuna is either of yours ready for a first comparison? :)

  11. flip1995 commented on Feb 14, 2021

    @flip1995
    Member

    After a quick scan of the PRs it seems that all are ready for review. 👍

  12. magurotuna commented on Feb 14, 2021

    @magurotuna
    ContributorAuthor

    Yes, mine is ready too. I'll have a look at the PRs of @nahuakang and @Y-Nak when I have time :)

  13. Y-Nak commented on Feb 14, 2021

    @Y-Nak
    Contributor

    @flip1995 Sure, I'll review them.
    @nahuakang @magurotuna mine is also ready, please see #6724 before reviewing my PR.

  14. 11 remaining items

  15. magurotuna commented on Mar 24, 2021

    @magurotuna
    ContributorAuthor

    Btw, it would be better to discuss how to refactor misc. All lints in misc seem not relevant to each other at all, so I think it makes sense to declare lint passes for each lint.

    Agreed. I don't see any specific reason why the lints that are currently categorized as "misc" are there. "misc" is so ambiguous that it makes people think a new lint that seems trivial to them should go into "misc". What kind of lints seem trivial to people differs from person to person IMO. Thus it makes more sense to me too, to separate the lints in "misc" and declare individual lint passes for them.

  16. flip1995 commented on Mar 24, 2021

    @flip1995
    Member

    I think for misc some of the lints there would also fit in already existing modules. misc and misc_early are both artifacts from the early days of Clippy. I agree that it might be good to split up and get rid of those modules completely.

  17. magurotuna commented on Mar 24, 2021

    @magurotuna
    ContributorAuthor

    Cool! I updated the description of this issue, adding a misc_early checkbox and how to refactor misc and misc_early.
    I would like to work on misc :)

  18. added a commit that references this issue on Mar 30, 2021
  19. Y-Nak commented on Mar 31, 2021

    @Y-Nak
    Contributor

    @magurotuna Could you update the TODO list? Refactoring functions has been done in #6990.

  20. magurotuna commented on Mar 31, 2021

    @magurotuna
    ContributorAuthor

    @Y-Nak Great job! Updated.

  21. Y-Nak commented on Apr 16, 2021

    @Y-Nak
    Contributor

    Oh, we missed matches.rs. I'll work on it.
    @magurotuna could you add it to the TODO list, please?

  22. magurotuna commented on Apr 17, 2021

    @magurotuna
    ContributorAuthor

    @Y-Nak Sure, added!


    Anyway, recently I've been mostly working on another project so I don't have enough time to refactor misc despite of my previous post. I'll withdraw from misc work for the moment. If anyone is interested in it, please feel free to take it over :D

  23. TaKO8Ki commented on Apr 22, 2021

    @TaKO8Ki
    Member

    Can I also work on misc_early group?

  24. flip1995 commented on Apr 22, 2021

    @flip1995
    Member

    Sure! If you have questions on where lints should go, I think the best place to discuss this is on Zulip.

  25. added a commit that references this issue on May 6, 2021
  26. added a commit that references this issue on Feb 7, 2022
  27. ada4a commented on Sep 7, 2025

    @ada4a
    Contributor

    I think matches can be crossed out as well, thanks to #8400

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-an-interesting-projectCategory: Interesting projects, that usually are more involved design/code wise.C-tracking-issueCategory: Tracking IssueE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions