golangci/golangci-lint · error

enable-all and enabled-checks options must not be combined

Error message

enable-all and enabled-checks options must not be combined

What it means

With gocritic enable-all enabled, listing enabled-checks is rejected because it conflicts with the semantics of turning everything on. validateOptionsCombinations throws this to prevent ambiguous configurations where inclusion lists and bulk enable coexist.

Source

Thrown at pkg/golinters/gocritic/gocritic_settings.go:310

			return err
		}
	}
	return nil
}

func (s *settingsWrapper) validateOptionsCombinations() error {
	if s.EnableAll && s.DisableAll {
		return errors.New("enable-all and disable-all options must not be combined")
	}

	switch {
	case s.EnableAll:
		if len(s.EnabledTags) > 0 {
			return errors.New("enable-all and enabled-tags options must not be combined")
		}

		if len(s.EnabledChecks) > 0 {
			return errors.New("enable-all and enabled-checks options must not be combined")
		}

	case s.DisableAll:
		if len(s.DisabledTags) > 0 {
			return errors.New("disable-all and disabled-tags options must not be combined")
		}

		if len(s.DisabledChecks) > 0 {
			return errors.New("disable-all and disabled-checks options must not be combined")
		}

		if len(s.EnabledTags) == 0 && len(s.EnabledChecks) == 0 {
			return errors.New("all checks were disabled, but no one check was enabled: at least one must be enabled")
		}
	}

	return nil
}

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Remove enabled-checks when enable-all is set
  2. Use disabled-checks with enable-all to turn off specific checks instead
  3. Drop enable-all if per-check opt-in (enabled-checks) is the desired behavior
  4. Verify config with 'golangci-lint config verify' before CI runs

Example fix

// before (.golangci.yml)
gocritic:
  enable-all: true
  enabled-checks:
    - rangeValCopy

// after
gocritic:
  enable-all: true
  disabled-checks:
    - hugeParam
Defensive patterns

Strategy: validation

Validate before calling

if cfg.Gocritic.EnableAll && len(cfg.Gocritic.EnabledChecks) > 0 {
    return errors.New("gocritic: use disabled-checks instead of enabled-checks with enable-all")
}

Prevention

When it happens

Trigger: gocritic settings combine enable-all: true with a non-empty enabled-checks list in .golangci.yml.

Common situations: Adding enable-all on top of an existing check-by-check config; scripts that append enable-all without cleaning enabled-checks; misunderstanding that enable-all acts as a default rather than a strict mode.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/177595e4c1dc60d3. Report an issue: GitHub.