1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-25 22:12:38 +02:00

fix: avoid false positive for blank identifier (#1376)

The fact that the error variable is not used is out of the scope of the rule

This pattern that can be found in benchmarks and examples.
It should be allowed.
This commit is contained in:
ccoVeille
2025-05-25 16:36:22 +02:00
committed by GitHub
parent a56cf7290e
commit a4737e935a
2 changed files with 22 additions and 1 deletions

View File

@@ -61,6 +61,17 @@ func (w lintErrors) Visit(_ ast.Node) ast.Visitor {
}
id := spec.Names[0]
if id.Name == "_" {
// avoid false positive for blank identifier
// The fact that the error variable is not used
// is out of the scope of the rule
// This pattern that can be found in benchmarks and examples
// should be allowed.
continue
}
prefix := "err"
if id.IsExported() {
prefix = "Err"