From fad7827ddbcb37b473fbae6606474bd206431eb6 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Wed, 27 Feb 2019 01:00:16 +0200 Subject: [PATCH] rubocop: fix offences of the Style/Alias cop --- .rubocop_todo.yml | 13 ------------- lib/pry/command.rb | 14 +++++++------- lib/pry/command_set.rb | 8 ++++---- lib/pry/config/behavior.rb | 4 ++-- lib/pry/wrapped_module.rb | 4 ++-- lib/pry/wrapped_module/candidate.rb | 4 ++-- spec/method_spec.rb | 4 ++-- 7 files changed, 19 insertions(+), 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a80edf86..fe0c72e1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -192,19 +192,6 @@ Style/AccessModifierDeclarations: - 'spec/helper.rb' - 'spec/method/patcher_spec.rb' -# Offense count: 19 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: prefer_alias, prefer_alias_method -Style/Alias: - Exclude: - - 'lib/pry/command.rb' - - 'lib/pry/command_set.rb' - - 'lib/pry/config/behavior.rb' - - 'lib/pry/wrapped_module.rb' - - 'lib/pry/wrapped_module/candidate.rb' - - 'spec/method_spec.rb' - # Offense count: 2 # Configuration parameters: AllowedChars. Style/AsciiComments: diff --git a/lib/pry/command.rb b/lib/pry/command.rb index 5cdfd77f..68dee7ab 100644 --- a/lib/pry/command.rb +++ b/lib/pry/command.rb @@ -45,8 +45,8 @@ class Pry @command_options end # backward compatibility - alias_method :options, :command_options - alias_method :options=, :command_options= + alias options command_options + alias options= command_options= # Define or get the command's banner def banner(arg = nil) @@ -70,12 +70,12 @@ class Pry def source_file Array(block.source_location).first end - alias_method :file, :source_file + alias file source_file def source_line Array(block.source_location).last end - alias_method :line, :source_line + alias line source_line def default_options(match) { @@ -514,7 +514,7 @@ WARN # Create subclasses using {Pry::CommandSet#command}. class BlockCommand < Command # backwards compatibility - alias_method :opts, :context + alias opts context # Call the block that was registered with this command. # @param [Array] args The arguments passed @@ -564,12 +564,12 @@ WARN def source_file source_object.source_file end - alias_method :file, :source_file + alias file source_file def source_line source_object.source_line end - alias_method :line, :source_line + alias line source_line private diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb index 47d94f0c..66c036fa 100644 --- a/lib/pry/command_set.rb +++ b/lib/pry/command_set.rb @@ -81,7 +81,7 @@ class Pry @commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block) end - alias_method :command, :block_command + alias command block_command # Defines a new Pry command class. # @@ -275,12 +275,12 @@ class Pry def list_commands @commands.keys end - alias_method :keys, :list_commands + alias keys list_commands def to_hash @commands.dup end - alias_method :to_h, :to_hash + alias to_h to_hash # Find a command that matches the given line # @param [String] pattern The line that might be a command invocation @@ -292,7 +292,7 @@ class Pry command.match_score(pattern) end end - alias_method :find_command, :[] + alias find_command [] # # Re-assign the command found at _pattern_ with _command_. diff --git a/lib/pry/config/behavior.rb b/lib/pry/config/behavior.rb index cd92007a..572c2dd9 100644 --- a/lib/pry/config/behavior.rb +++ b/lib/pry/config/behavior.rb @@ -226,7 +226,7 @@ class Pry @lookup == __try_convert_to_hash(other) end - alias_method :eql?, :== + alias eql? == # # @example @@ -303,7 +303,7 @@ class Pry def to_hash @lookup.dup end - alias_method :to_h, :to_hash + alias to_h to_hash def inspect key_str = keys.map { |key| "'#{key}'" }.join(",") diff --git a/lib/pry/wrapped_module.rb b/lib/pry/wrapped_module.rb index 59879985..563b9087 100644 --- a/lib/pry/wrapped_module.rb +++ b/lib/pry/wrapped_module.rb @@ -169,14 +169,14 @@ class Pry def file Array(source_location).first end - alias_method :source_file, :file + alias source_file file # @return [Fixnum, nil] The associated line for the module (i.e # the primary candidate: highest ranked monkeypatch). def line Array(source_location).last end - alias_method :source_line, :line + alias source_line line # Returns documentation for the module. # This documentation is for the primary candidate, if diff --git a/lib/pry/wrapped_module/candidate.rb b/lib/pry/wrapped_module/candidate.rb index d5dd5c61..7f99a7cb 100644 --- a/lib/pry/wrapped_module/candidate.rb +++ b/lib/pry/wrapped_module/candidate.rb @@ -12,11 +12,11 @@ class Pry # @return [String] The file where the module definition is located. attr_reader :file - alias_method :source_file, :file + alias source_file file # @return [Fixnum] The line where the module definition is located. attr_reader :line - alias_method :source_line, :line + alias source_line line # Methods to delegate to associated `Pry::WrappedModule # instance`. diff --git a/spec/method_spec.rb b/spec/method_spec.rb index 9e9ca58a..49772f4c 100644 --- a/spec/method_spec.rb +++ b/spec/method_spec.rb @@ -186,7 +186,7 @@ describe Pry::Method do @nips = "nips" binding end - alias paella borscht + alias_method :paella, :borscht def borscht() paella end end @@ -511,7 +511,7 @@ describe Pry::Method do def eat end - alias fress eat + alias_method :fress, :eat alias_method :omnomnom, :fress def eruct