Repository navigation
file-length-limit: count each skipped line once - #1928
Open
TastyHeadphones wants to merge 1 commit into
Open
TastyHeadphones wants to merge 1 commit into
TastyHeadphones wants to merge 1 commit into
Conversation
With skipComments and skipBlankLines both set, an empty line inside a block comment was subtracted twice, and two comments on one line were counted as two comment lines. Collect the skipped line numbers in a set and take comment lines from token positions instead. Closes revive-lint#1863
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 #1863
With
skipCommentsandskipBlankLinesboth enabled,file-length-limitsubtracted comment lines and blank lines separately, so an empty line inside a block comment was removed twice. Two comments on the same line (/* a */ // b) were also counted as two comment lines.The rule now collects the skipped physical line numbers in a set and subtracts its size, so each line is skipped at most once. Comment lines come from the comments' token positions instead of counting
\nin the comment text. Which lines count as comment lines is unchanged.Tests: added
testdata/file_length_limit_4_skip_comments_skip_blank_overlap.go, which has a block comment with an empty line and a line with two comments. It reports 3 lines (no failure) before this change and 5 lines after.go test -race ./...,revive --config revive.toml ./...andgolangci-lint run(v2.14.0) pass.This change was drafted with AI assistance (Grok). I reviewed the diff and ran the tests above.