golangci/golangci-lint · error
a rule cannot be enabled and disabled at the same time: '%s'
Error message
a rule cannot be enabled and disabled at the same time: '%s'
What it means
godoclint's settings check rejects rules that appear in both settings.Enable and settings.Disable (outside the special enable/disable/default modes). Since configuration is validated at linter construction (New), golangci-lint fails before analysis.
Source
Thrown at pkg/golinters/godoclint/godoclint.go:96
WithLoadMode(goanalysis.LoadModeSyntax)
}
func checkSettings(settings *config.GodoclintSettings) error {
switch deref(settings.Default) {
case string(model.DefaultSetAll):
if len(settings.Enable) > 0 {
return errors.New("cannot use 'enable' with 'default=all'")
}
case string(model.DefaultSetNone):
if len(settings.Disable) > 0 {
return errors.New("cannot use 'disable' with 'default=none'")
}
default:
for _, rule := range settings.Enable {
if slices.Contains(settings.Disable, rule) {
return fmt.Errorf("a rule cannot be enabled and disabled at the same time: '%s'", rule)
}
}
for _, rule := range settings.Disable {
if slices.Contains(settings.Enable, rule) {
return fmt.Errorf("a rule cannot be enabled and disabled at the same time: '%s'", rule)
}
}
}
return nil
}
func deref[T any](v *T) T {
if v == nil {
var zero T
return zero
}View on GitHub (pinned to ed7a235d2d)
Solutions
- Remove the rule from one of the two lists (enable or disable) per your intent
- If you intended to override a base config, use godoclint's mode options (e.g. 'disable' or 'default=none') consistently instead of mixing both lists
- Grep your merged .golangci.yml for the rule ID to see both occurrences
Example fix
// before (.golangci.yml)
settings:
godoclint:
enable: [wrl]
disable: [wrl]
// after
settings:
godoclint:
enable: [wrl] Defensive patterns
Strategy: validation
Validate before calling
const { enable = [], disable = [] } = cfg.settings.godoclint
const clash = enable.filter(r => disable.includes(r))
if (clash.length) throw new Error(`godoclint rule(s) both enabled and disabled: ${clash.join(', ')}`) Type guard
const noRuleConflict = (s) => !(s.enable ?? []).some(r => (s.disable ?? []).includes(r))
Prevention
- Keep godoclint rule selection in either enable or disable, not both
- When overriding a base config, remove inherited entries rather than adding the opposite list
- Validate merged config before running golangci-lint
When it happens
Trigger: In the godoclint settings block, the same rule ID is present in both 'enable' and 'disable' lists and the mode is not 'enable-only'/'disable-only' with default=none; checkSettings's first loop finds Disable containing the enabled rule.
Common situations: Merging a shared config that enables rules with a project config disabling them, adding a rule to enable while forgetting it's already in disable, copy-paste between the two lists.
Related errors
- can't combine option --config and --no-config
- can't get enabled formatters: %w
- failed to set analyzer setting %q with value %q: %w
- settings key %q must be valid analyzer name, valid analyzers
- failed to configure analyzer %s: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/078f67bce20e9f09.
Report an issue: GitHub.