Merge pull request #79 from alecthomas/master
Allow --enable, --enable-all and --fast to coexist.
This commit is contained in:
commit
616bc37d6a
@ -256,7 +256,7 @@ func validateAllDisableEnableOptions(cfg *config.Linters) error {
|
||||
}
|
||||
}
|
||||
|
||||
if cfg.EnableAll && len(cfg.Enable) != 0 {
|
||||
if cfg.EnableAll && len(cfg.Enable) != 0 && !cfg.Fast {
|
||||
return fmt.Errorf("can't combine options --enable-all and --enable %s", cfg.Enable[0])
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,19 @@ func getEnabledByDefaultFastLintersExcept(except ...string) []string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func getAllFastLintersWith(with ...string) []string {
|
||||
linters := lintersdb.GetAllSupportedLinterConfigs()
|
||||
ret := append([]string{}, with...)
|
||||
for _, linter := range linters {
|
||||
if linter.DoesFullImport {
|
||||
continue
|
||||
}
|
||||
ret = append(ret, linter.Linter.Name())
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func getEnabledByDefaultLinters() []string {
|
||||
ebdl := lintersdb.GetAllEnabledByDefaultLinters()
|
||||
ret := []string{}
|
||||
@ -180,6 +193,15 @@ func mergeMegacheck(linters []string) []string {
|
||||
return linters
|
||||
}
|
||||
|
||||
func TestEnableAllFastAndEnableCanCoexist(t *testing.T) {
|
||||
out, exitCode := runGolangciLint(t, "--fast", "--enable-all", "--enable=typecheck")
|
||||
checkNoIssuesRun(t, out, exitCode)
|
||||
|
||||
_, exitCode = runGolangciLint(t, "--enable-all", "--enable=typecheck")
|
||||
assert.Equal(t, 3, exitCode)
|
||||
|
||||
}
|
||||
|
||||
func TestEnabledLinters(t *testing.T) {
|
||||
type tc struct {
|
||||
name string
|
||||
@ -267,6 +289,12 @@ func TestEnabledLinters(t *testing.T) {
|
||||
el: getEnabledByDefaultLinters(),
|
||||
noImplicitFast: true,
|
||||
},
|
||||
{
|
||||
name: "fast option combined with enable and enable-all",
|
||||
args: "--enable-all --fast --enable=typecheck",
|
||||
el: getAllFastLintersWith("typecheck"),
|
||||
noImplicitFast: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
|
Loading…
x
Reference in New Issue
Block a user