Skip to content

Commit

Permalink
[Fix rubocop#4124] Apply rubocop -a with Style/SymbolArray cop
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Mar 19, 2017
1 parent 23dffd8 commit 8f3a4b9
Show file tree
Hide file tree
Showing 81 changed files with 273 additions and 273 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -29,7 +29,7 @@ end
desc 'Run RuboCop over itself'
RuboCop::RakeTask.new(:internal_investigation)

task default: [:spec, :ascii_spec, :internal_investigation]
task default: %i(spec ascii_spec internal_investigation)

require 'yard'
YARD::Rake::YardocTask.new
Expand All @@ -43,7 +43,7 @@ task :repl do
end

desc 'Benchmark a cop on given source file/dir'
task :bench_cop, [:cop, :srcpath, :times] do |_task, args|
task :bench_cop, %i(cop srcpath times) do |_task, args|
require 'benchmark'
require 'rubocop'
include RuboCop
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/builder.rb
Expand Up @@ -26,9 +26,9 @@ class Builder < Parser::Builders::Default
PairNode => [:pair],
ResbodyNode => [:resbody],
SendNode => [:send],
UntilNode => [:until, :until_post],
UntilNode => %i(until until_post),
WhenNode => [:when],
WhileNode => [:while, :while_post]
WhileNode => %i(while while_post)
}.freeze

# Generates {Node} from the given information.
Expand Down
34 changes: 17 additions & 17 deletions lib/rubocop/ast/node.rb
Expand Up @@ -21,27 +21,27 @@ module AST
class Node < Parser::AST::Node # rubocop:disable Metrics/ClassLength
include RuboCop::AST::Sexp

COMPARISON_OPERATORS = [:!, :==, :===, :!=, :<=, :>=, :>, :<, :<=>].freeze
COMPARISON_OPERATORS = %i(! == === != <= >= > < <=>).freeze

TRUTHY_LITERALS = [:str, :dstr, :xstr, :int, :float, :sym, :dsym, :array,
:hash, :regexp, :true, :irange, :erange, :complex,
:rational, :regopt].freeze
FALSEY_LITERALS = [:false, :nil].freeze
TRUTHY_LITERALS = %i(str dstr xstr int float sym dsym array
hash regexp true irange erange complex
rational regopt).freeze
FALSEY_LITERALS = %i(false nil).freeze
LITERALS = (TRUTHY_LITERALS + FALSEY_LITERALS).freeze
COMPOSITE_LITERALS = [:dstr, :xstr, :dsym, :array, :hash, :irange,
:erange, :regexp].freeze
COMPOSITE_LITERALS = %i(dstr xstr dsym array hash irange
erange regexp).freeze
BASIC_LITERALS = (LITERALS - COMPOSITE_LITERALS).freeze
MUTABLE_LITERALS = [:str, :dstr, :xstr, :array, :hash].freeze
MUTABLE_LITERALS = %i(str dstr xstr array hash).freeze
IMMUTABLE_LITERALS = (LITERALS - MUTABLE_LITERALS).freeze

VARIABLES = [:ivar, :gvar, :cvar, :lvar].freeze
REFERENCES = [:nth_ref, :back_ref].freeze
KEYWORDS = [:alias, :and, :break, :case, :class, :def, :defs, :defined?,
:kwbegin, :do, :else, :ensure, :for, :if, :module, :next,
:not, :or, :postexe, :redo, :rescue, :retry, :return, :self,
:super, :zsuper, :then, :undef, :until, :when, :while,
:yield].freeze
OPERATOR_KEYWORDS = [:and, :or].freeze
VARIABLES = %i(ivar gvar cvar lvar).freeze
REFERENCES = %i(nth_ref back_ref).freeze
KEYWORDS = %i(alias and break case class def defs defined?
kwbegin do else ensure for if module next
not or postexe redo rescue retry return self
super zsuper then undef until when while
yield).freeze
OPERATOR_KEYWORDS = %i(and or).freeze
SPECIAL_KEYWORDS = %w(__FILE__ __LINE__ __ENCODING__).freeze

# def_matcher can be used to define a pattern-matching method on Node
Expand Down Expand Up @@ -361,7 +361,7 @@ def immutable_literal?
IMMUTABLE_LITERALS.include?(type)
end

[:literal, :basic_literal].each do |kind|
%i(literal basic_literal).each do |kind|
recursive_kind = :"recursive_#{kind}?"
kind_filter = :"#{kind}?"
define_method(recursive_kind) do
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/send_node.rb
Expand Up @@ -6,7 +6,7 @@ module AST
# node when the builder constructs the AST, making its methods available
# to all `send` nodes within RuboCop.
class SendNode < Node
MACRO_PARENT_NODES = [:class, :module].freeze
MACRO_PARENT_NODES = %i(class module).freeze

# The receiving node of the method invocation.
#
Expand Down
30 changes: 15 additions & 15 deletions lib/rubocop/ast/traversal.rb
Expand Up @@ -13,21 +13,21 @@ def walk(node)
nil
end

NO_CHILD_NODES = [:true, :false, :nil, :int, :float, :complex,
:rational, :str, :sym, :regopt, :self, :lvar,
:ivar, :cvar, :gvar, :nth_ref, :back_ref, :cbase,
:arg, :restarg, :blockarg, :shadowarg,
:kwrestarg, :zsuper, :lambda, :redo, :retry].freeze
ONE_CHILD_NODE = [:splat, :kwsplat, :block_pass, :not, :break, :next,
:preexe, :postexe, :match_current_line, :defined?,
:arg_expr].freeze
MANY_CHILD_NODES = [:dstr, :dsym, :xstr, :regexp, :array, :hash, :pair,
:irange, :erange, :mlhs, :masgn, :or_asgn, :and_asgn,
:undef, :alias, :args, :super, :yield, :or, :and,
:while_post, :until_post, :iflipflop, :eflipflop,
:match_with_lvasgn, :begin, :kwbegin, :return].freeze
SECOND_CHILD_ONLY = [:lvasgn, :ivasgn, :cvasgn, :gvasgn, :optarg, :kwarg,
:kwoptarg].freeze
NO_CHILD_NODES = %i(true false nil int float complex
rational str sym regopt self lvar
ivar cvar gvar nth_ref back_ref cbase
arg restarg blockarg shadowarg
kwrestarg zsuper lambda redo retry).freeze
ONE_CHILD_NODE = %i(splat kwsplat block_pass not break next
preexe postexe match_current_line defined?
arg_expr).freeze
MANY_CHILD_NODES = %i(dstr dsym xstr regexp array hash pair
irange erange mlhs masgn or_asgn and_asgn
undef alias args super yield or and
while_post until_post iflipflop eflipflop
match_with_lvasgn begin kwbegin return).freeze
SECOND_CHILD_ONLY = %i(lvasgn ivasgn cvasgn gvasgn optarg kwarg
kwoptarg).freeze

NO_CHILD_NODES.each do |type|
module_eval("def on_#{type}(node); end")
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/format_parameter_mismatch.rb
Expand Up @@ -29,7 +29,7 @@ class FormatParameterMismatch < Cop
SHOVEL = '<<'.freeze
PERCENT = '%'.freeze
PERCENT_PERCENT = '%%'.freeze
STRING_TYPES = [:str, :dstr].freeze
STRING_TYPES = %i(str dstr).freeze
NAMED_INTERPOLATION = /%(?:<\w+>|\{\w+\})/

def on_send(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/literal_in_condition.rb
Expand Up @@ -108,7 +108,7 @@ def check_node(node)
def handle_node(node)
if node.literal?
add_offense(node, :expression)
elsif [:send, :and, :or, :begin].include?(node.type)
elsif %i(send and or begin).include?(node.type)
check_node(node)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/literal_in_interpolation.rb
Expand Up @@ -18,7 +18,7 @@ module Lint
# "result is 10"
class LiteralInInterpolation < Cop
MSG = 'Literal interpolation detected.'.freeze
COMPOSITE = [:array, :hash, :pair, :irange, :erange].freeze
COMPOSITE = %i(array hash pair irange erange).freeze

def on_dstr(node)
node.each_child_node(:begin) do |begin_node|
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/unneeded_splat_expansion.rb
Expand Up @@ -57,7 +57,7 @@ class UnneededSplatExpansion < Cop
PERCENT_I = '%i'.freeze
PERCENT_CAPITAL_I = '%I'.freeze
ARRAY_NEW_PATTERN = '$(send (const nil :Array) :new ...)'.freeze
ASSIGNMENT_TYPES = [:lvasgn, :ivasgn, :cvasgn, :gvasgn].freeze
ASSIGNMENT_TYPES = %i(lvasgn ivasgn cvasgn gvasgn).freeze

def_node_matcher :literal_expansion?, <<-PATTERN
(splat {$({str dstr int float array} ...) (block #{ARRAY_NEW_PATTERN} ...) #{ARRAY_NEW_PATTERN}} ...)
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/lint/unreachable_code.rb
Expand Up @@ -26,8 +26,8 @@ module Lint
class UnreachableCode < Cop
MSG = 'Unreachable code detected.'.freeze

NODE_TYPES = [:return, :next, :break, :retry, :redo].freeze
FLOW_COMMANDS = [:throw, :raise, :fail].freeze
NODE_TYPES = %i(return next break retry redo).freeze
FLOW_COMMANDS = %i(throw raise fail).freeze

def on_begin(node)
expressions = *node
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/useless_setter_call.rb
Expand Up @@ -28,7 +28,7 @@ class UselessSetterCall < Cop
include OnMethodDef

MSG = 'Useless setter call to local variable `%s`.'.freeze
ASSIGNMENT_TYPES = [:lvasgn, :ivasgn, :cvasgn, :gvasgn].freeze
ASSIGNMENT_TYPES = %i(lvasgn ivasgn cvasgn gvasgn).freeze

private

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/metrics/abc_size.rb
Expand Up @@ -11,7 +11,7 @@ class AbcSize < Cop

MSG = 'Assignment Branch Condition size for %s is too high. ' \
'[%.4g/%.4g]'.freeze
BRANCH_NODES = [:send, :csend].freeze
BRANCH_NODES = %i(send csend).freeze
CONDITION_NODES = CyclomaticComplexity::COUNTED_NODES.freeze

private
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/metrics/block_nesting.rb
Expand Up @@ -14,10 +14,10 @@ module Metrics
class BlockNesting < Cop
include ConfigurableMax

NESTING_BLOCKS = [
:case, :if, :while, :while_post,
:until, :until_post, :for, :resbody
].freeze
NESTING_BLOCKS = %i(
case if while while_post
until until_post for resbody
).freeze

def investigate(processed_source)
return unless processed_source.ast
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/metrics/cyclomatic_complexity.rb
Expand Up @@ -17,8 +17,8 @@ class CyclomaticComplexity < Cop
include MethodComplexity

MSG = 'Cyclomatic complexity for %s is too high. [%d/%d]'.freeze
COUNTED_NODES = [:if, :while, :until, :for,
:rescue, :when, :and, :or].freeze
COUNTED_NODES = %i(if while until for
rescue when and or).freeze

private

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/metrics/parameter_lists.rb
Expand Up @@ -28,7 +28,7 @@ def args_count(node)
if count_keyword_args?
node.children.size
else
node.children.count { |a| ![:kwoptarg, :kwarg].include?(a.type) }
node.children.count { |a| !%i(kwoptarg kwarg).include?(a.type) }
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/metrics/perceived_complexity.rb
Expand Up @@ -30,8 +30,8 @@ class PerceivedComplexity < Cop
include MethodComplexity

MSG = 'Perceived complexity for %s is too high. [%d/%d]'.freeze
COUNTED_NODES = [:if, :case, :while, :until,
:for, :rescue, :and, :or].freeze
COUNTED_NODES = %i(if case while until
for rescue and or).freeze

private

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/access_modifier_node.rb
Expand Up @@ -32,7 +32,7 @@ def class_or_module_parent?(node)
if ancestor.block_type?
return true if ancestor.class_constructor?
elsif !ancestor.begin_type?
return [:casgn, :sclass, :class, :module].include?(ancestor.type)
return %i(casgn sclass class module).include?(ancestor.type)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/frozen_string_literal.rb
Expand Up @@ -8,7 +8,7 @@ module FrozenStringLiteral

FROZEN_STRING_LITERAL = '# frozen_string_literal:'.freeze
FROZEN_STRING_LITERAL_ENABLED = '# frozen_string_literal: true'.freeze
FROZEN_STRING_LITERAL_TYPES = [:str, :dstr].freeze
FROZEN_STRING_LITERAL_TYPES = %i(str dstr).freeze

def frozen_string_literal_comment_exists?
leading_comment_lines.any? do |line|
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/on_method_def.rb
Expand Up @@ -37,7 +37,7 @@ def modifier_and_def_on_same_line?(send_node)
!send_node.receiver &&
send_node.method_name != :def &&
send_node.arguments.one? &&
[:def, :defs].include?(send_node.first_argument.type)
%i(def defs).include?(send_node.first_argument.type)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/space_after_punctuation.rb
Expand Up @@ -33,7 +33,7 @@ def space_required_before?(token)
end

def allowed_type?(token)
[:tRPAREN, :tRBRACK, :tPIPE].include?(token.type)
%i(tRPAREN tRBRACK tPIPE).include?(token.type)
end

def space_forbidden_before_rcurly?
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/unused_argument.rb
Expand Up @@ -24,7 +24,7 @@ def check_argument(variable)
end

def autocorrect(node)
return if [:kwarg, :kwoptarg].include?(node.type)
return if %i(kwarg kwoptarg).include?(node.type)

if node.blockarg_type?
lambda do |corrector|
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/cop/offense.rb
Expand Up @@ -7,8 +7,8 @@ class Offense
include Comparable

# @api private
COMPARISON_ATTRIBUTES = [:line, :column, :cop_name,
:message, :severity].freeze
COMPARISON_ATTRIBUTES = %i(line column cop_name
message severity).freeze

# @api public
#
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/performance/casecmp.rb
Expand Up @@ -19,7 +19,7 @@ module Performance
# 'abc'.casecmp(str).zero?
class Casecmp < Cop
MSG = 'Use `casecmp` instead of `%s %s`.'.freeze
CASE_METHODS = [:downcase, :upcase].freeze
CASE_METHODS = %i(downcase upcase).freeze

def_node_matcher :downcase_eq, <<-END
(send
Expand Down
62 changes: 31 additions & 31 deletions lib/rubocop/cop/rails/action_filter.rb
Expand Up @@ -16,37 +16,37 @@ class ActionFilter < Cop

MSG = 'Prefer `%s` over `%s`.'.freeze

FILTER_METHODS = [
:after_filter,
:append_after_filter,
:append_around_filter,
:append_before_filter,
:around_filter,
:before_filter,
:prepend_after_filter,
:prepend_around_filter,
:prepend_before_filter,
:skip_after_filter,
:skip_around_filter,
:skip_before_filter,
:skip_filter
].freeze

ACTION_METHODS = [
:after_action,
:append_after_action,
:append_around_action,
:append_before_action,
:around_action,
:before_action,
:prepend_after_action,
:prepend_around_action,
:prepend_before_action,
:skip_after_action,
:skip_around_action,
:skip_before_action,
:skip_action_callback
].freeze
FILTER_METHODS = %i(
after_filter
append_after_filter
append_around_filter
append_before_filter
around_filter
before_filter
prepend_after_filter
prepend_around_filter
prepend_before_filter
skip_after_filter
skip_around_filter
skip_before_filter
skip_filter
).freeze

ACTION_METHODS = %i(
after_action
append_after_action
append_around_action
append_before_action
around_action
before_action
prepend_after_action
prepend_around_action
prepend_before_action
skip_after_action
skip_around_action
skip_before_action
skip_action_callback
).freeze

minimum_target_rails_version 4.0

Expand Down

0 comments on commit 8f3a4b9

Please sign in to comment.