mirror of
https://github.com/mgechev/revive.git
synced 2025-07-17 01:12:27 +02:00
Fix/677 (#678)
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user