Skip to content

Commit

Permalink
Merge pull request #1036 from rubocop-hq/use-the-new-multiple-terms-u…
Browse files Browse the repository at this point in the history
…nion-node-pattern-syntax

Use the new Node Pattern multiple term union syntax
  • Loading branch information
pirj authored Oct 7, 2020
2 parents f1f369d + 72a91ee commit 300943e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/around_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AroundBlock < Base
'or `%<arg>s.run`.'

def_node_matcher :hook, <<-PATTERN
(block {(send nil? :around) (send nil? :around sym)} (args $...) ...)
(block (send nil? :around sym ?) (args $...) ...)
PATTERN

def_node_search :find_arg_usage, <<-PATTERN
Expand Down
3 changes: 1 addition & 2 deletions lib/rubocop/cop/rspec/implicit_block_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ImplicitBlockExpectation < Base
def_node_matcher :lambda?, <<-PATTERN
{
(send (const nil? :Proc) :new)
(send nil? :proc)
(send nil? :lambda)
(send nil? {:proc :lambda})
}
PATTERN

Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/rspec/subject_stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class SubjectStub < Base
#
# @yield [Symbol] subject name
def_node_matcher :subject, <<-PATTERN
{
(block (send nil? :subject (sym $_)) args ...)
(block (send nil? $:subject) args ...)
}
(block
(send nil?
{:subject (sym $_) | $:subject}
) args ...)
PATTERN

# @!method message_expectation?(node, method_name)
Expand Down
6 changes: 1 addition & 5 deletions lib/rubocop/rspec/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ module RSpec
class Hook < Concept
def_node_matcher :extract_metadata, <<~PATTERN
(block
{
(send _ _ #valid_scope? $...)
(send _ _ $...)
}
...
(send _ _ #valid_scope? ? $...) ...
)
PATTERN

Expand Down
1 change: 1 addition & 0 deletions rubocop-rspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
}

spec.add_runtime_dependency 'rubocop', '~> 0.87'
spec.add_runtime_dependency 'rubocop-ast', '~> 0.7.1'

spec.add_development_dependency 'rack'
spec.add_development_dependency 'rake'
Expand Down

0 comments on commit 300943e

Please sign in to comment.