Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoCompareNegZeroRule = rule.CreateRule(rule.Rule{ Name: "no-compare-neg-zero", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { operatorsToCheck := map[ast.Kind]bool{ ast.KindGreaterThanToken: true, ast.KindGreaterThanEqualsToken: true, ast.KindLessThanToken: true, ast.KindLessThanEqualsToken: true, ast.KindEqualsEqualsToken: true, ast.KindEqualsEqualsEqualsToken: true, ast.KindExclamationEqualsToken: true, ast.KindExclamationEqualsEqualsToken: true, } return rule.RuleListeners{ ast.KindBinaryExpression: func(node *ast.Node) { binary := node.AsBinaryExpression() if binary == nil || binary.OperatorToken == nil { return } if !operatorsToCheck[binary.OperatorToken.Kind] { return } if isNegativeZero(binary.Left) || isNegativeZero(binary.Right) { operatorText := getOperatorText(binary.OperatorToken.Kind) ctx.ReportNode(node, buildCompareNegZeroMessage(operatorText)) } }, } }, })
NoCompareNegZeroRule disallows comparisons to negative zero
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.