File tree 3 files changed +20
-3
lines changed
3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,10 @@ var defaultLintersSettings = LintersSettings{
485
485
ErrorLint : ErrorLintSettings {
486
486
Errorf : true ,
487
487
},
488
+ Ifshort : IfshortSettings {
489
+ MaxDeclLines : 1 ,
490
+ MaxDeclChars : 30 ,
491
+ },
488
492
Predeclared : PredeclaredSettings {
489
493
Ignore : "" ,
490
494
Qualified : false ,
Original file line number Diff line number Diff line change @@ -4,14 +4,25 @@ import (
4
4
"github.com/esimonov/ifshort/pkg/analyzer"
5
5
"golang.org/x/tools/go/analysis"
6
6
7
+ "github.com/golangci/golangci-lint/pkg/config"
7
8
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
8
9
)
9
10
10
- func NewIfshort () * goanalysis.Linter {
11
+ func NewIfshort (settings * config.IfshortSettings ) * goanalysis.Linter {
12
+ var cfg map [string ]map [string ]interface {}
13
+ if settings != nil {
14
+ cfg = map [string ]map [string ]interface {}{
15
+ analyzer .Analyzer .Name : {
16
+ "max-decl-lines" : settings .MaxDeclLines ,
17
+ "max-decl-chars" : settings .MaxDeclChars ,
18
+ },
19
+ }
20
+ }
21
+
11
22
return goanalysis .NewLinter (
12
23
"ifshort" ,
13
24
"Checks that your code uses short syntax for if-statements whenever possible" ,
14
25
[]* analysis.Analyzer {analyzer .Analyzer },
15
- nil ,
26
+ cfg ,
16
27
).WithLoadMode (goanalysis .LoadModeSyntax )
17
28
}
Original file line number Diff line number Diff line change @@ -95,13 +95,15 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
95
95
var errorlintCfg * config.ErrorLintSettings
96
96
var thelperCfg * config.ThelperSettings
97
97
var predeclaredCfg * config.PredeclaredSettings
98
+ var ifshortCfg * config.IfshortSettings
98
99
if m .cfg != nil {
99
100
govetCfg = & m .cfg .LintersSettings .Govet
100
101
testpackageCfg = & m .cfg .LintersSettings .Testpackage
101
102
exhaustiveCfg = & m .cfg .LintersSettings .Exhaustive
102
103
errorlintCfg = & m .cfg .LintersSettings .ErrorLint
103
104
thelperCfg = & m .cfg .LintersSettings .Thelper
104
105
predeclaredCfg = & m .cfg .LintersSettings .Predeclared
106
+ ifshortCfg = & m .cfg .LintersSettings .Ifshort
105
107
}
106
108
const megacheckName = "megacheck"
107
109
lcs := []* linter.Config {
@@ -344,7 +346,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
344
346
linter .NewConfig (golinters .NewForbidigo ()).
345
347
WithPresets (linter .PresetStyle ).
346
348
WithURL ("https://github.com/ashanbrown/forbidigo" ),
347
- linter .NewConfig (golinters .NewIfshort ()).
349
+ linter .NewConfig (golinters .NewIfshort (ifshortCfg )).
348
350
WithPresets (linter .PresetStyle ).
349
351
WithURL ("https://github.com/esimonov/ifshort" ),
350
352
linter .NewConfig (golinters .NewPredeclared (predeclaredCfg )).
You can’t perform that action at this time.
0 commit comments