Skip to content

fix: --reverse-direction flag ignored, statistics Total/Skipped mismatch#60

Merged
bigspawn merged 4 commits intomainfrom
fix/reverse-direction-and-statistics
Mar 1, 2026
Merged

fix: --reverse-direction flag ignored, statistics Total/Skipped mismatch#60
bigspawn merged 4 commits intomainfrom
fix/reverse-direction-and-statistics

Conversation

@bigspawn
Copy link
Owner

@bigspawn bigspawn commented Mar 1, 2026

Bug fixes

--reverse-direction was completely broken
getSyncFlagsFromCmd was reading cmd.Bool("reverse") instead of cmd.Bool("reverse-direction"). The flag does not exist under that name, so reverseVal was always false — sync and favorites always ran in forward direction regardless of the flag.

Statistics showed Skipped > Total
IncrementTotal() was called after the ignore list check, so ignored entries were added to Skipped but not Total. Moved IncrementTotal() before the check so the counts are consistent.

Tests

Added regression tests for getSyncFlagsFromCmd to catch the above flag-reading bug.

- cli.go: cmd.Bool("reverse") → cmd.Bool("reverse-direction")
  This was a critical bug: the flag was registered as "reverse-direction"
  but getSyncFlagsFromCmd read "reverse" (non-existent), so reverseVal
  was always false. Effect: --reverse-direction was completely ignored,
  both main sync and favorites always ran in forward (AniList→MAL) mode.

- updater.go: move IncrementTotal() before isIgnored() check
  Previously, "in ignore list" entries were counted in Skipped but NOT
  in Total, making Skipped > Total in the global summary (e.g., 635 vs 631).
  Now Total includes all valid-status entries (including ignored ones),
  so Total == Updated + Skipped + DryRun always holds.

- cli_test.go: add regression tests for getSyncFlagsFromCmd
  TestGetSyncFlagsFromCmd_ReverseDirection: verifies reverseOut=true
  TestGetSyncFlagsFromCmd_NoReverse: verifies reverseOut=false
  TestGetSyncFlagsFromCmd_VerboseFlag: verifies verboseOut=true
  Uses saveGlobalSyncFlags()/defer to prevent global state leakage
  between tests (getSyncFlagsFromCmd sets package-level vars).
@bigspawn bigspawn changed the title fix: --reverse-direction broken + statistics Total/Skipped inconsistency fix: --reverse-direction flag ignored + statistics Total/Skipped inconsistency Mar 1, 2026
@bigspawn bigspawn changed the title fix: --reverse-direction flag ignored + statistics Total/Skipped inconsistency fix: --reverse-direction flag ignored, statistics Total/Skipped mismatch Mar 1, 2026
bigspawn added 3 commits March 1, 2026 16:16
Added linters with autofix support not previously enabled:
- canonicalheader, dupword, exptostd, fatcontext, iface, importas,
  mirror, tagalign, usetesting (0 issues, safe additions)
- modernize: interface{} -> any, slices.Contains, max/min, WaitGroup.Go
- perfsprint: errors.New, string concat, strconv.Itoa instead of Sprintf
- intrange: for loops with integer range (Go 1.22+)
- godot: comments end in period
- noinlineerr: separate err assignment from if condition

Skipped linters (too opinionated / not applicable):
- err113: 152 issues, requires global error vars for all fmt.Errorf calls
- wsl_v5: 152 issues, whitespace everywhere
- nlreturn: 29 issues, blank line before every return
- ginkgolinter/protogetter/sloglint/testifylint: unused frameworks

Fixed autofix regression in cmd_logout.go and oauth.go where
noinlineerr incorrectly emitted duplicate ':=' for already-declared err.
Added nolint:gosec for os.Remove calls with internal temp paths.
@bigspawn bigspawn merged commit 3f7158e into main Mar 1, 2026
3 checks passed
@bigspawn bigspawn deleted the fix/reverse-direction-and-statistics branch March 1, 2026 15:32
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