File tree Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Expand file tree Collapse file tree 5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,10 @@ linters-settings:
158158 - var
159159 - func
160160
161+ # If true, underscore vars (vars with "_" as the name) will be ignored at all checks
162+ # Default: false (underscore vars are not ignored)
163+ ignore-underscore-vars : false
164+
161165 # If true, order of declarations is not checked at all.
162166 # Default: true (disabled)
163167 disable-dec-order-check : false
@@ -170,6 +174,18 @@ linters-settings:
170174 # Default: true (disabled)
171175 disable-dec-num-check : false
172176
177+ # If true, type declarations will be ignored for dec num check
178+ # Default: false (type statements are not ignored)
179+ disable-type-dec-num-check : false
180+
181+ # If true, const declarations will be ignored for dec num check
182+ # Default: false (const statements are not ignored)
183+ disable-const-dec-num-check : false
184+
185+ # If true, var declarations will be ignored for dec num check
186+ # Default: false (var statements are not ignored)
187+ disable-var-dec-num-check : false
188+
173189 depguard :
174190 # Rules to apply.
175191 #
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ require (
114114 github.com/yagipy/maintidx v1.0.0
115115 github.com/yeya24/promlinter v0.2.0
116116 github.com/ykadowak/zerologlint v0.1.3
117- gitlab.com/bosi/decorder v0.2.3
117+ gitlab.com/bosi/decorder v0.4.0
118118 go.tmz.dev/musttag v0.7.1
119119 golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea
120120 golang.org/x/tools v0.11.0
Original file line number Diff line number Diff line change @@ -272,7 +272,11 @@ type DepGuardDeny struct {
272272
273273type DecorderSettings struct {
274274 DecOrder []string `mapstructure:"dec-order"`
275+ IgnoreUnderscoreVars bool `mapstructure:"ignore-underscore-vars"`
275276 DisableDecNumCheck bool `mapstructure:"disable-dec-num-check"`
277+ DisableTypeDecNumCheck bool `mapstructure:"disable-type-dec-num-check"`
278+ DisableConstDecNumCheck bool `mapstructure:"disable-const-dec-num-check"`
279+ DisableVarDecNumCheck bool `mapstructure:"disable-var-dec-num-check"`
276280 DisableDecOrderCheck bool `mapstructure:"disable-dec-order-check"`
277281 DisableInitFuncFirstCheck bool `mapstructure:"disable-init-func-first-check"`
278282}
Original file line number Diff line number Diff line change @@ -15,14 +15,22 @@ func NewDecorder(settings *config.DecorderSettings) *goanalysis.Linter {
1515
1616 // disable all rules/checks by default
1717 cfg := map [string ]any {
18+ "ignore-underscore-vars" : false ,
1819 "disable-dec-num-check" : true ,
20+ "disable-type-dec-num-check" : false ,
21+ "disable-const-dec-num-check" : false ,
22+ "disable-var-dec-num-check" : false ,
1923 "disable-dec-order-check" : true ,
2024 "disable-init-func-first-check" : true ,
2125 }
2226
2327 if settings != nil {
2428 cfg ["dec-order" ] = strings .Join (settings .DecOrder , "," )
29+ cfg ["ignore-underscore-vars" ] = settings .IgnoreUnderscoreVars
2530 cfg ["disable-dec-num-check" ] = settings .DisableDecNumCheck
31+ cfg ["disable-type-dec-num-check" ] = settings .DisableTypeDecNumCheck
32+ cfg ["disable-const-dec-num-check" ] = settings .DisableConstDecNumCheck
33+ cfg ["disable-var-dec-num-check" ] = settings .DisableVarDecNumCheck
2634 cfg ["disable-dec-order-check" ] = settings .DisableDecOrderCheck
2735 cfg ["disable-init-func-first-check" ] = settings .DisableInitFuncFirstCheck
2836 }
You can’t perform that action at this time.
0 commit comments