New lint: too_many_lines_in_file#16675
Open
tupe12334 wants to merge 1 commit intorust-lang:masterfrom
Open
Conversation
Collaborator
|
r? @llogiq rustbot has assigned @llogiq. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
Lintcheck changes for 2c4c95a
This comment will be updated if you push new changes |
Adds a new `restriction` lint that warns when a source file exceeds a configurable number of lines of code. Blank lines and comment-only lines are excluded from the count, mirroring the behavior of `too_many_lines`. The span points to the specific line where the threshold is exceeded, giving a more actionable location in the diagnostic. The threshold is configurable via `too-many-lines-in-file-threshold` in `clippy.toml` (default: 1000). Closes rust-lang#16674 changelog: new lint: [`too_many_lines_in_file`]
4f0e1fb to
2c4c95a
Compare
Collaborator
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16674
Summary
Adds a new
restrictionlinttoo_many_lines_in_filethat warns when a source file exceeds a configurable number of lines of code. Blank lines and comment-only lines are not counted, matching the behavior of the existingtoo_many_linesfunction-level lint.Configuration
too-many-lines-in-file-thresholdinclippy.toml(default:1000)Example diagnostic
Implementation notes
EarlyLintPasswithcheck_crate, iterating all source files in the session source mapfile.cnum == LOCAL_CRATE) to avoid checking dependenciestoo_many_lines: skips blank lines and comment-only lines (including/* */block comments)file.start_pos(line 1, col 1 of the file)Disclosure
The code in this PR was generated with the assistance of Claude Code, Anthropic's AI coding assistant.
changelog: new lint: [
too_many_lines_in_file]