diff --git a/rule/function_result_limit.go b/rule/function_result_limit.go index 1b102dd3d..953f33bab 100644 --- a/rule/function_result_limit.go +++ b/rule/function_result_limit.go @@ -15,25 +15,6 @@ type FunctionResultsLimitRule struct { configureOnce sync.Once } -const defaultResultsLimit = 3 - -func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) { - if len(arguments) < 1 { - r.max = defaultResultsLimit - return - } - - maxResults, ok := arguments[0].(int64) // Alt. non panicking version - if !ok { - panic(fmt.Sprintf(`invalid value passed as return results number to the "function-result-limit" rule; need int64 but got %T`, arguments[0])) - } - if maxResults < 0 { - panic(`the value passed as return results number to the "function-result-limit" rule cannot be negative`) - } - - r.max = int(maxResults) -} - // Apply applies the rule to given file. func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure { r.configureOnce.Do(func() { r.configure(arguments) }) @@ -67,3 +48,22 @@ func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Argumen func (*FunctionResultsLimitRule) Name() string { return "function-result-limit" } + +const defaultResultsLimit = 3 + +func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) { + if len(arguments) < 1 { + r.max = defaultResultsLimit + return + } + + maxResults, ok := arguments[0].(int64) // Alt. non panicking version + if !ok { + panic(fmt.Sprintf(`invalid value passed as return results number to the "function-result-limit" rule; need int64 but got %T`, arguments[0])) + } + if maxResults < 0 { + panic(`the value passed as return results number to the "function-result-limit" rule cannot be negative`) + } + + r.max = int(maxResults) +}