1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-29 22:28:23 +02:00

fix: add-constant struct tags in anonymous struct literals false positive (#954)

* fix: add-constant struct tags in anonymous struct literals false positive
This commit is contained in:
Denis Voytyuk
2023-12-28 23:59:58 +01:00
committed by GitHub
parent 8d5724f746
commit f8e122f43d
2 changed files with 67 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ import (
"os"
)
func foo(a, b, c, d int) {
func foo(a float32, b string, c any, d int) {
a = 1.0 // ignore
b = "ignore"
c = 2 // ignore
@@ -51,3 +51,39 @@ func ignoredFunc(num int) int {
func notIgnoredFunc(num int) int {
return num
}
func tagsInStructLiteralsShouldBeOK() {
a := struct {
X int `json:"x"`
}{}
b := struct {
X int `json:"x"`
}{}
c := struct {
X int `json:"x"`
}{}
d := struct {
X int `json:"x"`
Y int `json:"y"`
}{}
e := struct {
X int `json:"x"`
Y int `json:"y"`
}{}
var f struct {
X int `json:"x"`
Y int `json:"y"`
}
var g struct {
X int `json:"x"`
Y int `json:"y"`
}
_, _, _, _, _, _, _ = a, b, c, d, e, f, g
}