1
0
mirror of https://github.com/mgechev/revive.git synced 2025-07-17 01:12:27 +02:00
This commit is contained in:
chavacava
2022-04-10 09:06:59 +02:00
committed by GitHub
parent b9814276b6
commit 31fbdb1833
23 changed files with 275 additions and 119 deletions

View File

@ -3,6 +3,7 @@ package rule
import (
"fmt"
"go/ast"
"sync"
"github.com/mgechev/revive/lint"
)
@ -10,10 +11,11 @@ import (
// FunctionResultsLimitRule lints given else constructs.
type FunctionResultsLimitRule struct {
max int
sync.Mutex
}
// Apply applies the rule to given file.
func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) {
r.Lock()
if r.max == 0 {
checkNumberOfArguments(1, arguments, r.Name())
@ -26,6 +28,12 @@ func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Argumen
}
r.max = int(max)
}
r.Unlock()
}
// Apply applies the rule to given file.
func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
r.configure(arguments)
var failures []lint.Failure