{"record":{"id":"3a672ef9d9c636d2","repo":"golangci/golangci-lint","slug":"check-q-disabled-and-enabled-at-one-moment","errorCode":null,"errorMessage":"check %q disabled and enabled at one moment","messagePattern":"check %q disabled and enabled at one moment","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/gocritic/gocritic_settings.go","lineNumber":383,"sourceCode":"\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\n}\n\ntype goCriticChecks[T any] map[string]T\n\nfunc (m goCriticChecks[T]) has(name string) bool {\n\t_, ok := m[name]","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/gocritic/gocritic_settings.go#L365-L401","documentation":"Error from gocritic's validateDisabledAndEnabledAtOneMoment: a check name appears in both disabled-checks and enabled-checks in the gocritic settings, which is contradictory. The validation loops over disabled checks and fails when one is also present in the enabled list (a symmetric check exists for tags).","triggerScenarios":"settings.gocritic has the same check name in both enabled-checks and disabled-checks; validateDisabledAndEnabledAtOneMoment uses slices.Contains over EnabledChecks for each DisabledChecks entry.","commonSituations":"Hand-editing configs where a check was first disabled then later enabled without removing the disable entry, CI vs local config overlays applying both directions.","solutions":["Delete the check from disabled-checks if you want it enabled","Delete the check from enabled-checks if you want it disabled","Keep a single source of truth for check enable/disable state in your config"],"exampleFix":"// before (.golangci.yml)\nsettings:\n  gocritic:\n    enabled-checks: [hugeParam]\n    disabled-checks: [hugeParam]\n// after\nsettings:\n  gocritic:\n    enabled-checks: [hugeParam]","handlingStrategy":"validation","validationCode":"const enabled = cfg.settings.gocritic['enabled-checks'] ?? []\nconst disabled = cfg.settings.gocritic['disabled-checks'] ?? []\nconst clash = disabled.filter(c => enabled.includes(c))\nif (clash.length) throw new Error(`check(s) both enabled and disabled: ${clash.join(', ')}`)","typeGuard":"const listsAreDisjoint = (a, b) => !a.some(x => b.includes(x))","tryCatchPattern":null,"preventionTips":["Remove a check from disabled-checks at the same time you add it to enabled-checks","Keep check enable/disable state in one config layer","CI config verification to catch duplicates"],"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"}