Repository navigation
ci(lint): enable gocritic's bug-finding checks and three small linters - #2592
Merged
Merged
Conversation
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 Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Contributor
|
Warning Review limit reachedYou'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. View limit details
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. Comment |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onmainand catch new cases on changed lines.Enabled:
argOrder,badCall,badCond,badRegexp,deferInLoop,dupImport,evalOrder,exitAfterDefer,nilValReturn,offBy1,uncheckedInlineErridentical-ifelseif-branchesreassign,goprintffuncname,mirrorApproach
None of the 45 findings was a live bug. The fixes keep behavior:
writeTimingLineininternal/subtitlessplits the cue line withbytes.Cutinstead of slicing at an uncheckedbytes.Index. Its callers always pass the line holding-->.strings.Indexnow fail with a message, instead of panicking, when the expected CTE is missing.internal/downloadscallUpsertStorageSamplebefore they return the summary passed to it by pointer, so the evaluation order is explicit. Two nil checks in jellycompat returnnildirectly.playback_v3.gothat discard the session error move out of theirifstatements, with a comment saying why the error goes unused.fsuffix:fail,recordFailure,report.embedimport, a single-argumentfilepath.Join, an identicalelse ifbranch, and[]byteconversions.Where the flagged pattern is intended, the line carries a
nolintdirective with its reason. These cover per-row cleanup defers in tests, defers followed by a return inside a loop, a typeahead fake's reversedHasPrefix, the stack-part regexp's inner^, andlog.Fatalfafter the debug listener's defer. revive's already enableddeferrule reports the same loop sites, so those directives name both linters. Twoentry.Close()defers now assign their error to_, because the edit put them on changed lines, where errcheck reports.weakCondandmapKeystay disabled, with their reason in the config. All 10weakCondfindings are regexp index results, which are full length whenever they are non-nil. All 14mapKeyfindings are whitespace-trimming test inputs.Validation
make lint-changedreports 0 issues.go vetandgo testpass 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-ratchetpasses.Evidence
Evidence: none, no user-visible change
Risks
None identified. The renamed helpers are unexported.
Checklist
AI Disclosure
claude-opus-5-5🤖 Generated with Claude Code
Note
Enable gocritic bug-finding checks and fix lint findings across services
reassign,goprintffuncname, andmirrorlinters plus previously commented gocritic checks in .golangci.yml, and fixes the findings they surface across the codebasefailf(playbackfixtures, settingsgen) andrecordFailurefin auto_update.go, andreportfin sweep.gostrings.Cut/bytes.Cutin catalog DB tests andsubtitles.writeTimingLinesubtitles.writeTimingLineno 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 anyGetPlaylisterror, not justErrNotFound; catalog DB tests now fail with a diagnostic when the page CTE marker is absent instead of slicing at an unchecked indexMacroscope summarized 3375066.