Repository navigation
feat: reduce duplicate-code false positives - #2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 03fdb720ad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| startLine := tokens[i].line | ||
| endLine := tokens[end].line | ||
| if endLine-startLine+1 < duplicateTokenMinLines { | ||
| if endLine-startLine+1 < options.MinTokenLines || !duplicateWindowHasMeaningfulStatements(syntax, fset, startLine, endLine, options.MinStatements) { |
There was a problem hiding this comment.
Count token-bearing lines for MinTokenLines
When duplicated tokens are separated by blank or comment-only lines, this checks the physical span rather than the number of lines containing tokens. For example, a 100-token sequence on three substantive lines spread across 12 physical lines passes the default MinTokenLines: 12; similarly, a configured higher threshold can be satisfied merely by adding whitespace. This defeats the newly documented token-line threshold and can preserve the false positives it is intended to suppress, so count distinct duplicateToken.line values in the candidate window instead.
Useful? React with 👍 / 👎.
Summary
duplicateCodethresholds to.gallowrc.jsonValidation
gofmtcleango test ./internal/settingspasses locally