Add missing close file and missing stop ticker (#300)

* Add missing close file and missing stop ticker

* Defer close file after checking error

* Update exchange_template.go
This commit is contained in:
leilaes
2019-05-17 13:17:35 +12:00
committed by Adrian Gallagher
parent 17a6acf58a
commit 46267e5975
6 changed files with 40 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ tenets:
- import: codelingo/effective-go/underscores-in-name
- import: codelingo/effective-go/unnecessary-else
- import: codelingo/code-review-comments/declare-empty-slice
- import: codelingo/effective-go/defer-close-file
# Overwrite one tenet with custom logic
# - import: codelingo/effective-go/comment-first-word-when-empty
- name: comment-first-word-when-empty
@@ -32,3 +33,31 @@ tenets:
go.ident:
name as funcName
public == "true"
- name: missing-stop-ticker
flows:
codelingo/review:
comment: Add `defer {{varName}}.Stop()` to stop the ticker and release associated resources.
query: |
import codelingo/ast/go
go.func_decl(depth = any):
@review comment
go.assign_stmt(depth = any):
go.lhs:
go.ident:
sibling_order == 0
name as varName
go.rhs:
go.call_expr:
go.selector_expr:
go.ident:
name == "time"
go.ident:
name == "NewTicker"
exclude:
go.call_expr(depth = any):
go.selector_expr:
go.ident:
name == varName
go.ident:
name == "Stop"