-
Notifications
You must be signed in to change notification settings - Fork 285
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
fix duplicated findings for string-format when there is more than one… #1085
Conversation
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.
Please run gofmt -w rule/string-format.go
to fix comments that I left.
rule/string-format.go
Outdated
@@ -216,7 +216,7 @@ func (w lintStringFormatRule) Visit(node ast.Node) ast.Visitor { | |||
for _, rule := range w.rules { | |||
for _, scope := range rule.scopes { | |||
if scope.funcName == callName { | |||
rule.Apply(call) | |||
rule.apply(call,scope) |
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.
rule.apply(call,scope) | |
rule.apply(call, scope) |
rule/string-format.go
Outdated
} | ||
|
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.
Redundant TAB, can be removed:
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.
I'm suggesting adding the test to verify that the issue is really fixed.
test/string-format_test.go
:
func TestStringFormatDuplicatedStrings(t *testing.T) {
testRule(t, "string-format-issue-1063", &rule.StringFormatRule{}, &lint.RuleConfig{
Arguments: lint.Arguments{[]any{
"fmt.Errorf[0],errors.New[0]",
"/^([^A-Z]|$)/",
"must not start with a capital letter",
}},
})
}
testdata/string-format-issue-1063.go
:
package fixtures
import (
"errors"
)
func ReturnError() error {
return errors.New("This is an error.") // MATCH /must not start with a capital letter/
}
Closes #1063 + minor code refactoring