golangci/golangci-lint · error

check %q disabled and enabled at one moment

Error message

check %q disabled and enabled at one moment

What it means

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).

Source

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

		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 nil
}

type goCriticChecks[T any] map[string]T

func (m goCriticChecks[T]) has(name string) bool {
	_, ok := m[name]

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Delete the check from disabled-checks if you want it enabled
  2. Delete the check from enabled-checks if you want it disabled
  3. Keep a single source of truth for check enable/disable state in your config

Example fix

// before (.golangci.yml)
settings:
  gocritic:
    enabled-checks: [hugeParam]
    disabled-checks: [hugeParam]
// after
settings:
  gocritic:
    enabled-checks: [hugeParam]
Defensive patterns

Strategy: validation

Validate before calling

const enabled = cfg.settings.gocritic['enabled-checks'] ?? []
const disabled = cfg.settings.gocritic['disabled-checks'] ?? []
const clash = disabled.filter(c => enabled.includes(c))
if (clash.length) throw new Error(`check(s) both enabled and disabled: ${clash.join(', ')}`)

Type guard

const listsAreDisjoint = (a, b) => !a.some(x => b.includes(x))

Prevention

When it happens

Trigger: settings.gocritic has the same check name in both enabled-checks and disabled-checks; validateDisabledAndEnabledAtOneMoment uses slices.Contains over EnabledChecks for each DisabledChecks entry.

Common situations: 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.

Related errors


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