refactor: extract shared utilities for duplicated provider logic - #113
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
refactor: extract shared utilities for duplicated provider logic#113devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Behavior-preserving de-duplication of the clone groups a
jscpdscan (167 exact clones, ~3k duplicated lines overapp/) flagged as literal copies, plus the JSXInputvariants. Net -730 lines, no behavior change: fullrspecis identical tomainon this box (793 examples, same 3 pre-existing env failures: unbuilt sprockets asset x2 + the node suite wrapper),npm test88/88,eslint0 errors,npm run buildclean.Five extractions:
SpellSlots(app/lib/spell_slots.rb) — the level→slots tables were copy-pasted 12+ times acrossdecorators/anddecorators_v2/. Only tables that were byte-identical collapsed intoFULL_CASTER/HALF_CASTER/THIRD_CASTER/WARLOCK; the dnd5 paladin/ranger and dnd2024 ranger tables differ at low levels and were deliberately left inline. Long cross-class references (::Dnd5Character::ClassDecorateWrapper::SPELL_SLOTS) now readSpellSlots::FULL_CASTER.Dnd2024::Subclasses::ThirdCasterDecorator—ArcaneTricksterDecoratorandEldritchKnightDecoratorwere identical apart from one string, so each is nowclass X < ThirdCasterDecorator; def spellcasting_class = 'rogue'; end.CharactersContext::{AvatarAttaching, CoinsSyncing, CharacterOptions, ClassSpellFeats}— the three providerUpdateCommands each carried the sameupload_avatar, the same money⇄coins divmod block, the same skill/armor/damage-type enums, and (dnd2024/tlc) the same class-spell attach/detach. The spell module keeps the provider deltas as hooks so TLC's union scope is not narrowed:refresh_spells(it attachesDnd5::Spellrows, not feats).CharactersContext::FeatFiltering— dnd2024 and tlcRefreshFeatswere identical exceptREQUIRED_ATTRIBUTESand the content scope; the module holds the D&D 2024 gating as the default and dnd5 overrides the three predicates that read its older feat shape (selected_featsarray condition, nospeciesorigin). Each class still declares its ownREQUIRED_ATTRIBUTES(tlc'stypefor STI) andfeats.ItemSerializing—Campaigns::ItemSerializerandCharacters::ItemSerializershared every method body; both now just declare their ownATTRIBUTESlist (character addsstate/charges) pluscharges_max.Also folded each
Input.jsx's<Switch>over three near-identical<input>copies into one element with a derivedtype, keeping the numericpattern/inputmodeattributes conditional.Deliberately not touched: the
CharKeeperAppvsHomebrewsAppatom pairs (Input,Select,Label, …) are structurally similar but carry different styling contracts, so sharing them is a UI decision underDESIGN.mdrather than a mechanical dedupe.Link to Devin session: https://app.devin.ai/sessions/cd94a4134a654b11ae74d4ec784f9232
Requested by: @zacgoodwin