aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mgechev/revive/rule/function-length.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-11-11 11:41:38 +0100
committerTaras Madan <tarasmadan@google.com>2024-11-11 11:10:48 +0000
commit27e76fae2ee2d84dc7db63af1d9ed7358ba35b7a (patch)
treeed19c0e35e272b3c4cc5a2f2c595e035b2428337 /vendor/github.com/mgechev/revive/rule/function-length.go
parent621e84e063b0e15b23e17780338627c509e1b9e8 (diff)
vendor: update
Diffstat (limited to 'vendor/github.com/mgechev/revive/rule/function-length.go')
-rw-r--r--vendor/github.com/mgechev/revive/rule/function-length.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/vendor/github.com/mgechev/revive/rule/function-length.go b/vendor/github.com/mgechev/revive/rule/function-length.go
index fd65884e9..30402313d 100644
--- a/vendor/github.com/mgechev/revive/rule/function-length.go
+++ b/vendor/github.com/mgechev/revive/rule/function-length.go
@@ -20,12 +20,14 @@ type FunctionLength struct {
func (r *FunctionLength) configure(arguments lint.Arguments) {
r.Lock()
defer r.Unlock()
- if !r.configured {
- maxStmt, maxLines := r.parseArguments(arguments)
- r.maxStmt = int(maxStmt)
- r.maxLines = int(maxLines)
- r.configured = true
+ if r.configured {
+ return
}
+
+ r.configured = true
+ maxStmt, maxLines := r.parseArguments(arguments)
+ r.maxStmt = int(maxStmt)
+ r.maxLines = int(maxLines)
}
// Apply applies the rule to given file.
@@ -61,8 +63,9 @@ func (*FunctionLength) parseArguments(arguments lint.Arguments) (maxStmt, maxLin
return defaultFuncStmtsLimit, defaultFuncLinesLimit
}
- if len(arguments) != 2 {
- panic(fmt.Sprintf(`invalid configuration for "function-length" rule, expected 2 arguments but got %d`, len(arguments)))
+ const minArguments = 2
+ if len(arguments) != minArguments {
+ panic(fmt.Sprintf(`invalid configuration for "function-length" rule, expected %d arguments but got %d`, minArguments, len(arguments)))
}
maxStmt, maxStmtOk := arguments[0].(int64)
@@ -98,7 +101,8 @@ func (w lintFuncLength) Visit(n ast.Node) ast.Visitor {
}
body := node.Body
- if body == nil || len(node.Body.List) == 0 {
+ emptyBody := body == nil || len(node.Body.List) == 0
+ if emptyBody {
return nil
}