refactor: remove global reverseDirection + code quality fixes#59
Merged
refactor: remove global reverseDirection + code quality fixes#59
Conversation
…in objects
Replace the package-level *reverseDirection pointer with an isReverse bool
field on Anime and Manga structs. Direction is now carried by each value
rather than read from a global at call time.
Key changes:
- Anime.isReverse / Manga.isReverse: replaces *reverseDirection in
GetTargetID() and GetSourceID()
- All MAL constructors (newAnimeFromMalAnime, newMangasFromMalUserMangas,
etc.) take a reverse bool param and propagate isReverse
- AniList constructors (newAnimesFromMediaListGroups, newAnimeFromVerniyMedia,
etc.) take a reverse bool param so AniList targets in reverse sync also
carry isReverse=true for correct GetTargetID() behaviour
- ManualMappingStrategy{Reverse bool}: lookupByIDs uses s.Reverse
- Updater{Reverse bool}: generateUpdateDetail and trackUnmapped use u.Reverse
- AniListAnimeService / AniListMangaService carry Reverse bool, propagate to
returned Anime/Manga entries
- NewApp(ctx, config, reverse bool): direction passed explicitly from CLI
- PrintGlobalSummary takes reverse bool instead of reading global
- Run() resets the four fetchedXxx cache fields at the start of each call
(important for watch mode — prevents stale data across runs)
- reverseDirection global removed from main.go and cli.go
…lobals, interfaces)
1fdd3da to
3c72d1d
Compare
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.
Summary
Code quality fixes and refactoring on top of the favorites feature branch.
Base branch:
feature/favorites-clean(merge that first, then this).Changes
🔴 Critical
reverseDirection— replaced withisReverse boolfield onAnime/Mangastructs;Reverse boolonUpdater,ManualMappingStrategy,AniListAnimeService,AniListMangaService.GetTargetID()/GetSourceID()are now direction-aware per-instance.🟠 High
id_helpers.go—GetTargetIDWithDirection/GetSourceIDWithDirectionhad zero callers after the refactoring abovelogging.go—RoundTripnow usesl.verbosestruct field instead of the*verboseglobalDPrintf→LogDebug(ctx, ...)— 13 no-op debug calls restored with proper context propagation; ctx threaded throughnormalizeScoreForMAL,denormalizeScoreForAniList,titleMatchingLevels,exactMatch,normalizedMatch,fuzzyMatch,levenshteinMatch;SameTitleWithTarget/SameTypeWithTargetinterface updated to acceptctx🟡 Medium
setSyncFlagsFromCmd— one-liner alias forgetSyncFlagsFromCmd, callers updatedanilistID > 0branch inlookupReverse(MAL sources always haveIDAnilist=0)NewSyncReport()now initializes all 4 slices (UnmappedItems,FavoritesMismatcheswere nil)printGlobalFavorites— remove deadif reversebranch (mismatches only populated in forward direction)🟢 Low
Manga.GetUpdateMyAnimeListStatusOption()— nil stub with zero callersperformSynccallsfetchFromAnilistToMAL/fetchFromMALToAnilistdirectly; deletedfetchData,fetchNormalSyncData,fetchReverseSyncDataRefresh()resetsResolvedMappings— was missing from watch-mode state reset loopTests
fixes_test.go— covers all fixes abovet.Context()propagation in all affected test files