mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
fix: flag-parameter rule wrongly detects var definition and points to the function signature (#1213)
This commit is contained in:
@@ -69,6 +69,11 @@ func (w conditionVisitor) Visit(node ast.Node) ast.Visitor {
|
||||
return false
|
||||
}
|
||||
|
||||
_, ok = w.idents[ident.Name]
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
return w.idents[ident.Name] == struct{}{}
|
||||
}
|
||||
|
||||
|
||||
12
testdata/flag_param.go
vendored
12
testdata/flag_param.go
vendored
@@ -1,11 +1,19 @@
|
||||
package fixtures
|
||||
|
||||
func foo(a bool, b int) { // MATCH /parameter 'a' seems to be a control flag, avoid control coupling/
|
||||
func fooFlagP(a bool, b int) { // MATCH /parameter 'a' seems to be a control flag, avoid control coupling/
|
||||
if a {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func foo(a bool, b int) {
|
||||
func barFlagP(a bool, b int) {
|
||||
str := mystruct{a, b}
|
||||
}
|
||||
|
||||
// issue #1211
|
||||
func bazFlagP(a int, b bool) {
|
||||
lBool := true
|
||||
if lBool {
|
||||
// do something
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user