aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2023-05-17 20:57:05 +0200
committerTeddy Wing2023-05-17 20:57:05 +0200
commit939b3aad88ce3043906d95329fecd8302ea3d9d7 (patch)
tree8705c1101a069c70cbf4c47b506c153569129941
parentb5759209f12d595e1f65cce85703c5051bd828f1 (diff)
downloadgocapturedrefrace-939b3aad88ce3043906d95329fecd8302ea3d9d7.tar.bz2
Separate `isVariableTypeSignature` condition
It doesn't need to be attached to the `funcScope` condition as it's a separate check. Wasn't thinking carefully when I added the check.
-rw-r--r--gocapturedrefrace.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/gocapturedrefrace.go b/gocapturedrefrace.go
index 66be1e9..ff5ac9a 100644
--- a/gocapturedrefrace.go
+++ b/gocapturedrefrace.go
@@ -26,6 +26,8 @@ import (
"golang.org/x/tools/go/analysis"
)
+var version = "0.0.1"
+
var Analyzer = &analysis.Analyzer{
Name: "gocapturedrefrace",
Doc: "reports captured references in goroutine closures",
@@ -108,13 +110,14 @@ func checkClosure(pass *analysis.Pass, funcLit *ast.FuncLit) {
// Ignore captured callable variables, like function arguments.
_, isVariableTypeSignature := variable.Type().(*types.Signature)
+ if isVariableTypeSignature {
+ return true
+ }
// TODO: Ignore shadowing variables.
// Identifier was defined in a different scope.
- if funcScope != scope &&
- !isVariableTypeSignature {
-
+ if funcScope != scope {
pass.Reportf(
ident.Pos(),
"captured reference %s in goroutine closure",