Tune ruby rails explainers - #78
Merged
Merged
Conversation
Rails snapshots produced noisy, often-wrong findings: Ruby modules are directories and coupling is synthesized from autoloaded constant references, so the module graph is nearly complete and bidirectional and the generic OOP/hexagonal explainers over-fire. - layers: re-level the Rails pattern to two tiers (delivery=controllers/ views, domain=everything else) so idiomatic model->service/job/helper references are no longer "violations"; only domain->delivery smells fire. Also classify interactors/presenters/serializers/notifiers/types. - god-class, hotspots: dedupe candidates by symbol name (a constant reopened across N files no longer yields N identical findings, e.g. RailsAdmin::Config::Actions x50) and cap god-class output at 25. - cycles: report SCCs larger than 8 modules as one low-confidence "highly coupled module cluster" note instead of a confidence-1.0 cyclic-dependency alarm; in autoloaded Rails a giant SCC is expected. - ruby extractor: tag synthetic coupling edges with coupling_kind and exclude ActiveRecord associations from cycle detection (has_many/ belongs_to pairs are bidirectional by nature); add framework constants (I18n, Rails, Logger, GlobalID, Mime) to the fan-in ignore list. - bump cacheVersion v94->v95 (+ cachecov coverage entry).
… hotspots) Follow-up to the layers/cycles tuning: three explainers still misfired on autoloaded, framework-heavy, public-by-default codebases. - dependency-depth: count an oversized coupling cluster (SCC) as one logical layer instead of its full size, so a giant autoload cluster no longer reports every chain through it as an extreme depth. - god-class, hotspots: exclude framework/base scaffolding classes (Application*, *BaseController, *::Base) via a Ruby-gated helper -- high fan-in through inheritance isn't a god class. - exported-surface: skip Ruby symbols; public-by-default makes the exported/total ratio ~100% and uninformative. - explain hotspots: compute module blast radius over the module graph instead of an all-node reverse count that saturates in a densely-coupled graph. Explainer-only, no extractor change, so no cacheVersion bump.
The depth explainer condenses SCCs and takes the longest path. After the earlier tuning an oversized autoload cluster counted as one node, so chains were honest but low-value: their length came mostly from threading through the one giant cluster (already reported by the cycles explainer), and they were near-duplicates sharing that cluster spine. Make an oversized cluster a weight-0 sink: drop its outgoing edges in the condensation and count it as 0 depth, so a chain earns depth only from genuine, distinct-module layering above/outside the cluster. Real deep layering still reports; cluster-manufactured depth no longer does.
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.
No description provided.