Skip to content

test: resolve the expired cyclop exceptions in seven test files - #382

Draft
lusoris wants to merge 3 commits into
mainfrom
test/141-cyclop-burn-down
Draft

lusoris wants to merge 3 commits into
mainfrom
test/141-cyclop-burn-down

Conversation

@lusoris

@lusoris lusoris commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Pull Request

Description

This pull request resolves the seven expired category C cyclop exceptions (#141, entered 2026-11-12, expired 2026-11-22). It splits the nine test functions that were over the cyclomatic limit of 10 into a short table or call sequence plus t.Helper() helpers, and deletes the seven entries from .golangci.yml. No dated exception is left in .golangci.yml after this change; #141 stays open for the 39 # baseline #141 entries that remain.

It also moves the self-exception of tools/go/lintexceptions to category D, expiring 2027-03-23, so main turns green again (see the last section).

What changed in the tests

  • Each over-cap test now delegates its checks to helpers that call t.Helper() first and carry a doc comment. Every helper is at cyclop 10 or below.
  • No assertion and no case was removed. The per-file count of t.Error, t.Errorf, t.Fatal and t.Fatalf calls is unchanged in six files.
  • metadata/anime/anidb: TestSearchByTitle is now a named table. The five inline query blocks became five table cases with the same queries, limits, expected lengths, AIDs and scores, checked by one helper. That is why the call count in that file drops from 110 to 98: each case still checks its length, AID and score, the "not loaded" error check stays, and TestSearchByTitleDedup is unchanged.
  • Every touched Test function has a doc comment.
  • The production code is unchanged.

Measured cyclomatic complexity (golangci-lint cyclop)

File Test Before After
arr/jackett/jackett_test.go TestSearch 17 4
arr/jackett/jackett_test.go TestGetCapabilities 16 2
metadata/anime/anidb/anidb_test.go TestSearchByTitle 18 4
metadata/anime/mal/mal_test.go TestGetAnimeSubtypes 12 2
metadata/anime/mal/mal_test.go TestExchangeCode 11 5
metadata/game/hasheous/hasheous_test.go TestLookupByHash 15 2
metadata/game/screenscraper/screenscraper_test.go TestGetGameInfo 13 2
metadata/tracking/letterboxd/letterboxd_test.go TestNewWithClientCredentials 13 8
tools/go/upstreamspec/manifest_test.go TestReadManifest 12 2

The highest value among the new helpers is 10 (checkSearchFirstResult and checkCapabilitiesCore in arr/jackett).

Things a reviewer should know

  • Generated block. The seven dated entries were removed by hand in the first commit. The second commit is the output of make lint-exceptions-gen, which re-measured all 72 modules and found 39 findings. It only deletes lines: the 19 # baseline #141 entries it drops all name the nine split tests, whose gocyclo, gocognit and funlen findings are gone with the split.
  • Hand edit inside the split. checkCapabilitiesCore in arr/jackett takes *jackett.Capabilities. The first draft declared a value parameter, which did not compile because GetCapabilities returns a pointer.
  • Why both changes ride in one pull request. On main, the local praetorctl audit hook refuses any commit while the seven expired entries are in .golangci.yml, and the CI job lint-exceptions fails on any branch until the category D change below is in. Each change needs the other, so they land together as separate commits.

Category D for the tools/go/lintexceptions self-exception

tools/go/lintexceptions is itself an exception to one mechanism per behavior (HISS-19). Its category C date ran out on 2026-11-22, so TestThisCheckIsItselfCurrent has failed on main and on every pull request since then.

  • New category and dates: category D, entered 2026-11-23, expires 2027-03-23 (test: burn down the dated complexity exceptions in test files #141).
  • Why category D and not another 10-day renewal: the engine audit (praetorctl audit) judges the same dated block in the local hooks, but CI runs no server-side praetorctl audit by adoption. This check is therefore the second barrier for the block in CI. That reason is structural, so a dated burn-down does not end it.
  • Revisit trigger: once CI runs praetorctl audit, delete this package.
  • selfExpiry is 2027-03-23; the package doc and the failure message of TestThisCheckIsItselfCurrent say the same.
  • New TestSelfExpiryHoldsThroughItsDay pins the boundary: the check holds on the day before and on the expiry day, and fails the day after.
  • The planted cases are unchanged: an exception dated 2026-10-29 still expires on 2026-10-30 (TestExpiredHoldsThroughTheExpiryDay), and the expired planted rule in TestCheckRefusesPlantedDefects is still refused.

Module(s) Affected

  • arr/... (arr/jackett, test file only)
  • metadata/... (anime/anidb, anime/mal, game/hasheous, game/screenscraper, tracking/letterboxd, test files only)
  • tools/go/upstreamspec (test file only), tools/go/lintexceptions (expiry constant, package doc, tests), plus the root .golangci.yml

Type of Change

  • Refactor (tests only)

Checklist

  • Tests pass (go test -race -count=1 -cover per touched module; coverage: jackett 97.1%, anidb 80.2%, mal 82.8%, hasheous 71.4%, screenscraper 85.1%, letterboxd 78.5%, upstreamspec 78.6%)
  • Lint passes (golangci-lint run per touched module, 0 issues)
  • New functionality has tests (no new functionality)
  • example_test.go updated if public API changed (no public API change)
  • go.work updated if new module added (no new module)

Summary by Sourcery

Refactor complex tests and update exception handling so lint checks pass without dated cyclop exceptions.

Bug Fixes:

  • Resolve expired cyclop lint exceptions across nine test functions without changing production behavior.
  • Restore the lintexceptions self-check by extending its exception through 2027-03-23 and covering its expiry boundary.

Enhancements:

  • Refactor complex tests into table-driven flows and focused helper assertions while preserving existing coverage and checks.

Tests:

  • Add coverage for the lintexceptions self-expiry boundary.

Chores:

  • Remove the seven expired category C exceptions and obsolete generated lint baselines from .golangci.yml.

Summary by CodeRabbit

  • Tests
    • Reorganized checks for search, metadata, authentication, and manifest handling while preserving existing expectations.
    • Added coverage for the validity of a tooling exception through its expiry date.
  • Chores
    • Updated maintenance records for code-quality checks. No end-user behavior changes are noted.

The seven test files whose category C cyclop exceptions expired on
2026-11-22 now stay under the limits. The request checks and the
per-field result checks of nine test functions move into t.Helper()
functions, anidb's title search becomes a named table, every touched
Test function has a doc comment, and the seven expired entries leave
.golangci.yml. No assertion and no case was removed.

Refs: #141
Signed-off-by: lusoris <lusoris@proton.me>
make lint-exceptions-gen re-measured all 72 modules and found 39
findings. The 19 baseline entries it drops all name the nine split
tests, whose gocyclo, gocognit and funlen findings are gone. The
diff only deletes lines.

Refs: #141
Signed-off-by: lusoris <lusoris@proton.me>
The self-exception of tools/go/lintexceptions ran out on 2026-11-22,
so TestThisCheckIsItselfCurrent failed on main and on every pull
request. It moves to category D, entered 2026-11-23 and expiring
2027-03-23: the engine audit judges the same block in the local
hooks, but CI runs no server-side praetorctl audit by adoption, so
this check is the second barrier for the block in CI. Revisit when
CI runs praetorctl audit.

TestSelfExpiryHoldsThroughItsDay pins the boundary of the new date.
The planted 2026-10-29 cases are unchanged.

Refs: #141
Signed-off-by: lusoris <lusoris@proton.me>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes reorganize assertions in several tests, update selected linter exceptions, and extend the lintexceptions package expiry date with a boundary test.

Changes: Test and lint exception maintenance

Layer / File(s) Summary
Refactor test assertions
arr/jackett/jackett_test.go, metadata/anime/..., metadata/game/..., metadata/tracking/letterboxd/letterboxd_test.go, tools/go/upstreamspec/manifest_test.go
Tests move existing request, result, and manifest checks into helpers or table-driven cases.
Update linter exceptions
.golangci.yml
Selected test suppressions are removed. The getTestAnime and TestTVSearch exceptions remain, and an exception is added for makeTestZip.
Update lintexceptions expiry checks
tools/go/lintexceptions/lintexceptions.go, tools/go/lintexceptions/lintexceptions_test.go
The self-expiry date changes to 2027-03-23. A test checks expiry behavior before, on, and after that date.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Possibly related issues

  • Issue 141 — The test refactoring and exception removals align with its exception cleanup objective; the issue summary says it remains partly open.
  • Issue 311 — This change removes some stale exception entries, but does not add the proposed stale-rule check.
  • Issue 270 — The removed cyclop exceptions and test refactoring align with its objective to resolve expiring test exceptions.

Suggested reviewers: sourcery-ai

Merge Risk: Minimal · up to cb8dd

This change reorganizes tests and updates lint exception bookkeeping without altering production behavior. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title 'test: resolve the expired cyclop exceptions in seven test files' follows the Conventional Commits type(scope) form with the accepted 'test' type and states the main change. The PR also refa…
Description check Passed The description follows the repository template closely. It has a Description section with a detailed summary of the seven expired exceptions, the nine split test functions, and the category D change.…
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.
Full details: Title check

Explanation

The title 'test: resolve the expired cyclop exceptions in seven test files' follows the Conventional Commits type(scope) form with the accepted 'test' type and states the main change. The PR also refactors nine test functions across seven files, removes seven expired exceptions from .golangci.yml, and moves the lintexceptions self-exception to category D. The title covers the main test refactor and exception removal but omits the category D change and the nine-function refactor. It is partially related to the changeset. The title does not include a scope in parentheses, which the requirement's type(scope) form suggests, but the requirement does not make a scope mandatory.

Full details: Description check

Explanation

The description follows the repository template closely. It has a Description section with a detailed summary of the seven expired exceptions, the nine split test functions, and the category D change. It lists affected modules with checkboxes, marks Refactor as the type of change, and completes the checklist with test and lint results. The remaining checklist items are unchecked, but they are marked as not applicable with reasons given. The description is mostly complete and clearly states what changed and why.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2fd8454 and cb8ddc9.

Files selected for processing: 10

  • .golangci.yml
  • arr/jackett/jackett_test.go
  • metadata/anime/anidb/anidb_test.go
  • metadata/anime/mal/mal_test.go
  • metadata/game/hasheous/hasheous_test.go
  • metadata/game/screenscraper/screenscraper_test.go
  • metadata/tracking/letterboxd/letterboxd_test.go
  • tools/go/lintexceptions/lintexceptions.go
  • tools/go/lintexceptions/lintexceptions_test.go
  • tools/go/upstreamspec/manifest_test.go
Files with no reviewable changes: 1

  • .golangci.yml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@sourcery-ai

sourcery-ai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Move the lintexceptions self-expiry date and document why the CI guard remains until CI runs the praetorctl audit.

  • tools/go/lintexceptions/lintexceptions.go L10-13, L26

Configuration

Remove the seven expired cyclop exceptions and the obsolete baseline entries for findings eliminated by the test refactors.

  • .golangci.yml L243-398 (7 small edits)

Tests

Split Jackett request, result, and capabilities assertions into helpers while preserving the test coverage.

  • arr/jackett/jackett_test.go L117-137, L167-191, L402-434 (+1 small edits)

Convert AniDB title-search checks into named cases and share the seeding and result assertions through helpers.

  • metadata/anime/anidb/anidb_test.go L586-587, L597-648

Extract MyAnimeList subtype assertions and OAuth exchange request checks into helpers.

  • metadata/anime/mal/mal_test.go L176-191, L764-787, L807-815 (+3 small edits)

Move Hasheous request and decoded-result assertions into helpers for the hash lookup test.

  • metadata/game/hasheous/hasheous_test.go L24-70, L76, L99

Move ScreenScraper request and decoded-response assertions into helpers for the game-info test.

  • metadata/game/screenscraper/screenscraper_test.go L27-70, L75, L103

Extract Letterboxd token and authenticated-film handlers from the client-credentials test.

  • metadata/tracking/letterboxd/letterboxd_test.go L66-97, L107-109

Extract manifest-case assertions and supplemental checks from the upstream-spec manifest test.

  • tools/go/upstreamspec/manifest_test.go L61-91, L133-136

Update the lintexceptions expiry failure message and add a boundary test for the self-expiry date.

  • tools/go/lintexceptions/lintexceptions_test.go L50, L153-175

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

This branch has not been deployed

No deployments
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