aboutsummaryrefslogtreecommitdiffstats
path: root/defererr.go
diff options
context:
space:
mode:
authorTeddy Wing2023-05-25 21:25:52 +0200
committerTeddy Wing2023-05-25 21:25:52 +0200
commit00707a7693c67076898556f2f5de2c8db46a0463 (patch)
tree7b2fe78d288f290968477fe073d32a67e5f23e91 /defererr.go
parent775991e6a57fddfd69f1cae4d0aee9c234855286 (diff)
downloadgodefererr-00707a7693c67076898556f2f5de2c8db46a0463.tar.bz2
Add more detail to the explanation of how the analyser works
Diffstat (limited to 'defererr.go')
-rw-r--r--defererr.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/defererr.go b/defererr.go
index 498708c..226e52b 100644
--- a/defererr.go
+++ b/defererr.go
@@ -16,10 +16,11 @@ var Analyzer = &analysis.Analyzer{
}
func run(pass *analysis.Pass) (interface{}, error) {
- // TODO: Find defer closure
- // Does it set error defined in outer scope?
- // Does outer scope declare error variable in signature?
- // Is err variable returned after closure?
+ // Look at each function and check if it returns an error.
+ // If so, look for a defer inside the function.
+ // If a captured error variable is defined in the defer's closure, ensure
+ // that the variable is declared in the function's signature, and that any
+ // returns after the defer closure use the assigned error variable.
for _, file := range pass.Files {
checkFunctions(pass, file)