{"record":{"id":"6105ff7c8616eaa0","repo":"golangci/golangci-lint","slug":"tag-q-disabled-and-enabled-at-one-moment","errorCode":null,"errorMessage":"tag %q disabled and enabled at one moment","messagePattern":"tag %q disabled and enabled at one moment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/gocritic/gocritic_settings.go","lineNumber":377,"sourceCode":"\tfor check := range s.SettingsPerCheck {\n\t\tlcName := strings.ToLower(check)\n\n\t\tif !s.allChecksLowerCased.has(lcName) {\n\t\t\treturn fmt.Errorf(\"invalid check settings: check %q doesn't exist, see %s documentation\", check, linterName)\n\t\t}\n\n\t\tif !s.inferredEnabledChecksLowerCased.has(lcName) {\n\t\t\ts.logger.Warnf(\"%s: settings were provided for disabled check %q\", check, linterName)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (s *settingsWrapper) validateDisabledAndEnabledAtOneMoment() error {\n\tfor _, tag := range s.DisabledTags {\n\t\tif slices.Contains(s.EnabledTags, tag) {\n\t\t\treturn fmt.Errorf(\"tag %q disabled and enabled at one moment\", tag)\n\t\t}\n\t}\n\n\tfor _, check := range s.DisabledChecks {\n\t\tif slices.Contains(s.EnabledChecks, check) {\n\t\t\treturn fmt.Errorf(\"check %q disabled and enabled at one moment\", check)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (s *settingsWrapper) validateAtLeastOneCheckerEnabled() error {\n\tif len(s.inferredEnabledChecks) == 0 {\n\t\treturn errors.New(\"eventually all checks were disabled: at least one must be enabled\")\n\t}\n\n\treturn nil","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/gocritic/gocritic_settings.go#L359-L395","documentation":"gocritic rejects configurations where the same tag is listed both in enabled-tags and disabled-tags, since the resulting state is ambiguous. validateDisabledAndEnabledAtOneMoment detects the overlap and fails configuration validation.","triggerScenarios":"settings.gocritic has a tag appearing in both disabled-tags and enabled-tags, e.g. after merging config fragments or enabling a tag previously disabled.","commonSituations":"Merging two .golangci.yml files (shared base enables 'style', local config disables 'style'), incremental edits adding an enable without removing the disable.","solutions":["Remove the tag from enabled-tags or disabled-tags so it appears in only one","Decide intent: to re-enable, delete it from disabled-tags; to disable, delete it from enabled-tags","Audit merged configs for duplicate keys before running golangci-lint"],"exampleFix":"// before (.golangci.yml)\nsettings:\n  gocritic:\n    enabled-tags: [style]\n    disabled-tags: [style]\n// after\nsettings:\n  gocritic:\n    enabled-tags: [style]","handlingStrategy":"validation","validationCode":"const enabled = cfg.settings.gocritic['enabled-tags'] ?? []\nconst disabled = cfg.settings.gocritic['disabled-tags'] ?? []\nconst clash = disabled.filter(t => enabled.includes(t))\nif (clash.length) throw new Error(`tag(s) both enabled and disabled: ${clash.join(', ')}`)","typeGuard":"const tagsAreDisjoint = (a, b) => !a.some(x => b.includes(x))","tryCatchPattern":null,"preventionTips":["When merging config overlays, diff enable/disable lists for overlaps","Decide a single place where enable/disable decisions live","Add a pre-commit check asserting disjoint tag lists"],"tags":["golangci-lint","gocritic","configuration"],"backgroundTag":"conflicting-linter-config","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}