golangci/golangci-lint · error
tag %q disabled and enabled at one moment
Error message
tag %q disabled and enabled at one moment
What it means
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.
Source
Thrown at pkg/golinters/gocritic/gocritic_settings.go:377
for check := range s.SettingsPerCheck {
lcName := strings.ToLower(check)
if !s.allChecksLowerCased.has(lcName) {
return fmt.Errorf("invalid check settings: check %q doesn't exist, see %s documentation", check, linterName)
}
if !s.inferredEnabledChecksLowerCased.has(lcName) {
s.logger.Warnf("%s: settings were provided for disabled check %q", check, linterName)
}
}
return nil
}
func (s *settingsWrapper) validateDisabledAndEnabledAtOneMoment() error {
for _, tag := range s.DisabledTags {
if slices.Contains(s.EnabledTags, tag) {
return fmt.Errorf("tag %q disabled and enabled at one moment", tag)
}
}
for _, check := range s.DisabledChecks {
if slices.Contains(s.EnabledChecks, check) {
return fmt.Errorf("check %q disabled and enabled at one moment", check)
}
}
return nil
}
func (s *settingsWrapper) validateAtLeastOneCheckerEnabled() error {
if len(s.inferredEnabledChecks) == 0 {
return errors.New("eventually all checks were disabled: at least one must be enabled")
}
return nilView on GitHub (pinned to ed7a235d2d)
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
Example fix
// before (.golangci.yml)
settings:
gocritic:
enabled-tags: [style]
disabled-tags: [style]
// after
settings:
gocritic:
enabled-tags: [style] Defensive patterns
Strategy: validation
Validate before calling
const enabled = cfg.settings.gocritic['enabled-tags'] ?? []
const disabled = cfg.settings.gocritic['disabled-tags'] ?? []
const clash = disabled.filter(t => enabled.includes(t))
if (clash.length) throw new Error(`tag(s) both enabled and disabled: ${clash.join(', ')}`) Type guard
const tagsAreDisjoint = (a, b) => !a.some(x => b.includes(x))
Prevention
- 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
When it happens
Trigger: 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.
Common situations: Merging two .golangci.yml files (shared base enables 'style', local config disables 'style'), incremental edits adding an enable without removing the disable.
Related errors
- checker %s config param %s doesn't exist: checker doesn't ha
- checker %s config param %s doesn't exist, all existing: %s
- enabled tag %q doesn't exist, see %s's documentation
- disabled tag %q doesn't exist, see %s's documentation
- enabled check %q doesn't exist, see %s's documentation
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/6105ff7c8616eaa0.
Report an issue: GitHub.