1
0
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:
chavacava
2025-01-28 14:53:32 +01:00
committed by GitHub
parent a600be2470
commit 8c5d8fc90a
2 changed files with 15 additions and 2 deletions

View File

@@ -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{}{}
}

View File

@@ -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
}
}