1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

rubocop: fix offences of the Style/Alias cop

This commit is contained in:
Kyrylo Silin 2019-02-27 01:00:16 +02:00
parent 218fac79b7
commit fad7827ddb
7 changed files with 19 additions and 32 deletions

View file

@ -192,19 +192,6 @@ Style/AccessModifierDeclarations:
- 'spec/helper.rb' - 'spec/helper.rb'
- 'spec/method/patcher_spec.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 # Offense count: 2
# Configuration parameters: AllowedChars. # Configuration parameters: AllowedChars.
Style/AsciiComments: Style/AsciiComments:

View file

@ -45,8 +45,8 @@ class Pry
@command_options @command_options
end end
# backward compatibility # backward compatibility
alias_method :options, :command_options alias options command_options
alias_method :options=, :command_options= alias options= command_options=
# Define or get the command's banner # Define or get the command's banner
def banner(arg = nil) def banner(arg = nil)
@ -70,12 +70,12 @@ class Pry
def source_file def source_file
Array(block.source_location).first Array(block.source_location).first
end end
alias_method :file, :source_file alias file source_file
def source_line def source_line
Array(block.source_location).last Array(block.source_location).last
end end
alias_method :line, :source_line alias line source_line
def default_options(match) def default_options(match)
{ {
@ -514,7 +514,7 @@ WARN
# Create subclasses using {Pry::CommandSet#command}. # Create subclasses using {Pry::CommandSet#command}.
class BlockCommand < Command class BlockCommand < Command
# backwards compatibility # backwards compatibility
alias_method :opts, :context alias opts context
# Call the block that was registered with this command. # Call the block that was registered with this command.
# @param [Array<String>] args The arguments passed # @param [Array<String>] args The arguments passed
@ -564,12 +564,12 @@ WARN
def source_file def source_file
source_object.source_file source_object.source_file
end end
alias_method :file, :source_file alias file source_file
def source_line def source_line
source_object.source_line source_object.source_line
end end
alias_method :line, :source_line alias line source_line
private private

View file

@ -81,7 +81,7 @@ class Pry
@commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block) @commands[match] = Pry::BlockCommand.subclass(match, description, options, helper_module, &block)
end end
alias_method :command, :block_command alias command block_command
# Defines a new Pry command class. # Defines a new Pry command class.
# #
@ -275,12 +275,12 @@ class Pry
def list_commands def list_commands
@commands.keys @commands.keys
end end
alias_method :keys, :list_commands alias keys list_commands
def to_hash def to_hash
@commands.dup @commands.dup
end end
alias_method :to_h, :to_hash alias to_h to_hash
# Find a command that matches the given line # Find a command that matches the given line
# @param [String] pattern The line that might be a command invocation # @param [String] pattern The line that might be a command invocation
@ -292,7 +292,7 @@ class Pry
command.match_score(pattern) command.match_score(pattern)
end end
end end
alias_method :find_command, :[] alias find_command []
# #
# Re-assign the command found at _pattern_ with _command_. # Re-assign the command found at _pattern_ with _command_.

View file

@ -226,7 +226,7 @@ class Pry
@lookup == __try_convert_to_hash(other) @lookup == __try_convert_to_hash(other)
end end
alias_method :eql?, :== alias eql? ==
# #
# @example # @example
@ -303,7 +303,7 @@ class Pry
def to_hash def to_hash
@lookup.dup @lookup.dup
end end
alias_method :to_h, :to_hash alias to_h to_hash
def inspect def inspect
key_str = keys.map { |key| "'#{key}'" }.join(",") key_str = keys.map { |key| "'#{key}'" }.join(",")

View file

@ -169,14 +169,14 @@ class Pry
def file def file
Array(source_location).first Array(source_location).first
end end
alias_method :source_file, :file alias source_file file
# @return [Fixnum, nil] The associated line for the module (i.e # @return [Fixnum, nil] The associated line for the module (i.e
# the primary candidate: highest ranked monkeypatch). # the primary candidate: highest ranked monkeypatch).
def line def line
Array(source_location).last Array(source_location).last
end end
alias_method :source_line, :line alias source_line line
# Returns documentation for the module. # Returns documentation for the module.
# This documentation is for the primary candidate, if # This documentation is for the primary candidate, if

View file

@ -12,11 +12,11 @@ class Pry
# @return [String] The file where the module definition is located. # @return [String] The file where the module definition is located.
attr_reader :file attr_reader :file
alias_method :source_file, :file alias source_file file
# @return [Fixnum] The line where the module definition is located. # @return [Fixnum] The line where the module definition is located.
attr_reader :line attr_reader :line
alias_method :source_line, :line alias source_line line
# Methods to delegate to associated `Pry::WrappedModule # Methods to delegate to associated `Pry::WrappedModule
# instance`. # instance`.

View file

@ -186,7 +186,7 @@ describe Pry::Method do
@nips = "nips" @nips = "nips"
binding binding
end end
alias paella borscht alias_method :paella, :borscht
def borscht() paella end def borscht() paella end
end end
@ -511,7 +511,7 @@ describe Pry::Method do
def eat def eat
end end
alias fress eat alias_method :fress, :eat
alias_method :omnomnom, :fress alias_method :omnomnom, :fress
def eruct def eruct