Skip to content

ci(lint): enable gocritic's bug-finding checks and three small linters - #2592

Merged
Quick104 merged 1 commit into
mainfrom
fix/lint-enable-bug-finding-checks
Oct 16, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/lint-enable-bug-finding-checks

Conversation

@Quick104

@Quick104 Quick104 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Several bug-finding checks were left disabled in #2522 because each had a handful of findings in the tree. While they stay off, new code can add a reversed argument pair, a slice at an unchecked Index, or a resource deferred inside a loop with nothing to flag it. This change resolves the existing findings and enables the checks, so they report nothing on main and catch new cases on changed lines.

Enabled:

  • gocritic: argOrder, badCall, badCond, badRegexp, deferInLoop, dupImport, evalOrder, exitAfterDefer, nilValReturn, offBy1, uncheckedInlineErr
  • revive: identical-ifelseif-branches
  • linters: reassign, goprintffuncname, mirror

Approach

None of the 45 findings was a live bug. The fixes keep behavior:

  • writeTimingLine in internal/subtitles splits the cue line with bytes.Cut instead of slicing at an unchecked bytes.Index. Its callers always pass the line holding -->.
  • Three DB tests that slice SQL at strings.Index now fail with a message, instead of panicking, when the expected CTE is missing.
  • Two storage-sample returns in internal/downloads call UpsertStorageSample before they return the summary passed to it by pointer, so the evaluation order is explicit. Two nil checks in jellycompat return nil directly.
  • The two replan rollback calls in playback_v3.go that discard the session error move out of their if statements, with a comment saying why the error goes unused.
  • Printf-like helpers gain an f suffix: fail, recordFailure, report.
  • The rest remove a duplicate embed import, a single-argument filepath.Join, an identical else if branch, and []byte conversions.

Where the flagged pattern is intended, the line carries a nolint directive with its reason. These cover per-row cleanup defers in tests, defers followed by a return inside a loop, a typeahead fake's reversed HasPrefix, the stack-part regexp's inner ^, and log.Fatalf after the debug listener's defer. revive's already enabled defer rule reports the same loop sites, so those directives name both linters. Two entry.Close() defers now assign their error to _, because the edit put them on changed lines, where errcheck reports.

weakCond and mapKey stay disabled, with their reason in the config. All 10 weakCond findings are regexp index results, which are full length whenever they are non-nil. All 14 mapKey findings are whitespace-trimming test inputs.

Validation

  • golangci-lint v2.12.2: the enabled checks report 0 findings over the whole tree, and make lint-changed reports 0 issues.
  • go vet and go test pass for all 24 touched packages. The DB-backed tests among them were skipped locally (no Postgres) and run in this PR's database jobs.
  • make verify-size-ratchet passes.

Evidence

Evidence: none, no user-visible change

Risks

None identified. The renamed helpers are unexported.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

  • Harness: Claude Code, run inside T3 Code
  • Tool(s): Claude Code, golangci-lint
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Enable gocritic bug-finding checks and fix lint findings across services

  • Turns on the reassign, goprintffuncname, and mirror linters plus previously commented gocritic checks in .golangci.yml, and fixes the findings they surface across the codebase
  • Renames printf-style helpers to failf (playbackfixtures, settingsgen) and recordFailuref in auto_update.go, and reportf in sweep.go
  • Replaces manual string/byte slicing with strings.Cut / bytes.Cut in catalog DB tests and subtitles.writeTimingLine
  • Behavioral Change: subtitles.writeTimingLine no longer panics on a line without the cue arrow — it formats the left portion with an empty right portion; the audiobooks playlist-create handler now falls back to the newly created playlist on any GetPlaylist error, not just ErrNotFound; catalog DB tests now fail with a diagnostic when the page CTE marker is absent instead of slicing at an unchecked index

Macroscope summarized 3375066.

Enable the gocritic checks argOrder, badCall, badCond, badRegexp,
deferInLoop, dupImport, evalOrder, exitAfterDefer, nilValReturn, offBy1,
and uncheckedInlineErr, revive's identical-ifelseif-branches, and the
reassign, goprintffuncname, and mirror linters. Each had 0 to 12
findings in the tree; all are resolved, so the checks report nothing
on main.

No finding was a live bug. The fixes keep behavior:

- writeTimingLine splits the cue line with bytes.Cut instead of slicing
  at an unchecked Index, and three tests fail with a message instead of
  panicking when the SQL they slice lacks the expected CTE.
- Two storage-sample returns call UpsertStorageSample before returning
  the summary they pass by pointer, and two nil checks return nil.
- The replan rollback calls that discard the session error move out of
  their if statements, with a comment saying why the error is unused.
- Printf-like helpers take an f suffix: fail, recordFailure, report.
- The rest drop a duplicate embed import, a redundant filepath.Join, an
  identical else-if branch, and []byte conversions.

Sites where the pattern is intended carry a nolint directive with its
reason: per-row cleanup defers in tests, defers followed by a return
inside a loop, a typeahead fake's reversed HasPrefix, the stack-part
regexp's inner ^, and log.Fatalf after the debug listener's defer.

weakCond and mapKey stay disabled: all of their findings are regexp
index results and whitespace-trimming test inputs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 16, 2026
@silo-kody

silo-kody Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f07c71a-5c51-4f4a-9461-52e56ceef70b
📥 Commits

Reviewing files that changed from the base of the PR and between c414af7 and 3375066.

📒 Files selected for processing: 32
  • .golangci.yml
  • cmd/playbackfixtures/main.go
  • cmd/settingsgen/main.go
  • cmd/silo/main.go
  • contracts/api/v2/embed.go
  • internal/api/handlers/playback_v3.go
  • internal/apibench/bench_test.go
  • internal/apiv2/admin_policy_pages_test.go
  • internal/apiv2/catalog_actions_test.go
  • internal/apiv2/catalog_items_test.go
  • internal/audiobooks/abs/playlists_handler.go
  • internal/blobstore/filesystem.go
  • internal/catalog/search_episode_exact_db_test.go
  • internal/catalog/search_optimization_db_test.go
  • internal/downloads/repo.go
  • internal/downloads/storage_maintenance.go
  • internal/ebooks/enrichment_queue_test.go
  • internal/historyimport/repo_test.go
  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/images.go
  • internal/metadata/nfo/lookup.go
  • internal/plugins/auto_update.go
  • internal/plugins/auto_update_defaults_test.go
  • internal/routeinventory/sweep.go
  • internal/s3client/transport_test.go
  • internal/scanner/ebook.go
  • internal/scanner/pdf_trailer.go
  • internal/scantrigger/scantrigger_test.go
  • internal/subtitles/timing.go
  • internal/themesongs/repository_test.go
  • internal/watchsync/ratings.go
  • internal/webhooksync/management_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@silo-triage silo-triage Bot added go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 16, 2026
@Quick104 Quick104 added the evidence-not-needed A maintainer waived the Evidence check, for example for an automated dependency update label Oct 16, 2026
@Quick104
Quick104 merged commit 6e78fbc into main Oct 16, 2026
20 checks passed
@Quick104
Quick104 deleted the fix/lint-enable-bug-finding-checks branch October 16, 2026 16:19
blurbery added a commit to blurbery/silo-server that referenced this pull request Oct 18, 2026
…ries

Upstream's wider static checks (Silo-Server#2522, Silo-Server#2592) now cover every line the
fork carries, and flagged nine in the open PR carries and fork-only
fixes. None changes behaviour:

- funlen and gocyclo: TestInitDevEnvOutputLoadsWithGodotenv (Silo-Server#1049),
  TestHDR10PlusBackfillRecordsFrameStatusDB (Silo-Server#2308) and
  TestPostgresSupersededEpisodeProgressIDs move their fixtures and
  checks into helpers. The notification decorator's
  preserveSupersededProgress splits its type switch by whether the
  decorator keeps episode parent completion.
- nestif and iface: Continue Watching's exact superseded-episode query
  moves into exactSupersededEpisodeProgressIDs, which asks the store
  through the new userstore.ExactSupersededEpisodeProgressIDs, so the
  interface is used in the package that declares it.
- errchkjson: the HDR10+ backfill result is plain integers, so its
  marshal error is discarded like the other backfill tasks.
- gosec G204: the HDR10+ first-frame ffprobe call gets the reason its
  arguments are safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evidence-not-needed A maintainer waived the Evidence check, for example for an automated dependency update go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant