File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -485,6 +485,10 @@ var defaultLintersSettings = LintersSettings{
485485 ErrorLint : ErrorLintSettings {
486486 Errorf : true ,
487487 },
488+ Ifshort : IfshortSettings {
489+ MaxDeclLines : 1 ,
490+ MaxDeclChars : 30 ,
491+ },
488492 Predeclared : PredeclaredSettings {
489493 Ignore : "" ,
490494 Qualified : false ,
Original file line number Diff line number Diff line change @@ -4,14 +4,25 @@ import (
44 "github.com/esimonov/ifshort/pkg/analyzer"
55 "golang.org/x/tools/go/analysis"
66
7+ "github.com/golangci/golangci-lint/pkg/config"
78 "github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
89)
910
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+
1122 return goanalysis .NewLinter (
1223 "ifshort" ,
1324 "Checks that your code uses short syntax for if-statements whenever possible" ,
1425 []* analysis.Analyzer {analyzer .Analyzer },
15- nil ,
26+ cfg ,
1627 ).WithLoadMode (goanalysis .LoadModeSyntax )
1728}
Original file line number Diff line number Diff line change @@ -95,13 +95,15 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
9595 var errorlintCfg * config.ErrorLintSettings
9696 var thelperCfg * config.ThelperSettings
9797 var predeclaredCfg * config.PredeclaredSettings
98+ var ifshortCfg * config.IfshortSettings
9899 if m .cfg != nil {
99100 govetCfg = & m .cfg .LintersSettings .Govet
100101 testpackageCfg = & m .cfg .LintersSettings .Testpackage
101102 exhaustiveCfg = & m .cfg .LintersSettings .Exhaustive
102103 errorlintCfg = & m .cfg .LintersSettings .ErrorLint
103104 thelperCfg = & m .cfg .LintersSettings .Thelper
104105 predeclaredCfg = & m .cfg .LintersSettings .Predeclared
106+ ifshortCfg = & m .cfg .LintersSettings .Ifshort
105107 }
106108 const megacheckName = "megacheck"
107109 lcs := []* linter.Config {
@@ -344,7 +346,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
344346 linter .NewConfig (golinters .NewForbidigo ()).
345347 WithPresets (linter .PresetStyle ).
346348 WithURL ("https://github.com/ashanbrown/forbidigo" ),
347- linter .NewConfig (golinters .NewIfshort ()).
349+ linter .NewConfig (golinters .NewIfshort (ifshortCfg )).
348350 WithPresets (linter .PresetStyle ).
349351 WithURL ("https://github.com/esimonov/ifshort" ),
350352 linter .NewConfig (golinters .NewPredeclared (predeclaredCfg )).
You can’t perform that action at this time.
0 commit comments