revive: the default configuration is only applied when no dedicated configuration. (#1831)

This commit is contained in:
Ludovic Fernandez 2021-03-15 12:39:04 +01:00 committed by GitHub
parent e381b33092
commit cd6644d47b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 17 deletions

View file

@ -3,12 +3,10 @@ linters-settings:
ignore-generated-header: true
severity: warning
rules:
- name: indent-error-flow
severity: warning
- name: cognitive-complexity
arguments: [ 7 ]
- name: line-length-limit
arguments: [ 110 ]
arguments: [ 130 ]
- name: function-result-limit
arguments: [ 3 ]
- name: argument-limit

View file

@ -2,12 +2,29 @@
//config_path: testdata/configs/revive.yml
package testdata
import "time"
import (
"net/http"
"time"
)
func testRevive(t *time.Duration) error {
if t == nil {
return nil
} else { // ERROR "indent-error-flow: if block ends with a return statement, .*"
} else {
return nil
}
}
func testReviveComplexity(s string) { // ERROR "cyclomatic: function testReviveComplexity has cyclomatic complexity 22"
if s == http.MethodGet || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
if s == "1" || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
if s == "1" || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
}

29
test/testdata/revive_default.go vendored Normal file
View file

@ -0,0 +1,29 @@
//args: -Erevive
package testdata
import (
"net/http"
"time"
)
func testReviveDefault(t *time.Duration) error {
if t == nil {
return nil
} else { // ERROR "indent-error-flow: if block ends with a return statement, .*"
return nil
}
}
func testReviveComplexityDefault(s string) {
if s == http.MethodGet || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
if s == "1" || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
if s == "1" || s == "2" || s == "3" || s == "4" || s == "5" || s == "6" || s == "7" {
return
}
}