Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NoSetterReturnRule = rule.Rule{ Name: "no-setter-return", Run: func(ctx rule.RuleContext, options any) rule.RuleListeners { return rule.RuleListeners{ ast.KindReturnStatement: func(node *ast.Node) { ret := node.AsReturnStatement() if ret.Expression == nil { return } enclosing := findEnclosingFunction(node) if enclosing != nil && isSetterFunction(enclosing, ctx) { ctx.ReportNode(node, buildSetterMessage()) } }, ast.KindArrowFunction: func(node *ast.Node) { body := node.Body() if body == nil || body.Kind == ast.KindBlock { return } if isSetterFunction(node, ctx) { ctx.ReportNode(body, buildSetterMessage()) } }, } }, }
NoSetterReturnRule disallows returning a value from a setter. Setters cannot meaningfully return values; any return value is silently ignored. A bare `return;` (without a value) is allowed for control flow.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.