fix: --reverse-direction flag ignored, statistics Total/Skipped mismatch#60
Merged
fix: --reverse-direction flag ignored, statistics Total/Skipped mismatch#60
Conversation
- 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).
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.
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.
Bug fixes
--reverse-direction was completely broken
getSyncFlagsFromCmdwas readingcmd.Bool("reverse")instead ofcmd.Bool("reverse-direction"). The flag does not exist under that name, soreverseValwas alwaysfalse— 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 toSkippedbut notTotal. MovedIncrementTotal()before the check so the counts are consistent.Tests
Added regression tests for
getSyncFlagsFromCmdto catch the above flag-reading bug.