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