Skip to content

Commit

Permalink
Extract static array into constant in RedundantSelf cop
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored and bbatsov committed Jun 14, 2020
1 parent 928abea commit 41b5b5e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/rubocop/cop/style/redundant_self.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ module Style
class RedundantSelf < Cop
MSG = 'Redundant `self` detected.'
KERNEL_METHODS = Kernel.methods(false)
KEYWORDS = %i[alias and begin break case class def defined? do
else elsif end ensure false for if in module
next nil not or redo rescue retry return self
super then true undef unless until when while
yield __FILE__ __LINE__ __ENCODING__].freeze

def self.autocorrect_incompatible_with
[ColonMethodCall]
Expand Down Expand Up @@ -131,7 +136,7 @@ def allowed_send_node?(node)

def regular_method_call?(node)
!(node.operator_method? ||
keyword?(node.method_name) ||
KEYWORDS.include?(node.method_name) ||
node.camel_case_method? ||
node.setter_method? ||
node.implicit_call?)
Expand All @@ -142,14 +147,6 @@ def on_argument(node)
@local_variables_scopes[node] << name
end

def keyword?(method_name)
%i[alias and begin break case class def defined? do
else elsif end ensure false for if in module
next nil not or redo rescue retry return self
super then true undef unless until when while
yield __FILE__ __LINE__ __ENCODING__].include?(method_name)
end

def allow_self(node)
return unless node.send_type? && node.self_receiver?

Expand Down

0 comments on commit 41b5b5e

Please sign in to comment.