Skip to content

Commit

Permalink
fix: fix false-positive (#97)
Browse files Browse the repository at this point in the history
Signed-off-by: Sasha Melentyev <sasha@m8.ru>
  • Loading branch information
sashamelentyev authored Jun 12, 2024
1 parent 5149298 commit a7b3ee4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ func run(pass *analysis.Pass) (interface{}, error) {

case *ast.BinaryExpr:
switch n.Op {
case token.LSS, token.GTR, token.LEQ, token.GEQ:
case token.LSS, token.GTR, token.LEQ, token.GEQ, token.QUO, token.ADD, token.SUB, token.MUL:
return
default:
}

x, ok := n.X.(*ast.SelectorExpr)
Expand All @@ -138,7 +139,6 @@ func run(pass *analysis.Pass) (interface{}, error) {
if ok {
switchStmt(pass, x, n.Body.List)
}

}
})

Expand Down
28 changes: 28 additions & 0 deletions pkg/analyzer/testdata/src/a/http/issue96.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package http_test

import (
"net/http"
)

func _() error {
resp, err := http.DefaultClient.Do(&http.Request{})
if err != nil {
return err
}
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode/100 != 2 {
return nil
}
if resp.StatusCode+100 != 2 {
return nil
}
if resp.StatusCode-100 != 2 {
return nil
}
if resp.StatusCode*100 != 2 {
return nil
}

return nil
}

0 comments on commit a7b3ee4

Please sign in to comment.