Skip to content

Commit

Permalink
Merge pull request rubocop#160 from koic/use_squiggly_heredoc
Browse files Browse the repository at this point in the history
Use squiggly heredoc
  • Loading branch information
koic authored Dec 2, 2019
2 parents 9db2fc9 + b50c142 commit 1ab92f2
Show file tree
Hide file tree
Showing 38 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BelongsTo < Cop
'In most configurations, this is the default and you can omit ' \
'this option altogether'

def_node_matcher :match_belongs_to_with_options, <<-PATTERN
def_node_matcher :match_belongs_to_with_options, <<~PATTERN
(send _ :belongs_to _
(hash <$(pair (sym :required) ${true false}) ...>)
)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/blank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Blank < Cop
# that have a single method call on the left hand side
# (`bar || foo.empty?`) will blow up when checking
# `(send (:nil) :== $_)`.
def_node_matcher :nil_or_empty?, <<-PATTERN
def_node_matcher :nil_or_empty?, <<~PATTERN
(or
{
(send $_ :!)
Expand All @@ -82,7 +82,7 @@ class Blank < Cop

def_node_matcher :defining_blank?, '(def :blank? (args) ...)'

def_node_matcher :unless_present?, <<-PATTERN
def_node_matcher :unless_present?, <<~PATTERN
(:if $(send $_ :present?) {nil? (...)} ...)
PATTERN

Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/rails/create_table_with_timestamps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ module Rails
class CreateTableWithTimestamps < Cop
MSG = 'Add timestamps when creating a new table.'

def_node_matcher :create_table_with_block?, <<-PATTERN
def_node_matcher :create_table_with_block?, <<~PATTERN
(block
(send nil? :create_table ...)
(args (arg _var))
_)
PATTERN

def_node_matcher :create_table_with_timestamps_proc?, <<-PATTERN
def_node_matcher :create_table_with_timestamps_proc?, <<~PATTERN
(send nil? :create_table (sym _) ... (block-pass (sym :timestamps)))
PATTERN

def_node_search :timestamps_included?, <<-PATTERN
def_node_search :timestamps_included?, <<~PATTERN
(send _var :timestamps ...)
PATTERN

def_node_search :created_at_or_updated_at_included?, <<-PATTERN
def_node_search :created_at_or_updated_at_included?, <<~PATTERN
(send _var :datetime
{(sym {:created_at :updated_at})(str {"created_at" "updated_at"})}
...)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module Rails
class Delegate < Cop
MSG = 'Use `delegate` to define delegations.'

def_node_matcher :delegate?, <<-PATTERN
def_node_matcher :delegate?, <<~PATTERN
(def _method_name _args
(send (send nil? _) _ ...))
PATTERN
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/delegate_allow_blank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Rails
class DelegateAllowBlank < Cop
MSG = '`allow_blank` is not a valid option, use `allow_nil`.'

def_node_matcher :allow_blank_option, <<-PATTERN
def_node_matcher :allow_blank_option, <<~PATTERN
(send nil? :delegate _ (hash <$(pair (sym :allow_blank) true) ...>))
PATTERN

Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rails/environment_comparison.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ class EnvironmentComparison < Cop
SYM_MSG = 'Do not compare `Rails.env` with a symbol, it will always ' \
'evaluate to `false`.'

def_node_matcher :environment_str_comparison?, <<-PATTERN
def_node_matcher :environment_str_comparison?, <<~PATTERN
(send
(send (const {nil? cbase} :Rails) :env)
:==
$str
)
PATTERN

def_node_matcher :environment_sym_comparison?, <<-PATTERN
def_node_matcher :environment_sym_comparison?, <<~PATTERN
(send
(send (const {nil? cbase} :Rails) :env)
:==
Expand Down Expand Up @@ -59,7 +59,7 @@ def replacement(node)
"#{node.receiver.source}.#{content(node.first_argument)}?"
end

def_node_matcher :content, <<-PATTERN
def_node_matcher :content, <<~PATTERN
({str sym} $_)
PATTERN
end
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rails/file_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ class FilePath < Cop
MSG_ARGUMENTS = 'Please use `Rails.root.join(\'path\', \'to\')` ' \
'instead.'

def_node_matcher :file_join_nodes?, <<-PATTERN
def_node_matcher :file_join_nodes?, <<~PATTERN
(send (const nil? :File) :join ...)
PATTERN

def_node_search :rails_root_nodes?, <<-PATTERN
def_node_search :rails_root_nodes?, <<~PATTERN
(send (const nil? :Rails) :root)
PATTERN

def_node_matcher :rails_root_join_nodes?, <<-PATTERN
def_node_matcher :rails_root_join_nodes?, <<~PATTERN
(send (send (const nil? :Rails) :root) :join ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/find_by.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FindBy < Cop
MSG = 'Use `find_by` instead of `where.%<method>s`.'
TARGET_SELECTORS = %i[first take].freeze

def_node_matcher :where_first?, <<-PATTERN
def_node_matcher :where_first?, <<~PATTERN
(send ({send csend} _ :where ...) {:first :take})
PATTERN

Expand Down
12 changes: 6 additions & 6 deletions lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ module Rails
class HasManyOrHasOneDependent < Cop
MSG = 'Specify a `:dependent` option.'

def_node_search :active_resource_class?, <<-PATTERN
def_node_search :active_resource_class?, <<~PATTERN
(const (const nil? :ActiveResource) :Base)
PATTERN

def_node_matcher :association_without_options?, <<-PATTERN
def_node_matcher :association_without_options?, <<~PATTERN
(send nil? {:has_many :has_one} _)
PATTERN

def_node_matcher :association_with_options?, <<-PATTERN
def_node_matcher :association_with_options?, <<~PATTERN
(send nil? {:has_many :has_one} _ (hash $...))
PATTERN

def_node_matcher :dependent_option?, <<-PATTERN
def_node_matcher :dependent_option?, <<~PATTERN
(pair (sym :dependent) !nil)
PATTERN

def_node_matcher :present_option?, <<-PATTERN
def_node_matcher :present_option?, <<~PATTERN
(pair (sym :through) !nil)
PATTERN

def_node_matcher :with_options_block, <<-PATTERN
def_node_matcher :with_options_block, <<~PATTERN
(block
(send nil? :with_options
(hash $...))
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/http_positional_arguments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HttpPositionalArguments < Cop

minimum_target_rails_version 5.0

def_node_matcher :http_request?, <<-PATTERN
def_node_matcher :http_request?, <<~PATTERN
(send nil? {#{HTTP_METHODS.map(&:inspect).join(' ')}} !nil? $_ ...)
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/http_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ module Rails
class HttpStatus < Cop
include ConfigurableEnforcedStyle

def_node_matcher :http_status, <<-PATTERN
def_node_matcher :http_status, <<~PATTERN
{
(send nil? {:render :redirect_to} _ $hash)
(send nil? {:render :redirect_to} $hash)
}
PATTERN

def_node_matcher :status_code, <<-PATTERN
def_node_matcher :status_code, <<~PATTERN
(hash <(pair (sym :status) ${int sym}) ...>)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class IgnoredSkipActionFilterOption < Cop
:skip_action_callback
].freeze

def_node_matcher :filter_options, <<-PATTERN
def_node_matcher :filter_options, <<~PATTERN
(send
nil?
{#{FILTERS.join(' ')}}
Expand Down
18 changes: 9 additions & 9 deletions lib/rubocop/cop/rails/inverse_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,39 @@ class InverseOf < Cop
NIL_MSG = 'You specified `inverse_of: nil`, you probably meant to ' \
'use `inverse_of: false`.'

def_node_matcher :association_recv_arguments, <<-PATTERN
def_node_matcher :association_recv_arguments, <<~PATTERN
(send $_ {:has_many :has_one :belongs_to} _ $...)
PATTERN

def_node_matcher :options_from_argument, <<-PATTERN
def_node_matcher :options_from_argument, <<~PATTERN
(hash $...)
PATTERN

def_node_matcher :conditions_option?, <<-PATTERN
def_node_matcher :conditions_option?, <<~PATTERN
(pair (sym :conditions) !nil)
PATTERN

def_node_matcher :through_option?, <<-PATTERN
def_node_matcher :through_option?, <<~PATTERN
(pair (sym :through) !nil)
PATTERN

def_node_matcher :polymorphic_option?, <<-PATTERN
def_node_matcher :polymorphic_option?, <<~PATTERN
(pair (sym :polymorphic) !nil)
PATTERN

def_node_matcher :as_option?, <<-PATTERN
def_node_matcher :as_option?, <<~PATTERN
(pair (sym :as) !nil)
PATTERN

def_node_matcher :foreign_key_option?, <<-PATTERN
def_node_matcher :foreign_key_option?, <<~PATTERN
(pair (sym :foreign_key) !nil)
PATTERN

def_node_matcher :inverse_of_option?, <<-PATTERN
def_node_matcher :inverse_of_option?, <<~PATTERN
(pair (sym :inverse_of) !nil)
PATTERN

def_node_matcher :inverse_of_nil_option?, <<-PATTERN
def_node_matcher :inverse_of_nil_option?, <<~PATTERN
(pair (sym :inverse_of) nil)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/lexically_scoped_action_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class LexicallyScopedActionFilter < Cop
:skip_action_callback
].freeze

def_node_matcher :only_or_except_filter_methods, <<-PATTERN
def_node_matcher :only_or_except_filter_methods, <<~PATTERN
(send
nil?
{#{FILTERS.join(' ')}}
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rails/link_to_blank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module Rails
class LinkToBlank < Cop
MSG = 'Specify a `:rel` option containing noopener.'

def_node_matcher :blank_target?, <<-PATTERN
def_node_matcher :blank_target?, <<~PATTERN
(pair {(sym :target) (str "target")} {(str "_blank") (sym :_blank)})
PATTERN

def_node_matcher :includes_noopener?, <<-PATTERN
def_node_matcher :includes_noopener?, <<~PATTERN
(pair {(sym :rel) (str "rel")} ({str sym} #contains_noopener?))
PATTERN

def_node_matcher :rel_node?, <<-PATTERN
def_node_matcher :rel_node?, <<~PATTERN
(pair {(sym :rel) (str "rel")} (str _))
PATTERN

Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/rails/not_null_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ module Rails
class NotNullColumn < Cop
MSG = 'Do not add a NOT NULL column without a default value.'

def_node_matcher :add_not_null_column?, <<-PATTERN
def_node_matcher :add_not_null_column?, <<~PATTERN
(send nil? :add_column _ _ _ (hash $...))
PATTERN

def_node_matcher :add_not_null_reference?, <<-PATTERN
def_node_matcher :add_not_null_reference?, <<~PATTERN
(send nil? :add_reference _ _ (hash $...))
PATTERN

def_node_matcher :null_false?, <<-PATTERN
def_node_matcher :null_false?, <<~PATTERN
(pair (sym :null) (false))
PATTERN

def_node_matcher :default_option?, <<-PATTERN
def_node_matcher :default_option?, <<~PATTERN
(pair (sym :default) !nil)
PATTERN

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ class Output < Cop
MSG = 'Do not write to stdout. ' \
"Use Rails's logger if you want to log."

def_node_matcher :output?, <<-PATTERN
def_node_matcher :output?, <<~PATTERN
(send nil? {:ap :p :pp :pretty_print :print :puts} ...)
PATTERN

def_node_matcher :io_output?, <<-PATTERN
def_node_matcher :io_output?, <<~PATTERN
(send
{
(gvar #match_gvar?)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/presence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Presence < Cop

MSG = 'Use `%<prefer>s` instead of `%<current>s`.'

def_node_matcher :redundant_receiver_and_other, <<-PATTERN
def_node_matcher :redundant_receiver_and_other, <<~PATTERN
{
(if
(send $_recv :present?)
Expand All @@ -57,7 +57,7 @@ class Presence < Cop
}
PATTERN

def_node_matcher :redundant_negative_receiver_and_other, <<-PATTERN
def_node_matcher :redundant_negative_receiver_and_other, <<~PATTERN
{
(if
(send (send $_recv :present?) :!)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rails/present.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Present < Cop
MSG_UNLESS_BLANK = 'Use `if %<prefer>s` instead of ' \
'`%<current>s`.'

def_node_matcher :exists_and_not_empty?, <<-PATTERN
def_node_matcher :exists_and_not_empty?, <<~PATTERN
(and
{
(send (send $_ :nil?) :!)
Expand All @@ -66,7 +66,7 @@ class Present < Cop

def_node_matcher :not_blank?, '(send (send $_ :blank?) :!)'

def_node_matcher :unless_blank?, <<-PATTERN
def_node_matcher :unless_blank?, <<~PATTERN
(:if $(send $_ :blank?) {nil? (...)} ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/rake_environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module Rails
class RakeEnvironment < Cop
MSG = 'Set `:environment` task as a dependency to all rake task.'

def_node_matcher :task_definition?, <<-PATTERN
def_node_matcher :task_definition?, <<~PATTERN
(send nil? :task ...)
PATTERN

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/rails/read_write_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Rails
class ReadWriteAttribute < Cop
MSG = 'Prefer `%<prefer>s` over `%<current>s`.'

def_node_matcher :read_write_attribute?, <<-PATTERN
def_node_matcher :read_write_attribute?, <<~PATTERN
{
(send nil? :read_attribute _)
(send nil? :write_attribute _ _)
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class RedundantReceiverInWithOptions < Cop

MSG = 'Redundant receiver in `with_options`.'

def_node_matcher :with_options?, <<-PATTERN
def_node_matcher :with_options?, <<~PATTERN
(block
(send nil? :with_options
(...))
Expand All @@ -71,11 +71,11 @@ class RedundantReceiverInWithOptions < Cop
$_body)
PATTERN

def_node_search :all_block_nodes_in, <<-PATTERN
def_node_search :all_block_nodes_in, <<~PATTERN
(block ...)
PATTERN

def_node_search :all_send_nodes_in, <<-PATTERN
def_node_search :all_send_nodes_in, <<~PATTERN
(send ...)
PATTERN

Expand Down
Loading

0 comments on commit 1ab92f2

Please sign in to comment.