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.
[linter-miner] feat(linters): add fmterrorfnoverbs linter #36146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
[linter-miner] feat(linters): add fmterrorfnoverbs linter #36146
Changes from all commits
51902d5cd4f1aaFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] Manual string unquoting (
val[1:len(val)-1]) is fragile. It happens to work for both double-quoted and backtick-quoted literals since both delimiters are single characters, but it silently mishandles any edge casego/constantwould ordinarily handle. Preferstrconv.Unquotefor interpreted string literals and skip the manual slice for raw literals.💡 Safer approach
constant.StringValalready handles interpreted string escapes, raw literals, and multi-line strings uniformly — no manual slicing needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False negative:
%%-only strings are silently skipped.strings.Contains(val, "%")returnstruefor"100%%"sofmt.Errorf("100%% complete")is never flagged — but%%is the fmt escape for a literal%, not a format verb.💡 Suggested fix
Replace the broad
%check with a scan that skips%%pairs:Then:
Add a fixture:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] False negative for
%%escape sequences:strings.Contains(val, "%")returnstruefor strings like"100%% done", which contain no actual format verbs — so the call is never flagged, even thougherrors.Newwould be more appropriate.💡 Suggested fix
Strip
%%before checking for%, so only real format verbs are detected:Add a test fixture for this case:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] Test fixtures are missing two important edge cases:
%%escape sequences (false negative as noted in the implementation) and raw string literals (backtick-quoted). Adding these as fixtures would both document expected behaviour and guard against regressions.💡 Suggested additions
Note:
badPercentEscapewill only pass once the implementation is fixed to strip%%before the%check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test cases leave two detectable paths untested. The fixtures only cover double-quoted strings. Raw string literals (backtick) and the
%%false-negative case are not exercised, so regressions in those paths would go unnoticed.💡 Suggested additions
Uh oh!
There was an error while loading. Please reload this page.