Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use squiggly heredocs wherever possible #1761

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rspec/around_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ class AroundBlock < Base
'or `%<arg>s.run`.'

# @!method hook_block(node)
def_node_matcher :hook_block, <<-PATTERN
def_node_matcher :hook_block, <<~PATTERN
(block (send nil? :around sym ?) (args $...) ...)
PATTERN

# @!method hook_numblock(node)
def_node_matcher :hook_numblock, <<-PATTERN
def_node_matcher :hook_numblock, <<~PATTERN
(numblock (send nil? :around sym ?) ...)
PATTERN

# @!method find_arg_usage(node)
def_node_search :find_arg_usage, <<-PATTERN
def_node_search :find_arg_usage, <<~PATTERN
{(send $... {:call :run}) (send _ _ $...) (yield $...) (block-pass $...)}
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/be.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Be < Base
RESTRICT_ON_SEND = Runners.all

# @!method be_without_args(node)
def_node_matcher :be_without_args, <<-PATTERN
def_node_matcher :be_without_args, <<~PATTERN
(send _ #Runners.all $(send nil? :be))
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/be_eq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BeEq < Base
RESTRICT_ON_SEND = %i[eq].freeze

# @!method eq_type_with_identity?(node)
def_node_matcher :eq_type_with_identity?, <<-PATTERN
def_node_matcher :eq_type_with_identity?, <<~PATTERN
(send nil? :eq {true false nil})
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/be_eql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BeEql < Base
RESTRICT_ON_SEND = %i[to].freeze

# @!method eql_type_with_identity(node)
def_node_matcher :eql_type_with_identity, <<-PATTERN
def_node_matcher :eql_type_with_identity, <<~PATTERN
(send _ :to $(send nil? :eql {true false int float sym nil}))
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/be_nil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class BeNil < Base
RESTRICT_ON_SEND = %i[be be_nil].freeze

# @!method be_nil_matcher?(node)
def_node_matcher :be_nil_matcher?, <<-PATTERN
def_node_matcher :be_nil_matcher?, <<~PATTERN
(send nil? :be_nil)
PATTERN

# @!method nil_value_expectation?(node)
def_node_matcher :nil_value_expectation?, <<-PATTERN
def_node_matcher :nil_value_expectation?, <<~PATTERN
(send nil? :be nil)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/before_after_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class BeforeAfterAll < Base
RESTRICT_ON_SEND = Set[:before, :after].freeze

# @!method before_or_after_all(node)
def_node_matcher :before_or_after_all, <<-PATTERN
def_node_matcher :before_or_after_all, <<~PATTERN
$(send _ RESTRICT_ON_SEND (sym {:all :context}))
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/capybara/feature_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class FeatureMethods < Base
}.freeze

# @!method capybara_speak(node)
def_node_matcher :capybara_speak, <<-PATTERN
def_node_matcher :capybara_speak, <<~PATTERN
{#{MAP.keys.map(&:inspect).join(' ')}}
PATTERN

# @!method feature_method(node)
def_node_matcher :feature_method, <<-PATTERN
def_node_matcher :feature_method, <<~PATTERN
(block
$(send #rspec? $#capybara_speak ...)
...)
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rspec/change_by_zero.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ class ChangeByZero < Base
RESTRICT_ON_SEND = CHANGE_METHODS.freeze

# @!method expect_change_with_arguments(node)
def_node_matcher :expect_change_with_arguments, <<-PATTERN
def_node_matcher :expect_change_with_arguments, <<~PATTERN
(send
$(send nil? CHANGE_METHODS ...) :by
(int 0))
PATTERN

# @!method expect_change_with_block(node)
def_node_matcher :expect_change_with_block, <<-PATTERN
def_node_matcher :expect_change_with_block, <<~PATTERN
(send
(block
$(send nil? CHANGE_METHODS)
Expand All @@ -83,7 +83,7 @@ class ChangeByZero < Base
PATTERN

# @!method change_nodes(node)
def_node_search :change_nodes, <<-PATTERN
def_node_search :change_nodes, <<~PATTERN
$(send nil? CHANGE_METHODS ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/context_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ContextMethod < Base
MSG = 'Use `describe` for testing methods.'

# @!method context_method(node)
def_node_matcher :context_method, <<-PATTERN
def_node_matcher :context_method, <<~PATTERN
(block
(send #rspec? :context
${(str #method_name?) (dstr (str #method_name?) ...)}
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/context_wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ContextWording < Base
MSG = 'Context description should match %<patterns>s.'

# @!method context_wording(node)
def_node_matcher :context_wording, <<-PATTERN
def_node_matcher :context_wording, <<~PATTERN
(block (send #rspec? { :context :shared_context } $({str dstr xstr} ...) ...) ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/describe_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DescribeSymbol < Base
RESTRICT_ON_SEND = %i[describe].freeze

# @!method describe_symbol?(node)
def_node_matcher :describe_symbol?, <<-PATTERN
def_node_matcher :describe_symbol?, <<~PATTERN
(send #rspec? :describe $sym ...)
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/described_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DescribedClass < Base
MSG = 'Use `%<replacement>s` instead of `%<src>s`.'

# @!method common_instance_exec_closure?(node)
def_node_matcher :common_instance_exec_closure?, <<-PATTERN
def_node_matcher :common_instance_exec_closure?, <<~PATTERN
(block (send (const nil? {:Class :Module :Struct}) :new ...) ...)
PATTERN

Expand All @@ -75,7 +75,7 @@ class DescribedClass < Base
def_node_matcher :scope_changing_syntax?, '{def class module}'

# @!method described_constant(node)
def_node_matcher :described_constant, <<-PATTERN
def_node_matcher :described_constant, <<~PATTERN
(block (send _ :describe $(const ...) ...) (args) $_)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/example_wording.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ExampleWording < Base
IT_PREFIX = /\Ait /i.freeze

# @!method it_description(node)
def_node_matcher :it_description, <<-PATTERN
def_node_matcher :it_description, <<~PATTERN
(block (send _ :it ${
(str $_)
(dstr (str $_ ) ...)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/excessive_docstring_spacing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ExcessiveDocstringSpacing < Base
MSG = 'Excessive whitespace.'

# @!method example_description(node)
def_node_matcher :example_description, <<-PATTERN
def_node_matcher :example_description, <<~PATTERN
(send _ {#Examples.all #ExampleGroups.all} ${
$str
$(dstr ({str dstr `sym} ...) ...)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/expect_change.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class ExpectChange < Base
RESTRICT_ON_SEND = %i[change].freeze

# @!method expect_change_with_arguments(node)
def_node_matcher :expect_change_with_arguments, <<-PATTERN
def_node_matcher :expect_change_with_arguments, <<~PATTERN
(send nil? :change $_ ({sym str} $_))
PATTERN

# @!method expect_change_with_block(node)
def_node_matcher :expect_change_with_block, <<-PATTERN
def_node_matcher :expect_change_with_block, <<~PATTERN
(block
(send nil? :change)
(args)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/focus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Focus < Base
MSG = 'Focused spec found.'

# @!method focusable_selector?(node)
def_node_matcher :focusable_selector?, <<-PATTERN
def_node_matcher :focusable_selector?, <<~PATTERN
{
#ExampleGroups.regular
#ExampleGroups.skipped
Expand All @@ -68,7 +68,7 @@ class Focus < Base
PATTERN

# @!method metadata(node)
def_node_matcher :metadata, <<-PATTERN
def_node_matcher :metadata, <<~PATTERN
{(send #rspec? #focusable_selector? <$(sym :focus) ...>)
(send #rspec? #focusable_selector? ... (hash <$(pair (sym :focus) true) ...>))}
PATTERN
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/hook_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ class HookArgument < Base
EXPLICIT_MSG = 'Use `%<scope>p` for RSpec hooks.'

# @!method scoped_hook(node)
def_node_matcher :scoped_hook, <<-PATTERN
def_node_matcher :scoped_hook, <<~PATTERN
({block numblock} $(send _ #Hooks.all (sym ${:each :example})) ...)
PATTERN

# @!method unscoped_hook(node)
def_node_matcher :unscoped_hook, <<-PATTERN
def_node_matcher :unscoped_hook, <<~PATTERN
({block numblock} $(send _ #Hooks.all) ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/hooks_before_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HooksBeforeExamples < Base
MSG = 'Move `%<hook>s` above the examples in the group.'

# @!method example_or_group?(node)
def_node_matcher :example_or_group?, <<-PATTERN
def_node_matcher :example_or_group?, <<~PATTERN
{
({block numblock} {
(send #rspec? #ExampleGroups.all ...)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/implicit_block_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ImplicitBlockExpectation < Base
RESTRICT_ON_SEND = %i[is_expected should should_not].freeze

# @!method lambda?(node)
def_node_matcher :lambda?, <<-PATTERN
def_node_matcher :lambda?, <<~PATTERN
{
(send (const nil? :Proc) :new)
(send nil? {:proc :lambda})
Expand All @@ -33,7 +33,7 @@ class ImplicitBlockExpectation < Base
def_node_matcher :lambda_subject?, '(block #lambda? ...)'

# @!method implicit_expect(node)
def_node_matcher :implicit_expect, <<-PATTERN
def_node_matcher :implicit_expect, <<~PATTERN
$(send nil? {:is_expected :should :should_not} ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/implicit_expect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ImplicitExpect < Base
RESTRICT_ON_SEND = Runners.all + %i[should should_not]

# @!method implicit_expect(node)
def_node_matcher :implicit_expect, <<-PATTERN
def_node_matcher :implicit_expect, <<~PATTERN
{
(send nil? ${:should :should_not} ...)
(send (send nil? $:is_expected) #Runners.all ...)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/implicit_subject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ class ImplicitSubject < Base
].freeze

# @!method explicit_unnamed_subject?(node)
def_node_matcher :explicit_unnamed_subject?, <<-PATTERN
def_node_matcher :explicit_unnamed_subject?, <<~PATTERN
(send nil? :expect (send nil? :subject))
PATTERN

# @!method implicit_subject?(node)
def_node_matcher :implicit_subject?, <<-PATTERN
def_node_matcher :implicit_subject?, <<~PATTERN
(send nil? {:should :should_not :is_expected} ...)
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/instance_spy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class InstanceSpy < Base
'with `have_received`.'

# @!method null_double(node)
def_node_search :null_double, <<-PATTERN
def_node_search :null_double, <<~PATTERN
(lvasgn $_
(send
$(send nil? :instance_double
...) :as_null_object))
PATTERN

# @!method have_received_usage(node)
def_node_search :have_received_usage, <<-PATTERN
def_node_search :have_received_usage, <<~PATTERN
(send
(send nil? :expect
(lvar $_)) :to
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/instance_variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ class InstanceVariable < Base
'a method call, or a local variable (if possible).'

# @!method dynamic_class?(node)
def_node_matcher :dynamic_class?, <<-PATTERN
def_node_matcher :dynamic_class?, <<~PATTERN
(block (send (const nil? :Class) :new ...) ...)
PATTERN

# @!method custom_matcher?(node)
def_node_matcher :custom_matcher?, <<-PATTERN
def_node_matcher :custom_matcher?, <<~PATTERN
(block {
(send nil? :matcher sym)
(send (const (const nil? :RSpec) :Matchers) :define sym)
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rspec/iterated_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class IteratedExpectation < Base
'of iterating over an array.'

# @!method each?(node)
def_node_matcher :each?, <<-PATTERN
def_node_matcher :each?, <<~PATTERN
(block
(send ... :each)
(args (arg $_))
Expand All @@ -30,14 +30,14 @@ class IteratedExpectation < Base
PATTERN

# @!method each_numblock?(node)
def_node_matcher :each_numblock?, <<-PATTERN
def_node_matcher :each_numblock?, <<~PATTERN
(numblock
(send ... :each) _ $(...)
)
PATTERN

# @!method expectation?(node)
def_node_matcher :expectation?, <<-PATTERN
def_node_matcher :expectation?, <<~PATTERN
(send (send nil? :expect (lvar %)) :to ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/let_before_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LetBeforeExamples < Base
MSG = 'Move `let` before the examples in the group.'

# @!method example_or_group?(node)
def_node_matcher :example_or_group?, <<-PATTERN
def_node_matcher :example_or_group?, <<~PATTERN
{
(block (send nil? {#ExampleGroups.all #Examples.all} ...) ...)
(send nil? #Includes.examples ...)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/let_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LetSetup < Base
PATTERN

# @!method let_bang(node)
def_node_matcher :let_bang, <<-PATTERN
def_node_matcher :let_bang, <<~PATTERN
{
(block $(send nil? :let! {(sym $_) (str $_)}) ...)
$(send nil? :let! {(sym $_) (str $_)} block_pass)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rspec/message_expectation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MessageExpectation < Base
RESTRICT_ON_SEND = %i[to].freeze

# @!method message_expectation(node)
def_node_matcher :message_expectation, <<-PATTERN
def_node_matcher :message_expectation, <<~PATTERN
(send $(send nil? {:expect :allow} ...) :to #receive_message?)
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/mixin/skip_or_pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module SkipOrPending
extend RuboCop::NodePattern::Macros

# @!method skipped_in_metadata?(node)
def_node_matcher :skipped_in_metadata?, <<-PATTERN
def_node_matcher :skipped_in_metadata?, <<~PATTERN
{
(send _ _ <(sym {:skip :pending}) ...>)
(send _ _ ... (hash <(pair (sym {:skip :pending}) { true str dstr }) ...>))
Expand All @@ -30,7 +30,7 @@ module SkipOrPending
#
# @param node [RuboCop::AST::Node]
# @return [Array<RuboCop::AST::Node>] matching nodes
def_node_matcher :skip_or_pending_inside_block?, <<-PATTERN
def_node_matcher :skip_or_pending_inside_block?, <<~PATTERN
(block <(send nil? {:skip :pending} ...) ...>)
PATTERN
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/multiple_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MultipleExpectations < Base
TRUE = ->(node) { node.true_type? }

# @!method aggregate_failures?(node)
def_node_matcher :aggregate_failures?, <<-PATTERN
def_node_matcher :aggregate_failures?, <<~PATTERN
(block {
(send _ _ <(sym :aggregate_failures) ...>)
(send _ _ ... (hash <(pair (sym :aggregate_failures) %1) ...>))
Expand All @@ -81,7 +81,7 @@ class MultipleExpectations < Base
def_node_matcher :expect?, '(send nil? #Expectations.all ...)'

# @!method aggregate_failures_block?(node)
def_node_matcher :aggregate_failures_block?, <<-PATTERN
def_node_matcher :aggregate_failures_block?, <<~PATTERN
(block (send nil? :aggregate_failures ...) ...)
PATTERN

Expand Down