Skip to content

chore(lint): enable revive defaults and drop dead exclusions - #928

Merged
gaborage merged 4 commits into
mainfrom
chore/revive-enable-default-rules
Aug 8, 2026
Merged

chore(lint): enable revive defaults and drop dead exclusions#928
gaborage merged 4 commits into
mainfrom
chore/revive-enable-default-rules

Conversation

@gaborage

@gaborage gaborage commented Aug 8, 2026

Copy link
Copy Markdown
Owner

What

.golangci.yml re-declared golangci-lint's 23 default revive rules, because declaring
rules replaces the default set rather than extending it. enable-default-rules: true
restores them, so only the 17 uber-go additions need listing — and deleting one line can no
longer silently drop a rule. Also removes two var-naming exclusions that stopped matching
at revive v1.15.0, and updates wiki/linting.md for both.

Impact

None — behavior-identical. In v2.12.2 the same defaultRules slice backs both the implicit
default and enable-default-rules, and it is a verbatim copy of revive v1.15.0's list.
Consumers following wiki/linting.md now get the flag rather than a 23-line transcription.

Verification

Resolved-config dumps differ in exactly one field (EnableDefaultRules), same 40 rules with
identical arguments. With exclusion presets stripped so the comparison is non-vacuous, the
full repo yields the same 166 issues (88 revive) under both, matched issue-for-issue. The
deleted exclusions suppressed nothing — removing them leaves the repo at 0 findings.

Summary by CodeRabbit

  • Chores

    • Updated static analysis settings to use the standard rule set while preserving custom checks.
    • Removed outdated naming exclusions.
  • Documentation

    • Clarified how default rules and message-text exclusions work.
    • Added guidance for scoping rules by path and linter.
    • Documented compatibility considerations when combining default rules with all available rules.

Declaring linters.settings.revive.rules REPLACES revive's default set,
so the 23 default rule names were re-listed ahead of the uber-go
additions to avoid silently dropping enforcement. golangci-lint v2.12.2
accepts enable-default-rules, which restores those defaults without the
re-declaration and removes the failure mode the re-declaration created:
deleting one of the 23 lines loses a rule with no signal.

Verified behavior-preserving rather than assumed:

- golangci-lint v2.12.2's internal defaultRules list is a verbatim copy
  of revive v1.15.0's, and enable-default-rules feeds that same list
  through normalizeConfig, so the two spellings cannot diverge at this
  pin.
- GL_DEBUG=revive dumps the resolved lint.Config. The dumps for the two
  spellings differ in exactly one field — EnableDefaultRules itself:
  same 40 rules, each with identical Arguments, Severity, Disabled and
  Exclude, plus Confidence 0.8 and Severity "warning".
- A throwaway probe package planting a deliberate violation of each of
  the 23 defaults produced an identical finding set under both configs
  (22 rules fired; time-naming emits nothing under golangci-lint at this
  pin for any construct tried, and staticcheck ST1011 covers that class).
- Repo-wide runs matched exactly, issue for issue: 0/0 with the real
  config, 166/166 with the exclusion presets stripped (88 revive: 68
  exported + 20 package-comments), 0/0 with the two var-naming exclusion
  rules stripped.
- No run logged level=error or "cannot find rule".

Pre-existing drift noticed while checking the exclusions and left alone:
the two `text: "var-naming: avoid package names"` exclusion rules match
nothing at revive v1.15.0, because that package-name check moved out of
var-naming into the (unenabled) package-naming rule and was reworded.
The findings they suppressed are no longer produced at all, under either
spelling.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 376fa728-92b8-4527-91b2-5aaf4e4c5ad4

📥 Commits

Reviewing files that changed from the base of the PR and between 21fd934 and 0c2e531.

📒 Files selected for processing (1)
  • wiki/linting.md

Walkthrough

The Revive configuration now enables default rules with enable-default-rules: true. Custom rules remain configured. The linting guide documents default-rule behavior, stale exclusions, scoping guidance, and configuration constraints.

Changes

Revive linting

Layer / File(s) Summary
Configure Revive defaults
.golangci.yml
Enables Revive default rules, retains custom rules, and removes two package-name exclusions.
Update linting guidance
wiki/linting.md
Documents default-rule replacement behavior, stale message exclusions, recommended scoping, and incompatibility with enable-all-rules.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit checks the rules today,
Default checks now lead the way.
Custom rules stay near,
Clear guidance makes them clear,
While stale exclusions fade away.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: enabling Revive default rules and removing obsolete exclusions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/revive-enable-default-rules

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 8, 2026
Both `text: "var-naming: avoid package names"` stanzas — for
(cache|database|observability)/testing/ and trace/ — stopped matching at revive
v1.15.0, when the package-name check moved out into a separate `package-naming`
rule (not in the default set, not enabled here) and every message was reworded.
That text exists only in v1.14.0.

They were suppressing nothing: deleting them leaves the repo at 0 findings
under `--uniq-by-line=false`, exactly as before. This is not a behavior change,
it is removing config that had silently stopped applying.

Found while proving the enable-default-rules swap in the previous commit: the
exclusions match on message text, so they had to be re-verified rather than
assumed, and re-verifying showed they were already inert.

wiki/linting.md is updated for both commits. The revive section now presents
enable-default-rules as what this repo does rather than as an alternative for
new configs, and the exclusions section carries the transferable lesson: an
exclusion keyed on message `text` dies silently when the linter rewords the
message, in either direction, so prefer scoping by `path` and `linters`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gaborage gaborage changed the title chore(lint): enable revive defaults instead of re-declaring 23 rules chore(lint): enable revive defaults and drop dead exclusions Aug 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@wiki/linting.md`:
- Line 60: Update the wording in the linting documentation to use “scopes”
instead of “scopings” in the phrase describing the `_test.go` exceptions,
without changing the surrounding lint configuration references.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c0b97e38-e700-4a2d-a7a9-b37a1816168b

📥 Commits

Reviewing files that changed from the base of the PR and between a22b812 and bd7baa0.

📒 Files selected for processing (2)
  • .golangci.yml
  • wiki/linting.md
💤 Files with no reviewable changes (1)
  • .golangci.yml

Comment thread wiki/linting.md
"a few `_test.go` scopings" -> "a few rules scoped to `_test.go`". Not a word,
and the rephrasing also names what is actually being described.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
wiki/linting.md (2)

65-68: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Scope the statement about suppressed findings.

The repository still contains 11 inline var-naming suppressions under database/types/. Change “Nothing was being suppressed” to “The two exclusions suppressed nothing.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wiki/linting.md` around lines 65 - 68, Update the statement in the linting
documentation to say that the two exclusions suppressed nothing, rather than
claiming that nothing was being suppressed generally. Preserve the surrounding
explanation about the two obsolete `var-naming` stanzas and their removal.

170-174: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Qualify the “strictly safer” claim.

When dependency versions change, recheck the resolved rule set. Replace “strictly safer” with “safer against accidental omissions.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@wiki/linting.md` around lines 170 - 174, Update the prose around the
golangci-lint default-list flag to replace “strictly safer” with “safer against
accidental omissions,” while preserving the surrounding explanation and caveat
about incompatibility with enable-all-rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@wiki/linting.md`:
- Around line 65-68: Update the statement in the linting documentation to say
that the two exclusions suppressed nothing, rather than claiming that nothing
was being suppressed generally. Preserve the surrounding explanation about the
two obsolete `var-naming` stanzas and their removal.
- Around line 170-174: Update the prose around the golangci-lint default-list
flag to replace “strictly safer” with “safer against accidental omissions,”
while preserving the surrounding explanation and caveat about incompatibility
with enable-all-rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a88756b5-65eb-49e4-9594-83f1c9243c85

📥 Commits

Reviewing files that changed from the base of the PR and between bd7baa0 and 21fd934.

📒 Files selected for processing (1)
  • wiki/linting.md

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 8, 2026
Both were unqualified statements that read wider than the evidence behind them.

"Nothing was being suppressed" sat in a paragraph advising readers to recheck
their own exclusions, where it could be read as a claim about exclusions in
general. Scoped to the two var-naming stanzas actually measured.

"strictly safer" overstated enable-default-rules. It is safer against one
specific failure — omitting a default when re-declaring by hand — and it costs
the visible inventory that re-declaration gave. Now "safer against accidental
omissions", which is the claim the evidence supports.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@gaborage
gaborage enabled auto-merge (squash) August 8, 2026 04:01
@sonarqubecloud

sonarqubecloud Bot commented Aug 8, 2026

Copy link
Copy Markdown

@gaborage
gaborage merged commit 6fc6c0f into main Aug 8, 2026
27 checks passed
@gaborage
gaborage deleted the chore/revive-enable-default-rules branch August 8, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant