Skip to content

Commit

Permalink
renamed function
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Apr 11, 2024
1 parent a8fb57d commit ec8edcf
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/linter/block_linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,18 +767,18 @@ func (b *blockLinter) checkIfStmt(s *ir.IfStmt) {
func (b *blockLinter) checkDangerousBoolCond(s ir.Node) {
cond, ok := s.(*ir.BooleanOrExpr)
if !ok {
checkNode(s, b)
checkNodeDangerousBoolCond(s, b)
return
}

checkIfStatementConditionBool(cond.Left, cond.Right, b)
}
func checkIfStatementConditionBool(left ir.Node, right ir.Node, b *blockLinter) {
checkNode(left, b)
checkNode(right, b)
checkNodeDangerousBoolCond(left, b)
checkNodeDangerousBoolCond(right, b)
}

func checkNode(node ir.Node, b *blockLinter) {
func checkNodeDangerousBoolCond(node ir.Node, b *blockLinter) {
switch n := node.(type) {
case *ir.ConstFetchExpr:
if strings.EqualFold(n.Constant.Value, "true") || strings.EqualFold(n.Constant.Value, "false") {
Expand All @@ -789,11 +789,11 @@ func checkNode(node ir.Node, b *blockLinter) {
b.report(node, LevelWarning, "dangerousCondition", "Potential dangerous value: you have constant int value that interpreted as bool")
}
case *ir.BooleanOrExpr:
checkNode(n.Left, b)
checkNode(n.Right, b)
checkNodeDangerousBoolCond(n.Left, b)
checkNodeDangerousBoolCond(n.Right, b)
case *ir.BooleanAndExpr:
checkNode(n.Left, b)
checkNode(n.Right, b)
checkNodeDangerousBoolCond(n.Left, b)
checkNodeDangerousBoolCond(n.Right, b)
}
}

Expand Down

0 comments on commit ec8edcf

Please sign in to comment.