RUBY-3914 Fix multiple excluded cops#3081
Open
jamis wants to merge 14 commits into
Open
Conversation
Make the unused version-suffix group non-capturing so the regex no longer mixes named and numbered captures.
Use next instead of return when skipping an unsupported URI option, so the iterator continues processing the remaining options instead of returning early from smc_to_ruby.
Use a plain call for is_a?, which already handles nil receivers, so the safe navigation operator is redundant.
The excluded file was deleted as dead code in RUBY-3814, so the todo entry no longer refers to anything.
Replace the unless-wrapped raise in validate_same_origin! with a guard clause, extracting the domain match condition into a local variable for readability.
Use Kernel#loop instead of while true in run_state_machine.
Rename the block parameter from it to doc to avoid shadowing the default block parameter name.
Drop the redundant map(&:to_s) before join, which already stringifies each element.
Include Mongo explicitly into Object instead of using a bare top-level include, keeping the namespace constants available unqualified in the console.
Replace OpenStruct with a keyword-initialized Struct for background thread records.
Build the filter hash with to_h instead of each_with_object.
Use || to select the with_transaction deadline instead of an if/else that returns the condition value in one branch.
Use grep_v to exclude the mongos-unpin fixture instead of reject with a regexp match.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes a set of one-off RuboCop cop exclusions by fixing the underlying single offenses across the driver codebase and test suite, allowing .rubocop_todo.yml to be simplified.
Changes:
- Replace/adjust a handful of Ruby constructs to satisfy RuboCop style/lint cops (e.g.,
OpenStruct→Struct,while true→loop do, guard clauses, safer iterator control flow). - Modernize some collection operations in specs (e.g.,
grep_v,to_h) and minor variable naming cleanups. - Remove the corresponding cop exclusion entries from
.rubocop_todo.yml.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
spec/support/background_thread_registry.rb |
Removes OpenStruct usage by introducing a small Struct record. |
spec/spec_tests/transactions_unified_spec.rb |
Uses grep_v to exclude a specific YAML test file more idiomatically. |
spec/runners/crud/requirement.rb |
Simplifies topology formatting by relying on Array#join coercion. |
spec/mongo/monitoring/command_log_subscriber_spec.rb |
Refactors hash construction to to_h with a block. |
spec/integration/cursor_pinning_spec.rb |
Avoids it block variable assignment to satisfy style cop. |
lib/mongo/uri/options_mapper.rb |
Replaces return inside an iterator with next; removes redundant safe navigation. |
lib/mongo/srv/result.rb |
Refactors conditional into a guard-clause-style return/raise flow. |
lib/mongo/session.rb |
Simplifies deadline selection logic for with_transaction. |
lib/mongo/crypt/context.rb |
Replaces while true with loop do. |
lib/mongo/crypt/binding.rb |
Fixes regex capture grouping to avoid mixed capture types. |
bin/mongo_console |
Changes how Mongo is mixed in so constants are available without qualification. |
.rubocop_todo.yml |
Removes exclusions for the addressed cops. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Each of the following cops were being excluded by our rubocop todo file. Each had only a single recorded violation, so this PR tackles them all in one batch.