Skip to content

Conversation

@ydah
Copy link
Member

@ydah ydah commented Oct 2, 2025

Fix offenses for InternalAffairs/NodePatternGroups cop

This cop was added by the following PR.

Offenses:

lib/rubocop/cop/rspec/context_wording.rb:70:63: C: [Corrected] InternalAffairs/NodePatternGroups: Replace str, dstr, xstr in node pattern union with any_str.
          (block (send #rspec? { :context :shared_context } $({str dstr xstr} ...) ...) ...)
                                                              ^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/mixin/final_end_location.rb:10:34: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_str instead of individually listing group types.
            start_node.each_node(:str, :dstr, :xstr)
                                 ^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/mixin/variable.rb:16:15: C: [Corrected] InternalAffairs/NodePatternGroups: Replace sym, dsym in node pattern union with any_sym.
            $({sym str dsym dstr} ...) ...)
              ^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/predicate_matcher.rb:184:36: C: [Corrected] Style/SymbolProc: Pass &:any_str_type? as an argument to select instead of a block.
          matcher.arguments.select do |arg| ...
                                   ^^^^^^^^
lib/rubocop/cop/rspec/predicate_matcher.rb:185:23: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_str instead of individually listing group types.
            arg.type?(:str, :dstr, :xstr)
                      ^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/sort_metadata.rb:33:28: C: [Corrected] InternalAffairs/NodePatternGroups: Replace str, dstr, xstr in node pattern union with any_str.
          (send _ _ _ ... !{hash sym str dstr xstr})
                           ^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/variable_definition.rb:72:22: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_sym instead of individually listing group types.
          node.type?(:sym, :dsym)
                     ^^^^^^^^^^^

282 files inspected, 7 offenses detected, 7 offenses corrected

Before submitting the PR make sure the following are checked:

  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • [-] Added tests.
  • [-] Updated documentation.
  • [-] Added an entry to the CHANGELOG.md if the new code introduces user-observable changes.
  • The build (bundle exec rake) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).

@ydah ydah requested a review from a team as a code owner October 2, 2025 12:27
@bquorning
Copy link
Collaborator

We need spec.add_dependency 'rubocop', '~> 1.81' in the gemspec. That pulls in rubocop-ast v1.47+ which introduced these new methods.

node.str_type?
end

def symbol?(node)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should inline #string? and #symbol? now? They are only used once each.

This cop was added by the following PR.
- rubocop/rubocop#13762

```
Offenses:

lib/rubocop/cop/rspec/context_wording.rb:70:63: C: [Corrected] InternalAffairs/NodePatternGroups: Replace str, dstr, xstr in node pattern union with any_str.
          (block (send #rspec? { :context :shared_context } $({str dstr xstr} ...) ...) ...)
                                                              ^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/mixin/final_end_location.rb:10:34: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_str instead of individually listing group types.
            start_node.each_node(:str, :dstr, :xstr)
                                 ^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/mixin/variable.rb:16:15: C: [Corrected] InternalAffairs/NodePatternGroups: Replace sym, dsym in node pattern union with any_sym.
            $({sym str dsym dstr} ...) ...)
              ^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/predicate_matcher.rb:184:36: C: [Corrected] Style/SymbolProc: Pass &:any_str_type? as an argument to select instead of a block.
          matcher.arguments.select do |arg| ...
                                   ^^^^^^^^
lib/rubocop/cop/rspec/predicate_matcher.rb:185:23: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_str instead of individually listing group types.
            arg.type?(:str, :dstr, :xstr)
                      ^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/sort_metadata.rb:33:28: C: [Corrected] InternalAffairs/NodePatternGroups: Replace str, dstr, xstr in node pattern union with any_str.
          (send _ _ _ ... !{hash sym str dstr xstr})
                           ^^^^^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/rspec/variable_definition.rb:72:22: C: [Corrected] InternalAffairs/NodeTypeGroup: Use :any_sym instead of individually listing group types.
          node.type?(:sym, :dsym)
                     ^^^^^^^^^^^

282 files inspected, 7 offenses detected, 7 offenses corrected
```
## Master (Unreleased)

- Add new cop `RSpec/LeakyLocalVariable`. ([@lovro-bikic])
- Bump RuboCop requirement to +1.81. ([@ydah])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo) added change log

@ydah ydah requested a review from bquorning October 2, 2025 12:51
@ydah ydah merged commit 1872722 into master Oct 2, 2025
27 checks passed
@ydah ydah deleted the fix-offenses branch October 2, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants