Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoSelfAssignRule = rule.Rule{ Name: "no-self-assign", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { opts := parseOptions(options) return rule.RuleListeners{ ast.KindBinaryExpression: func(node *ast.Node) { binExpr := node.AsBinaryExpression() if binExpr == nil || binExpr.OperatorToken == nil { return } op := binExpr.OperatorToken.Kind if op != ast.KindEqualsToken && op != ast.KindAmpersandAmpersandEqualsToken && op != ast.KindBarBarEqualsToken && op != ast.KindQuestionQuestionEqualsToken { return } eachSelfAssignment(binExpr.Left, binExpr.Right, opts.props, func(rightNode *ast.Node) { name := getNodeText(ctx.SourceFile, rightNode) ctx.ReportNode(rightNode, rule.RuleMessage{ Id: "selfAssignment", Description: "'" + name + "' is assigned to itself.", }) }) }, } }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.