Replace virtus with an internal attributes module#1
Closed
pnomolos wants to merge 1 commit into
Closed
Conversation
The `virtus` gem is unmaintained and drags in a chain of abandoned transitive dependencies: axiom-types, coercible, descendants_tracker, ice_nine, and the deprecated thread_safe (superseded by concurrent-ruby). RubyCritic only used a tiny slice of virtus -- an `attribute` DSL on two classes -- so carrying that whole tree was not justified. Introduce a small internal `RubyCritic::Attributes` module that reproduces only the used subset: an `attribute` class macro with reader/writer generation, type coercion (Float/Integer/Array/Symbol), per-instance duped mutable defaults, and a hash-accepting initializer. `Smell` and `AnalysedModule` now include it instead of `Virtus.model`. Drop the `virtus` runtime dependency and move `ostruct` to a development dependency (only referenced in tests). Update `.reek.yml` and the changelog accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by the upstream PR against whitesmith/rubycritic (whitesmith#574). |
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.
Why
virtusis unmaintained and pulls in a chain of abandoned gems(
axiom-types,coercible,descendants_tracker,ice_nine) plus thedeprecated
thread_safe(superseded by concurrent-ruby). RubyCritic onlyused a tiny slice of virtus -- an
attributeDSL on two classes -- socarrying that whole dependency tree wasn't justified.
A custom module was chosen over dry-rb deliberately: dry-struct would just
trade one transitive tree for another (
dry-core,dry-types,dry-logic,zeitwerk...), which runs counter to the goal and to the codebase's recentdirection of shedding/leaning out dependencies (e.g. preferring
prismoverthe
parsergem, dropping cucumber).What changed
RubyCritic::Attributesmodule reproducing only the usedvirtus subset: an
attributemacro, type coercion, per-instance dupeddefaults, and a hash-accepting initializer.
SmellandAnalysedModulenowinclude RubyCritic::Attributesinsteadof
Virtus.model.virtusruntime dependency removed;ostructmoved to a developmentdependency (only used in tests).
.reek.ymlandCHANGELOG.mdupdated accordingly.Verification
rakesuite is green: tests, reek (0 warnings), and rubocop (nooffenses).
Float::INFINITY/Symbol defaults preserved, coercion applied on writers,and method overrides intact.
Checklist
🤖 Generated with Claude Code