Skip to content

Commit

Permalink
removes redefinition of max built-in (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavacava authored Sep 29, 2024
1 parent e9b7f3a commit fa37c00
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions rule/function-result-limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ func (r *FunctionResultsLimitRule) configure(arguments lint.Arguments) {
r.max = defaultResultsLimit
return
}
max, ok := arguments[0].(int64) // Alt. non panicking version
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 max < 0 {
if maxResults < 0 {
panic(`the value passed as return results number to the "function-result-limit" rule cannot be negative`)
}
r.max = int(max)
r.max = int(maxResults)
}
}

Expand Down
6 changes: 3 additions & 3 deletions rule/line-length-limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (r *LineLengthLimitRule) configure(arguments lint.Arguments) {
return
}

max, ok := arguments[0].(int64) // Alt. non panicking version
if !ok || max < 0 {
maxLength, ok := arguments[0].(int64) // Alt. non panicking version
if !ok || maxLength < 0 {
panic(`invalid value passed as argument number to the "line-length-limit" rule`)
}

r.max = int(max)
r.max = int(maxLength)
}
}

Expand Down
4 changes: 2 additions & 2 deletions rule/max-control-nesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ func (r *MaxControlNestingRule) configure(arguments lint.Arguments) {

checkNumberOfArguments(1, arguments, r.Name())

max, ok := arguments[0].(int64) // Alt. non panicking version
maxNesting, ok := arguments[0].(int64) // Alt. non panicking version
if !ok {
panic(`invalid value passed as argument number to the "max-control-nesting" rule`)
}
r.max = max
r.max = maxNesting
}
4 changes: 2 additions & 2 deletions rule/max-public-structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func (r *MaxPublicStructsRule) configure(arguments lint.Arguments) {

checkNumberOfArguments(1, arguments, r.Name())

max, ok := arguments[0].(int64) // Alt. non panicking version
maxStructs, ok := arguments[0].(int64) // Alt. non panicking version
if !ok {
panic(`invalid value passed as argument number to the "max-public-structs" rule`)
}
r.max = max
r.max = maxStructs
}
}

Expand Down

0 comments on commit fa37c00

Please sign in to comment.