Skip to content

Conversation

@sean-rn
Copy link
Contributor

@sean-rn sean-rn commented Jan 3, 2026

Given

version: "2"
linters:
  settings:
    revive:
      enable-default-rules: true
      rules:
        - name: unused-parameter
          disabled: true

Running

$ GL_DEBUG=revive golangci-lint run --enable-only=revive

would output:

DEBU [revive] Default rules (23): blank-imports, context-as-argument, context-keys-type, dot-imports, empty-block, error-naming, error-return, error-strings, errorf, exported, increment-decrement, indent-error-flow, package-comments, range, receiver-naming, redefines-builtin-id, superfluous-else, time-naming, unexported-return, unreachable-code, unused-parameter, var-declaration, var-naming. 
DEBU [revive] Enabled by config rules (0): .      
DEBU [revive] revive configuration: &lint.Config{IgnoreGeneratedHeader:false, Confidence:0.8, Severity:"warning", EnableAllRules:false, EnableDefaultRules:false, Rules:map[string]lint.RuleConfig{"unused-parameter":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:true, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}}, ErrorCode:0, WarningCode:0, Directives:map[string]lint.DirectiveConfig(nil), Exclude:[]string(nil), GoVersion:(*version.Version)(nil)} 

Note the EnableDefaultRules:false despite the config file having enable-default-rules: true and how no rules are configured.
This happens because the config.ReviveSettings is non-zero, but the ReviveSettings.EnableDefaultRules field is not being copied over to lint.Config.

With this fix we get:

DEBU [revive] Default rules (23): blank-imports, context-as-argument, context-keys-type, dot-imports, empty-block, error-naming, error-return, error-strings, errorf, exported, increment-decrement, indent-error-flow, package-comments, range, receiver-naming, redefines-builtin-id, superfluous-else, time-naming, unexported-return, unreachable-code, unused-parameter, var-declaration, var-naming. 
DEBU [revive] Enabled by config rules (22): blank-imports, context-as-argument, context-keys-type, dot-imports, empty-block, error-naming, error-return, error-strings, errorf, exported, increment-decrement, indent-error-flow, package-comments, range, receiver-naming, redefines-builtin-id, superfluous-else, time-naming, unexported-return, unreachable-code, var-declaration, var-naming. 
DEBU [revive] revive configuration: &lint.Config{IgnoreGeneratedHeader:false, Confidence:0.8, Severity:"warning", EnableAllRules:false, EnableDefaultRules:true, Rules:map[string]lint.RuleConfig{"blank-imports":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "context-as-argument":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "context-keys-type":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "dot-imports":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "empty-block":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "error-naming":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "error-return":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "error-strings":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "errorf":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "exported":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "increment-decrement":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "indent-error-flow":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "package-comments":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "range":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "receiver-naming":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "redefines-builtin-id":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "superfluous-else":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "time-naming":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "unexported-return":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "unreachable-code":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "unused-parameter":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:true, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "var-declaration":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}, "var-naming":lint.RuleConfig{Arguments:[]interface {}(nil), Severity:"warning", Disabled:false, Exclude:[]string(nil), excludeFilters:[]*lint.FileFilter(nil)}}, ErrorCode:0, WarningCode:0, Directives:map[string]lint.DirectiveConfig(nil), Exclude:[]string(nil), GoVersion:(*version.Version)(nil)}

In particular:EnableDefaultRules:true and how we get the expected default rules aside from "unused-parameter".
(Note: Disabling unused-parameter is just an arbitrary example, the behavior is the same for any combination of rules)

@boring-cyborg
Copy link

boring-cyborg bot commented Jan 3, 2026

Hey, thank you for opening your first Pull Request !

@ldez ldez self-requested a review January 3, 2026 04:26
@ldez ldez added bug Something isn't working linter: update Update the linter implementation inside golangci-lint labels Jan 3, 2026
@ldez ldez added this to the unreleased milestone Jan 3, 2026
@ldez ldez removed bug Something isn't working linter: update Update the linter implementation inside golangci-lint labels Jan 3, 2026
@ldez ldez changed the title fix: Actually respect the revive enable-default-rules setting revive: add missing enable-default-rules setting Jan 3, 2026
@ldez ldez added bug Something isn't working linter: update Update the linter implementation inside golangci-lint labels Jan 3, 2026
@ldez
Copy link
Member

ldez commented Jan 3, 2026

@sean-rn You need to sign the CLA, but the trigger has not started the check (I don't know why), so I will try to push-force to trigger the check.

It wasn't being copied from golangci config into revive config
@ldez ldez force-pushed the fix/revive-enable-default-rules branch from d41654f to def31ed Compare January 3, 2026 04:36
@CLAassistant
Copy link

CLAassistant commented Jan 3, 2026

CLA assistant check
All committers have signed the CLA.

@sean-rn
Copy link
Contributor Author

sean-rn commented Jan 3, 2026

@sean-rn You need to sign the CLA, but the trigger has not started the check (I don't know why), so I will try to push-force to trigger the check.

Your force push seems to have worked, the bot gave me a signing link.

Copy link
Member

@ldez ldez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ldez ldez merged commit 246bc08 into golangci:main Jan 3, 2026
18 checks passed
@sean-rn sean-rn deleted the fix/revive-enable-default-rules branch January 3, 2026 05:09
@ldez ldez modified the milestones: unreleased, v2.8 Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working linter: update Update the linter implementation inside golangci-lint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants