github.com/chenfeining/golangci-lint@v1.0.2-0.20230730162517-14c6c67868df/pkg/config/linters_settings.go (about)

     1  package config
     2  
     3  import (
     4  	"encoding"
     5  	"errors"
     6  	"runtime"
     7  
     8  	"gopkg.in/yaml.v3"
     9  )
    10  
    11  var defaultLintersSettings = LintersSettings{
    12  	Asasalint: AsasalintSettings{
    13  		UseBuiltinExclusions: true,
    14  	},
    15  	Decorder: DecorderSettings{
    16  		DecOrder:                  []string{"type", "const", "var", "func"},
    17  		DisableDecNumCheck:        true,
    18  		DisableDecOrderCheck:      true,
    19  		DisableInitFuncFirstCheck: true,
    20  	},
    21  	Dogsled: DogsledSettings{
    22  		MaxBlankIdentifiers: 2,
    23  	},
    24  	ErrorLint: ErrorLintSettings{
    25  		Errorf:      true,
    26  		ErrorfMulti: true,
    27  		Asserts:     true,
    28  		Comparison:  true,
    29  	},
    30  	Exhaustive: ExhaustiveSettings{
    31  		Check:                      []string{"switch"},
    32  		CheckGenerated:             false,
    33  		DefaultSignifiesExhaustive: false,
    34  		IgnoreEnumMembers:          "",
    35  		PackageScopeOnly:           false,
    36  		ExplicitExhaustiveMap:      false,
    37  		ExplicitExhaustiveSwitch:   false,
    38  	},
    39  	Forbidigo: ForbidigoSettings{
    40  		ExcludeGodocExamples: true,
    41  	},
    42  	Gci: GciSettings{
    43  		Sections:      []string{"standard", "default"},
    44  		SkipGenerated: true,
    45  	},
    46  	Gocognit: GocognitSettings{
    47  		MinComplexity: 30,
    48  	},
    49  	Gocritic: GoCriticSettings{
    50  		SettingsPerCheck: map[string]GoCriticCheckSettings{},
    51  	},
    52  	Godox: GodoxSettings{
    53  		Keywords: []string{},
    54  	},
    55  	Godot: GodotSettings{
    56  		Scope:  "declarations",
    57  		Period: true,
    58  	},
    59  	Gofumpt: GofumptSettings{
    60  		LangVersion: "",
    61  		ModulePath:  "",
    62  		ExtraRules:  false,
    63  	},
    64  	Gosec: GoSecSettings{
    65  		Concurrency: runtime.NumCPU(),
    66  	},
    67  	Gosmopolitan: GosmopolitanSettings{
    68  		AllowTimeLocal:  false,
    69  		EscapeHatches:   []string{},
    70  		IgnoreTests:     true,
    71  		WatchForScripts: []string{"Han"},
    72  	},
    73  	Ifshort: IfshortSettings{
    74  		MaxDeclLines: 1,
    75  		MaxDeclChars: 30,
    76  	},
    77  	InterfaceBloat: InterfaceBloatSettings{
    78  		Max: 10,
    79  	},
    80  	Lll: LllSettings{
    81  		LineLength: 120,
    82  		TabWidth:   1,
    83  	},
    84  	LoggerCheck: LoggerCheckSettings{
    85  		Kitlog:           true,
    86  		Klog:             true,
    87  		Logr:             true,
    88  		Zap:              true,
    89  		RequireStringKey: false,
    90  		NoPrintfLike:     false,
    91  		Rules:            nil,
    92  	},
    93  	MaintIdx: MaintIdxSettings{
    94  		Under: 20,
    95  	},
    96  	Nakedret: NakedretSettings{
    97  		MaxFuncLines: 30,
    98  	},
    99  	Nestif: NestifSettings{
   100  		MinComplexity: 5,
   101  	},
   102  	NoLintLint: NoLintLintSettings{
   103  		RequireExplanation: false,
   104  		RequireSpecific:    false,
   105  		AllowUnused:        false,
   106  	},
   107  	Prealloc: PreallocSettings{
   108  		Simple:     true,
   109  		RangeLoops: true,
   110  		ForLoops:   false,
   111  	},
   112  	Predeclared: PredeclaredSettings{
   113  		Ignore:    "",
   114  		Qualified: false,
   115  	},
   116  	TagAlign: TagAlignSettings{
   117  		Align: true,
   118  		Sort:  true,
   119  		Order: nil,
   120  	},
   121  	Testpackage: TestpackageSettings{
   122  		SkipRegexp:    `(export|internal)_test\.go`,
   123  		AllowPackages: []string{"main"},
   124  	},
   125  	Unparam: UnparamSettings{
   126  		Algo: "cha",
   127  	},
   128  	UseStdlibVars: UseStdlibVarsSettings{
   129  		HTTPMethod:     true,
   130  		HTTPStatusCode: true,
   131  	},
   132  	Varnamelen: VarnamelenSettings{
   133  		MaxDistance:   5,
   134  		MinNameLength: 3,
   135  	},
   136  	WSL: WSLSettings{
   137  		StrictAppend:                     true,
   138  		AllowAssignAndCallCuddle:         true,
   139  		AllowAssignAndAnythingCuddle:     false,
   140  		AllowMultiLineAssignCuddle:       true,
   141  		ForceCaseTrailingWhitespaceLimit: 0,
   142  		AllowTrailingComment:             false,
   143  		AllowSeparatedLeadingComment:     false,
   144  		AllowCuddleDeclaration:           false,
   145  		AllowCuddleWithCalls:             []string{"Lock", "RLock"},
   146  		AllowCuddleWithRHS:               []string{"Unlock", "RUnlock"},
   147  		ForceCuddleErrCheckAndAssign:     false,
   148  		ErrorVariableNames:               []string{"err"},
   149  		ForceExclusiveShortDeclarations:  false,
   150  	},
   151  }
   152  
   153  type LintersSettings struct {
   154  	Asasalint        AsasalintSettings
   155  	BiDiChk          BiDiChkSettings
   156  	Cyclop           Cyclop
   157  	Decorder         DecorderSettings
   158  	Depguard         DepGuardSettings
   159  	Dogsled          DogsledSettings
   160  	Dupl             DuplSettings
   161  	DupWord          DupWordSettings
   162  	Errcheck         ErrcheckSettings
   163  	ErrChkJSON       ErrChkJSONSettings
   164  	ErrorLint        ErrorLintSettings
   165  	Exhaustive       ExhaustiveSettings
   166  	ExhaustiveStruct ExhaustiveStructSettings
   167  	Exhaustruct      ExhaustructSettings
   168  	Forbidigo        ForbidigoSettings
   169  	Funlen           FunlenSettings
   170  	Gci              GciSettings
   171  	GinkgoLinter     GinkgoLinterSettings
   172  	Gocognit         GocognitSettings
   173  	Goconst          GoConstSettings
   174  	Gocritic         GoCriticSettings
   175  	Gocyclo          GoCycloSettings
   176  	Godot            GodotSettings
   177  	Godox            GodoxSettings
   178  	Gofmt            GoFmtSettings
   179  	Gofumpt          GofumptSettings
   180  	Goheader         GoHeaderSettings
   181  	Goimports        GoImportsSettings
   182  	Golint           GoLintSettings
   183  	Gomnd            GoMndSettings
   184  	GoModDirectives  GoModDirectivesSettings
   185  	Gomodguard       GoModGuardSettings
   186  	Gosec            GoSecSettings
   187  	Gosimple         StaticCheckSettings
   188  	Gosmopolitan     GosmopolitanSettings
   189  	Govet            GovetSettings
   190  	Grouper          GrouperSettings
   191  	Ifshort          IfshortSettings
   192  	ImportAs         ImportAsSettings
   193  	InterfaceBloat   InterfaceBloatSettings
   194  	Ireturn          IreturnSettings
   195  	Lll              LllSettings
   196  	LoggerCheck      LoggerCheckSettings
   197  	MaintIdx         MaintIdxSettings
   198  	Makezero         MakezeroSettings
   199  	Maligned         MalignedSettings
   200  	Misspell         MisspellSettings
   201  	MustTag          MustTagSettings
   202  	Nakedret         NakedretSettings
   203  	Nestif           NestifSettings
   204  	NilNil           NilNilSettings
   205  	Nlreturn         NlreturnSettings
   206  	NoLintLint       NoLintLintSettings
   207  	NoNamedReturns   NoNamedReturnsSettings
   208  	ParallelTest     ParallelTestSettings
   209  	Prealloc         PreallocSettings
   210  	Predeclared      PredeclaredSettings
   211  	Promlinter       PromlinterSettings
   212  	Reassign         ReassignSettings
   213  	Revive           ReviveSettings
   214  	RowsErrCheck     RowsErrCheckSettings
   215  	Staticcheck      StaticCheckSettings
   216  	Structcheck      StructCheckSettings
   217  	Stylecheck       StaticCheckSettings
   218  	TagAlign         TagAlignSettings
   219  	Tagliatelle      TagliatelleSettings
   220  	Tenv             TenvSettings
   221  	Testpackage      TestpackageSettings
   222  	Thelper          ThelperSettings
   223  	Unparam          UnparamSettings
   224  	UseStdlibVars    UseStdlibVarsSettings
   225  	Varcheck         VarCheckSettings
   226  	Varnamelen       VarnamelenSettings
   227  	Whitespace       WhitespaceSettings
   228  	Wrapcheck        WrapcheckSettings
   229  	WSL              WSLSettings
   230  
   231  	Custom map[string]CustomLinterSettings
   232  }
   233  
   234  type AsasalintSettings struct {
   235  	Exclude              []string `mapstructure:"exclude"`
   236  	UseBuiltinExclusions bool     `mapstructure:"use-builtin-exclusions"`
   237  	IgnoreTest           bool     `mapstructure:"ignore-test"`
   238  }
   239  
   240  type BiDiChkSettings struct {
   241  	LeftToRightEmbedding     bool `mapstructure:"left-to-right-embedding"`
   242  	RightToLeftEmbedding     bool `mapstructure:"right-to-left-embedding"`
   243  	PopDirectionalFormatting bool `mapstructure:"pop-directional-formatting"`
   244  	LeftToRightOverride      bool `mapstructure:"left-to-right-override"`
   245  	RightToLeftOverride      bool `mapstructure:"right-to-left-override"`
   246  	LeftToRightIsolate       bool `mapstructure:"left-to-right-isolate"`
   247  	RightToLeftIsolate       bool `mapstructure:"right-to-left-isolate"`
   248  	FirstStrongIsolate       bool `mapstructure:"first-strong-isolate"`
   249  	PopDirectionalIsolate    bool `mapstructure:"pop-directional-isolate"`
   250  }
   251  
   252  type Cyclop struct {
   253  	MaxComplexity  int     `mapstructure:"max-complexity"`
   254  	PackageAverage float64 `mapstructure:"package-average"`
   255  	SkipTests      bool    `mapstructure:"skip-tests"`
   256  }
   257  
   258  type DepGuardSettings struct {
   259  	Rules map[string]*DepGuardList `mapstructure:"rules"`
   260  }
   261  
   262  type DepGuardList struct {
   263  	Files []string       `mapstructure:"files"`
   264  	Allow []string       `mapstructure:"allow"`
   265  	Deny  []DepGuardDeny `mapstructure:"deny"`
   266  }
   267  
   268  type DepGuardDeny struct {
   269  	Pkg  string `mapstructure:"pkg"`
   270  	Desc string `mapstructure:"desc"`
   271  }
   272  
   273  type DecorderSettings struct {
   274  	DecOrder                  []string `mapstructure:"dec-order"`
   275  	IgnoreUnderscoreVars      bool     `mapstructure:"ignore-underscore-vars"`
   276  	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"`
   280  	DisableDecOrderCheck      bool     `mapstructure:"disable-dec-order-check"`
   281  	DisableInitFuncFirstCheck bool     `mapstructure:"disable-init-func-first-check"`
   282  }
   283  
   284  type DogsledSettings struct {
   285  	MaxBlankIdentifiers int `mapstructure:"max-blank-identifiers"`
   286  }
   287  
   288  type DuplSettings struct {
   289  	Threshold int
   290  }
   291  
   292  type DupWordSettings struct {
   293  	Keywords []string `mapstructure:"keywords"`
   294  }
   295  
   296  type ErrcheckSettings struct {
   297  	DisableDefaultExclusions bool     `mapstructure:"disable-default-exclusions"`
   298  	CheckTypeAssertions      bool     `mapstructure:"check-type-assertions"`
   299  	CheckAssignToBlank       bool     `mapstructure:"check-blank"`
   300  	Ignore                   string   `mapstructure:"ignore"`
   301  	ExcludeFunctions         []string `mapstructure:"exclude-functions"`
   302  
   303  	// Deprecated: use ExcludeFunctions instead
   304  	Exclude string `mapstructure:"exclude"`
   305  }
   306  
   307  type ErrChkJSONSettings struct {
   308  	CheckErrorFreeEncoding bool `mapstructure:"check-error-free-encoding"`
   309  	ReportNoExported       bool `mapstructure:"report-no-exported"`
   310  }
   311  
   312  type ErrorLintSettings struct {
   313  	Errorf      bool `mapstructure:"errorf"`
   314  	ErrorfMulti bool `mapstructure:"errorf-multi"`
   315  	Asserts     bool `mapstructure:"asserts"`
   316  	Comparison  bool `mapstructure:"comparison"`
   317  }
   318  
   319  type ExhaustiveSettings struct {
   320  	Check                      []string `mapstructure:"check"`
   321  	CheckGenerated             bool     `mapstructure:"check-generated"`
   322  	DefaultSignifiesExhaustive bool     `mapstructure:"default-signifies-exhaustive"`
   323  	IgnoreEnumMembers          string   `mapstructure:"ignore-enum-members"`
   324  	IgnoreEnumTypes            string   `mapstructure:"ignore-enum-types"`
   325  	PackageScopeOnly           bool     `mapstructure:"package-scope-only"`
   326  	ExplicitExhaustiveMap      bool     `mapstructure:"explicit-exhaustive-map"`
   327  	ExplicitExhaustiveSwitch   bool     `mapstructure:"explicit-exhaustive-switch"`
   328  }
   329  
   330  type ExhaustiveStructSettings struct {
   331  	StructPatterns []string `mapstructure:"struct-patterns"`
   332  }
   333  
   334  type ExhaustructSettings struct {
   335  	Include []string `mapstructure:"include"`
   336  	Exclude []string `mapstructure:"exclude"`
   337  }
   338  
   339  type ForbidigoSettings struct {
   340  	Forbid               []ForbidigoPattern `mapstructure:"forbid"`
   341  	ExcludeGodocExamples bool               `mapstructure:"exclude-godoc-examples"`
   342  	AnalyzeTypes         bool               `mapstructure:"analyze-types"`
   343  }
   344  
   345  var _ encoding.TextUnmarshaler = &ForbidigoPattern{}
   346  
   347  // ForbidigoPattern corresponds to forbidigo.pattern and adds mapstructure support.
   348  // The YAML field names must match what forbidigo expects.
   349  type ForbidigoPattern struct {
   350  	// patternString gets populated when the config contains a string as entry in ForbidigoSettings.Forbid[]
   351  	// because ForbidigoPattern implements encoding.TextUnmarshaler
   352  	// and the reader uses the mapstructure.TextUnmarshallerHookFunc as decoder hook.
   353  	//
   354  	// If the entry is a map, then the other fields are set as usual by mapstructure.
   355  	patternString string
   356  
   357  	Pattern string `yaml:"p" mapstructure:"p"`
   358  	Package string `yaml:"pkg,omitempty" mapstructure:"pkg,omitempty"`
   359  	Msg     string `yaml:"msg,omitempty" mapstructure:"msg,omitempty"`
   360  }
   361  
   362  func (p *ForbidigoPattern) UnmarshalText(text []byte) error {
   363  	// Validation happens when instantiating forbidigo.
   364  	p.patternString = string(text)
   365  	return nil
   366  }
   367  
   368  // MarshalString converts the pattern into a string as needed by forbidigo.NewLinter.
   369  //
   370  // MarshalString is intentionally not called MarshalText,
   371  // although it has the same signature
   372  // because implementing encoding.TextMarshaler led to infinite recursion when yaml.Marshal called MarshalText.
   373  func (p *ForbidigoPattern) MarshalString() ([]byte, error) {
   374  	if p.patternString != "" {
   375  		return []byte(p.patternString), nil
   376  	}
   377  
   378  	return yaml.Marshal(p)
   379  }
   380  
   381  type FunlenSettings struct {
   382  	Lines      int
   383  	Statements int
   384  }
   385  
   386  type GciSettings struct {
   387  	LocalPrefixes string   `mapstructure:"local-prefixes"` // Deprecated
   388  	Sections      []string `mapstructure:"sections"`
   389  	SkipGenerated bool     `mapstructure:"skip-generated"`
   390  	CustomOrder   bool     `mapstructure:"custom-order"`
   391  }
   392  
   393  type GinkgoLinterSettings struct {
   394  	SuppressLenAssertion     bool `mapstructure:"suppress-len-assertion"`
   395  	SuppressNilAssertion     bool `mapstructure:"suppress-nil-assertion"`
   396  	SuppressErrAssertion     bool `mapstructure:"suppress-err-assertion"`
   397  	SuppressCompareAssertion bool `mapstructure:"suppress-compare-assertion"`
   398  	SuppressAsyncAssertion   bool `mapstructure:"suppress-async-assertion"`
   399  	SuppressFocusContainer   bool `mapstructure:"suppress-focus-container"`
   400  	AllowHaveLenZero         bool `mapstructure:"allow-havelen-zero"`
   401  }
   402  
   403  type GocognitSettings struct {
   404  	MinComplexity int `mapstructure:"min-complexity"`
   405  }
   406  
   407  type GoConstSettings struct {
   408  	IgnoreTests         bool `mapstructure:"ignore-tests"`
   409  	MatchWithConstants  bool `mapstructure:"match-constant"`
   410  	MinStringLen        int  `mapstructure:"min-len"`
   411  	MinOccurrencesCount int  `mapstructure:"min-occurrences"`
   412  	ParseNumbers        bool `mapstructure:"numbers"`
   413  	NumberMin           int  `mapstructure:"min"`
   414  	NumberMax           int  `mapstructure:"max"`
   415  	IgnoreCalls         bool `mapstructure:"ignore-calls"`
   416  }
   417  
   418  type GoCriticSettings struct {
   419  	Go               string                           `mapstructure:"-"`
   420  	EnabledChecks    []string                         `mapstructure:"enabled-checks"`
   421  	DisabledChecks   []string                         `mapstructure:"disabled-checks"`
   422  	EnabledTags      []string                         `mapstructure:"enabled-tags"`
   423  	DisabledTags     []string                         `mapstructure:"disabled-tags"`
   424  	SettingsPerCheck map[string]GoCriticCheckSettings `mapstructure:"settings"`
   425  }
   426  
   427  type GoCriticCheckSettings map[string]any
   428  
   429  type GoCycloSettings struct {
   430  	MinComplexity int `mapstructure:"min-complexity"`
   431  }
   432  
   433  type GodotSettings struct {
   434  	Scope   string   `mapstructure:"scope"`
   435  	Exclude []string `mapstructure:"exclude"`
   436  	Capital bool     `mapstructure:"capital"`
   437  	Period  bool     `mapstructure:"period"`
   438  
   439  	// Deprecated: use `Scope` instead
   440  	CheckAll bool `mapstructure:"check-all"`
   441  }
   442  
   443  type GodoxSettings struct {
   444  	Keywords []string
   445  }
   446  
   447  type GoFmtSettings struct {
   448  	Simplify     bool
   449  	RewriteRules []GoFmtRewriteRule `mapstructure:"rewrite-rules"`
   450  }
   451  
   452  type GoFmtRewriteRule struct {
   453  	Pattern     string
   454  	Replacement string
   455  }
   456  
   457  type GofumptSettings struct {
   458  	ModulePath string `mapstructure:"module-path"`
   459  	ExtraRules bool   `mapstructure:"extra-rules"`
   460  
   461  	// Deprecated: use the global `run.go` instead.
   462  	LangVersion string `mapstructure:"lang-version"`
   463  }
   464  
   465  type GoHeaderSettings struct {
   466  	Values       map[string]map[string]string `mapstructure:"values"`
   467  	Template     string                       `mapstructure:"template"`
   468  	TemplatePath string                       `mapstructure:"template-path"`
   469  }
   470  
   471  type GoImportsSettings struct {
   472  	LocalPrefixes string `mapstructure:"local-prefixes"`
   473  }
   474  
   475  type GoLintSettings struct {
   476  	MinConfidence float64 `mapstructure:"min-confidence"`
   477  }
   478  
   479  type GoMndSettings struct {
   480  	Settings         map[string]map[string]any // Deprecated
   481  	Checks           []string                  `mapstructure:"checks"`
   482  	IgnoredNumbers   []string                  `mapstructure:"ignored-numbers"`
   483  	IgnoredFiles     []string                  `mapstructure:"ignored-files"`
   484  	IgnoredFunctions []string                  `mapstructure:"ignored-functions"`
   485  }
   486  
   487  type GoModDirectivesSettings struct {
   488  	ReplaceAllowList          []string `mapstructure:"replace-allow-list"`
   489  	ReplaceLocal              bool     `mapstructure:"replace-local"`
   490  	ExcludeForbidden          bool     `mapstructure:"exclude-forbidden"`
   491  	RetractAllowNoExplanation bool     `mapstructure:"retract-allow-no-explanation"`
   492  }
   493  
   494  type GoModGuardSettings struct {
   495  	Allowed struct {
   496  		Modules []string `mapstructure:"modules"`
   497  		Domains []string `mapstructure:"domains"`
   498  	} `mapstructure:"allowed"`
   499  	Blocked struct {
   500  		Modules []map[string]struct {
   501  			Recommendations []string `mapstructure:"recommendations"`
   502  			Reason          string   `mapstructure:"reason"`
   503  		} `mapstructure:"modules"`
   504  		Versions []map[string]struct {
   505  			Version string `mapstructure:"version"`
   506  			Reason  string `mapstructure:"reason"`
   507  		} `mapstructure:"versions"`
   508  		LocalReplaceDirectives bool `mapstructure:"local_replace_directives"`
   509  	} `mapstructure:"blocked"`
   510  }
   511  
   512  type GoSecSettings struct {
   513  	Includes         []string       `mapstructure:"includes"`
   514  	Excludes         []string       `mapstructure:"excludes"`
   515  	Severity         string         `mapstructure:"severity"`
   516  	Confidence       string         `mapstructure:"confidence"`
   517  	ExcludeGenerated bool           `mapstructure:"exclude-generated"`
   518  	Config           map[string]any `mapstructure:"config"`
   519  	Concurrency      int            `mapstructure:"concurrency"`
   520  }
   521  
   522  type GosmopolitanSettings struct {
   523  	AllowTimeLocal  bool     `mapstructure:"allow-time-local"`
   524  	EscapeHatches   []string `mapstructure:"escape-hatches"`
   525  	IgnoreTests     bool     `mapstructure:"ignore-tests"`
   526  	WatchForScripts []string `mapstructure:"watch-for-scripts"`
   527  }
   528  
   529  type GovetSettings struct {
   530  	Go             string `mapstructure:"-"`
   531  	CheckShadowing bool   `mapstructure:"check-shadowing"`
   532  	Settings       map[string]map[string]any
   533  
   534  	Enable     []string
   535  	Disable    []string
   536  	EnableAll  bool `mapstructure:"enable-all"`
   537  	DisableAll bool `mapstructure:"disable-all"`
   538  }
   539  
   540  func (cfg *GovetSettings) Validate() error {
   541  	if cfg.EnableAll && cfg.DisableAll {
   542  		return errors.New("enable-all and disable-all can't be combined")
   543  	}
   544  	if cfg.EnableAll && len(cfg.Enable) != 0 {
   545  		return errors.New("enable-all and enable can't be combined")
   546  	}
   547  	if cfg.DisableAll && len(cfg.Disable) != 0 {
   548  		return errors.New("disable-all and disable can't be combined")
   549  	}
   550  	return nil
   551  }
   552  
   553  type GrouperSettings struct {
   554  	ConstRequireSingleConst   bool `mapstructure:"const-require-single-const"`
   555  	ConstRequireGrouping      bool `mapstructure:"const-require-grouping"`
   556  	ImportRequireSingleImport bool `mapstructure:"import-require-single-import"`
   557  	ImportRequireGrouping     bool `mapstructure:"import-require-grouping"`
   558  	TypeRequireSingleType     bool `mapstructure:"type-require-single-type"`
   559  	TypeRequireGrouping       bool `mapstructure:"type-require-grouping"`
   560  	VarRequireSingleVar       bool `mapstructure:"var-require-single-var"`
   561  	VarRequireGrouping        bool `mapstructure:"var-require-grouping"`
   562  }
   563  
   564  type IfshortSettings struct {
   565  	MaxDeclLines int `mapstructure:"max-decl-lines"`
   566  	MaxDeclChars int `mapstructure:"max-decl-chars"`
   567  }
   568  
   569  type ImportAsSettings struct {
   570  	Alias          []ImportAsAlias
   571  	NoUnaliased    bool `mapstructure:"no-unaliased"`
   572  	NoExtraAliases bool `mapstructure:"no-extra-aliases"`
   573  }
   574  
   575  type ImportAsAlias struct {
   576  	Pkg   string
   577  	Alias string
   578  }
   579  
   580  type InterfaceBloatSettings struct {
   581  	Max int `mapstructure:"max"`
   582  }
   583  
   584  type IreturnSettings struct {
   585  	Allow  []string `mapstructure:"allow"`
   586  	Reject []string `mapstructure:"reject"`
   587  }
   588  
   589  type LllSettings struct {
   590  	LineLength int `mapstructure:"line-length"`
   591  	TabWidth   int `mapstructure:"tab-width"`
   592  }
   593  
   594  type LoggerCheckSettings struct {
   595  	Kitlog           bool     `mapstructure:"kitlog"`
   596  	Klog             bool     `mapstructure:"klog"`
   597  	Logr             bool     `mapstructure:"logr"`
   598  	Zap              bool     `mapstructure:"zap"`
   599  	RequireStringKey bool     `mapstructure:"require-string-key"`
   600  	NoPrintfLike     bool     `mapstructure:"no-printf-like"`
   601  	Rules            []string `mapstructure:"rules"`
   602  }
   603  
   604  type MaintIdxSettings struct {
   605  	Under int `mapstructure:"under"`
   606  }
   607  
   608  type MakezeroSettings struct {
   609  	Always bool
   610  }
   611  
   612  type MalignedSettings struct {
   613  	SuggestNewOrder bool `mapstructure:"suggest-new"`
   614  }
   615  
   616  type MisspellSettings struct {
   617  	Locale string
   618  	// TODO(ldez): v2 the options must be renamed to `IgnoredRules`.
   619  	IgnoreWords []string `mapstructure:"ignore-words"`
   620  }
   621  
   622  type MustTagSettings struct {
   623  	Functions []struct {
   624  		Name   string `mapstructure:"name"`
   625  		Tag    string `mapstructure:"tag"`
   626  		ArgPos int    `mapstructure:"arg-pos"`
   627  	} `mapstructure:"functions"`
   628  }
   629  
   630  type NakedretSettings struct {
   631  	MaxFuncLines int `mapstructure:"max-func-lines"`
   632  }
   633  
   634  type NestifSettings struct {
   635  	MinComplexity int `mapstructure:"min-complexity"`
   636  }
   637  
   638  type NilNilSettings struct {
   639  	CheckedTypes []string `mapstructure:"checked-types"`
   640  }
   641  
   642  type NlreturnSettings struct {
   643  	BlockSize int `mapstructure:"block-size"`
   644  }
   645  
   646  type NoLintLintSettings struct {
   647  	RequireExplanation bool     `mapstructure:"require-explanation"`
   648  	RequireSpecific    bool     `mapstructure:"require-specific"`
   649  	AllowNoExplanation []string `mapstructure:"allow-no-explanation"`
   650  	AllowUnused        bool     `mapstructure:"allow-unused"`
   651  }
   652  
   653  type NoNamedReturnsSettings struct {
   654  	ReportErrorInDefer bool `mapstructure:"report-error-in-defer"`
   655  }
   656  type ParallelTestSettings struct {
   657  	IgnoreMissing bool `mapstructure:"ignore-missing"`
   658  }
   659  
   660  type PreallocSettings struct {
   661  	Simple     bool
   662  	RangeLoops bool `mapstructure:"range-loops"`
   663  	ForLoops   bool `mapstructure:"for-loops"`
   664  }
   665  
   666  type PredeclaredSettings struct {
   667  	Ignore    string `mapstructure:"ignore"`
   668  	Qualified bool   `mapstructure:"q"`
   669  }
   670  
   671  type PromlinterSettings struct {
   672  	Strict          bool     `mapstructure:"strict"`
   673  	DisabledLinters []string `mapstructure:"disabled-linters"`
   674  }
   675  
   676  type ReassignSettings struct {
   677  	Patterns []string `mapstructure:"patterns"`
   678  }
   679  
   680  type ReviveSettings struct {
   681  	MaxOpenFiles          int  `mapstructure:"max-open-files"`
   682  	IgnoreGeneratedHeader bool `mapstructure:"ignore-generated-header"`
   683  	Confidence            float64
   684  	Severity              string
   685  	EnableAllRules        bool `mapstructure:"enable-all-rules"`
   686  	Rules                 []struct {
   687  		Name      string
   688  		Arguments []any
   689  		Severity  string
   690  		Disabled  bool
   691  	}
   692  	ErrorCode   int `mapstructure:"error-code"`
   693  	WarningCode int `mapstructure:"warning-code"`
   694  	Directives  []struct {
   695  		Name     string
   696  		Severity string
   697  	}
   698  }
   699  
   700  type RowsErrCheckSettings struct {
   701  	Packages []string
   702  }
   703  
   704  type StaticCheckSettings struct {
   705  	// Deprecated: use the global `run.go` instead.
   706  	GoVersion string `mapstructure:"go"`
   707  
   708  	Checks                  []string `mapstructure:"checks"`
   709  	Initialisms             []string `mapstructure:"initialisms"`                // only for stylecheck
   710  	DotImportWhitelist      []string `mapstructure:"dot-import-whitelist"`       // only for stylecheck
   711  	HTTPStatusCodeWhitelist []string `mapstructure:"http-status-code-whitelist"` // only for stylecheck
   712  }
   713  
   714  func (s *StaticCheckSettings) HasConfiguration() bool {
   715  	return len(s.Initialisms) > 0 || len(s.HTTPStatusCodeWhitelist) > 0 || len(s.DotImportWhitelist) > 0 || len(s.Checks) > 0
   716  }
   717  
   718  type StructCheckSettings struct {
   719  	CheckExportedFields bool `mapstructure:"exported-fields"`
   720  }
   721  
   722  type TagAlignSettings struct {
   723  	Align bool     `mapstructure:"align"`
   724  	Sort  bool     `mapstructure:"sort"`
   725  	Order []string `mapstructure:"order"`
   726  }
   727  
   728  type TagliatelleSettings struct {
   729  	Case struct {
   730  		Rules        map[string]string
   731  		UseFieldName bool `mapstructure:"use-field-name"`
   732  	}
   733  }
   734  
   735  type TestpackageSettings struct {
   736  	SkipRegexp    string   `mapstructure:"skip-regexp"`
   737  	AllowPackages []string `mapstructure:"allow-packages"`
   738  }
   739  
   740  type ThelperSettings struct {
   741  	Test      ThelperOptions `mapstructure:"test"`
   742  	Fuzz      ThelperOptions `mapstructure:"fuzz"`
   743  	Benchmark ThelperOptions `mapstructure:"benchmark"`
   744  	TB        ThelperOptions `mapstructure:"tb"`
   745  }
   746  
   747  type ThelperOptions struct {
   748  	First *bool `mapstructure:"first"`
   749  	Name  *bool `mapstructure:"name"`
   750  	Begin *bool `mapstructure:"begin"`
   751  }
   752  
   753  type TenvSettings struct {
   754  	All bool `mapstructure:"all"`
   755  }
   756  
   757  type UseStdlibVarsSettings struct {
   758  	HTTPMethod         bool `mapstructure:"http-method"`
   759  	HTTPStatusCode     bool `mapstructure:"http-status-code"`
   760  	TimeWeekday        bool `mapstructure:"time-weekday"`
   761  	TimeMonth          bool `mapstructure:"time-month"`
   762  	TimeLayout         bool `mapstructure:"time-layout"`
   763  	CryptoHash         bool `mapstructure:"crypto-hash"`
   764  	DefaultRPCPath     bool `mapstructure:"default-rpc-path"`
   765  	OSDevNull          bool `mapstructure:"os-dev-null"`
   766  	SQLIsolationLevel  bool `mapstructure:"sql-isolation-level"`
   767  	TLSSignatureScheme bool `mapstructure:"tls-signature-scheme"`
   768  	ConstantKind       bool `mapstructure:"constant-kind"`
   769  	SyslogPriority     bool `mapstructure:"syslog-priority"`
   770  }
   771  
   772  type UnparamSettings struct {
   773  	CheckExported bool `mapstructure:"check-exported"`
   774  	Algo          string
   775  }
   776  
   777  type VarCheckSettings struct {
   778  	CheckExportedFields bool `mapstructure:"exported-fields"`
   779  }
   780  
   781  type VarnamelenSettings struct {
   782  	MaxDistance        int      `mapstructure:"max-distance"`
   783  	MinNameLength      int      `mapstructure:"min-name-length"`
   784  	CheckReceiver      bool     `mapstructure:"check-receiver"`
   785  	CheckReturn        bool     `mapstructure:"check-return"`
   786  	CheckTypeParam     bool     `mapstructure:"check-type-param"`
   787  	IgnoreNames        []string `mapstructure:"ignore-names"`
   788  	IgnoreTypeAssertOk bool     `mapstructure:"ignore-type-assert-ok"`
   789  	IgnoreMapIndexOk   bool     `mapstructure:"ignore-map-index-ok"`
   790  	IgnoreChanRecvOk   bool     `mapstructure:"ignore-chan-recv-ok"`
   791  	IgnoreDecls        []string `mapstructure:"ignore-decls"`
   792  }
   793  
   794  type WhitespaceSettings struct {
   795  	MultiIf   bool `mapstructure:"multi-if"`
   796  	MultiFunc bool `mapstructure:"multi-func"`
   797  }
   798  
   799  type WrapcheckSettings struct {
   800  	// TODO(ldez): v2 the options must be renamed to use hyphen.
   801  	IgnoreSigs             []string `mapstructure:"ignoreSigs"`
   802  	IgnoreSigRegexps       []string `mapstructure:"ignoreSigRegexps"`
   803  	IgnorePackageGlobs     []string `mapstructure:"ignorePackageGlobs"`
   804  	IgnoreInterfaceRegexps []string `mapstructure:"ignoreInterfaceRegexps"`
   805  }
   806  
   807  type WSLSettings struct {
   808  	StrictAppend                     bool     `mapstructure:"strict-append"`
   809  	AllowAssignAndCallCuddle         bool     `mapstructure:"allow-assign-and-call"`
   810  	AllowAssignAndAnythingCuddle     bool     `mapstructure:"allow-assign-and-anything"`
   811  	AllowMultiLineAssignCuddle       bool     `mapstructure:"allow-multiline-assign"`
   812  	ForceCaseTrailingWhitespaceLimit int      `mapstructure:"force-case-trailing-whitespace"`
   813  	AllowTrailingComment             bool     `mapstructure:"allow-trailing-comment"`
   814  	AllowSeparatedLeadingComment     bool     `mapstructure:"allow-separated-leading-comment"`
   815  	AllowCuddleDeclaration           bool     `mapstructure:"allow-cuddle-declarations"`
   816  	AllowCuddleWithCalls             []string `mapstructure:"allow-cuddle-with-calls"`
   817  	AllowCuddleWithRHS               []string `mapstructure:"allow-cuddle-with-rhs"`
   818  	ForceCuddleErrCheckAndAssign     bool     `mapstructure:"force-err-cuddling"`
   819  	ErrorVariableNames               []string `mapstructure:"error-variable-names"`
   820  	ForceExclusiveShortDeclarations  bool     `mapstructure:"force-short-decl-cuddling"`
   821  }
   822  
   823  // CustomLinterSettings encapsulates the meta-data of a private linter.
   824  // For example, a private linter may be added to the golangci config file as shown below.
   825  //
   826  //	linters-settings:
   827  //	 custom:
   828  //	   example:
   829  //	     path: /example.so
   830  //	     description: The description of the linter
   831  //	     original-url: github.com/golangci/example-linter
   832  type CustomLinterSettings struct {
   833  	// Path to a plugin *.so file that implements the private linter.
   834  	Path string
   835  	// Description describes the purpose of the private linter.
   836  	Description string
   837  	// OriginalURL The URL containing the source code for the private linter.
   838  	OriginalURL string `mapstructure:"original-url"`
   839  
   840  	// Settings plugin settings only work with linterdb.PluginConstructor symbol.
   841  	Settings any
   842  }