1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00

Check max value and add more information about what the rule received as argument.

This commit is contained in:
xuri 2018-09-17 20:17:21 +08:00
parent dd1a8bf4e6
commit f02afab00f
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

View File

@ -18,7 +18,10 @@ func (r *FunctionResultsLimitRule) Apply(file *lint.File, arguments lint.Argumen
max, ok := arguments[0].(int64) // Alt. non panicking version
if !ok {
panic(`invalid value passed as return results number to the "function-result-limit" rule`)
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 {
panic(`the value passed as return results number to the "function-result-limit" rule cannot be negative`)
}
var failures []lint.Failure