MONGOID-5931 Remove dead and unreachable code - #6164
Merged
Conversation
…atedOptions Audited the codebase for dead and unreachable code using RuboCop lint cops, debride, and a grep/AST caller cross-reference. The codebase is largely free of dead code; the one genuine site was an obsolete guard. - clients/factory.rb: drop the `driver_version <=> [2, 13]` guard, which is always true now that the gemspec requires mongo >= 2.18.0, and remove the now-unused driver_version helper. - config.rb: document that DeprecatedOptions::OPTIONS is intentionally empty when no options are deprecated.
Contributor
There was a problem hiding this comment.
Pull request overview
Removes an obsolete, always-true MongoDB driver version guard in the client factory and documents intentional “empty scaffolding” in configuration, as part of auditing Mongoid for dead/unreachable code.
Changes:
- Removed the
driver_versionhelper and themongodriver>= 2.13conditional inMongoid::Clients::Factory#options, making wrapping-library tagging run unconditionally. - Added clarifying documentation to
Mongoid::Config::DeprecatedOptionsexplaining whyOPTIONSmay be empty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/mongoid/clients/factory.rb | Removes an obsolete driver-version gate and simplifies wrapping-library option construction. |
| lib/mongoid/config.rb | Documents that DeprecatedOptions::OPTIONS can be intentionally empty when no options are deprecated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
comandeo-mongo
approved these changes
Jul 9, 2026
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.
Description
MONGOID-5931: audit the codebase for dead and unreachable code and remove/refactor/document each site.
I ran three detection passes:
Lint/UnreachableCode,UselessAssignment,UnusedMethodArgument,UselessMethodDefinition, etc.) — zero offenses across all files.lib/andspec/) narrowed to 5 non-public zero-caller candidates. All 5 were false positives: the_dependent_*!methods inassociation/depending.rbare dispatched viasend("_dependent_#{dependent}!", ...).RUBY_VERSION,BSON::VERSION, and driver-version guards against the gemspec minimums.The main outcome is that the codebase is largely free of dead code. The one genuine site was an obsolete driver-version guard.
Changes
clients/factory.rb: removed theif (driver_version <=> [2, 13]) >= 0guard. The gemspec requiresmongo >= 2.18.0, so this is always true; the body now runs unconditionally. Thedriver_versionhelper (its only caller) is removed.config.rb: documented thatDeprecatedOptions::OPTIONSis intentionally empty when no options are deprecated, so the inert-looking module reads as deliberate scaffolding.Reviewed and intentionally left in place
config.rbRUBY_VERSION < '3.2'and< '3.0'guards — reachable under supported Ruby (gemspec requires >= 2.7).config.rbBSON::VERSION >= '5.0.0'guard — both bson 4 and 5 are supported at runtime.Testing
spec/mongoid/clients/factory_spec.rbandspec/mongoid/config_spec.rbpass against a local replica set (313 examples, 0 failures; 4 pending are libmongocrypt-gated and unrelated). RuboCop is clean.