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

Merge pull request #1801 from pry/rubocop-lint-unused-method-argument

rubocop: fix offences of the Lint/UnusedMethodArgument cop
This commit is contained in:
Kyrylo Silin 2018-10-14 15:58:34 +08:00 committed by GitHub
commit 13e9c39562
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 25 additions and 30 deletions

View file

@ -677,12 +677,6 @@ Lint/UnneededRequireStatement:
Lint/UnusedBlockArgument: Lint/UnusedBlockArgument:
Enabled: false Enabled: false
# Offense count: 22
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Enabled: false
# Offense count: 1 # Offense count: 1
Lint/UselessAssignment: Lint/UselessAssignment:
Exclude: Exclude:

View file

@ -297,9 +297,8 @@ class Pry
# Get the (approximate) Module.nesting at the give line number. # Get the (approximate) Module.nesting at the give line number.
# #
# @param [Integer] line_number line number starting from 1 # @param [Integer] line_number line number starting from 1
# @param [Module] top_module the module in which this code exists
# @return [Array<Module>] a list of open modules. # @return [Array<Module>] a list of open modules.
def nesting_at(line_number, top_module = Object) def nesting_at(line_number)
Pry::Indent.nesting_at(raw, line_number) Pry::Indent.nesting_at(raw, line_number)
end end

View file

@ -466,9 +466,9 @@ class Pry
# Generate completions for this command # Generate completions for this command
# #
# @param [String] search The line typed so far # @param [String] _search The line typed so far
# @return [Array<String>] Completion words # @return [Array<String>] Completion words
def complete(search) def complete(_search)
[] []
end end

View file

@ -19,16 +19,15 @@ class Pry
def process def process
raise CommandError, "No input to amend." if eval_string.empty? raise CommandError, "No input to amend." if eval_string.empty?
eval_string.replace amended_input(eval_string) eval_string.replace(amend_input)
run "fix-indent" run "fix-indent"
run "show-input" run "show-input"
end end
private private
# @param [String] string The string to amend.
# @return [String] A new string with the amendments applied to it. # @return [String] A new string with the amendments applied to it.
def amended_input(string) def amend_input
input_array = eval_string.each_line.to_a input_array = eval_string.each_line.to_a
if arg_string == "!" if arg_string == "!"

View file

@ -10,7 +10,8 @@ class Pry
Import a Pry command set. Import a Pry command set.
BANNER BANNER
def process(command_set_name) # TODO: resolve unused parameter.
def process(_command_set_name)
raise CommandError, "Provide a command set name" if command_set.nil? raise CommandError, "Provide a command set name" if command_set.nil?
set = target.eval(arg_string) set = target.eval(arg_string)

View file

@ -38,7 +38,7 @@ class Pry
@pager.page(paging_text.string) @pager.page(paging_text.string)
end end
def formatter(io) def formatter(_io)
if @formatter_klass if @formatter_klass
@formatter_klass.new @formatter_klass.new
else else

View file

@ -86,7 +86,9 @@ class Pry
end end
end end
def add_expression(arguments) # TODO: fix arguments.
# https://github.com/pry/pry/commit/b031df2f2f5850ee6e9018f33d35f3485a9b0423
def add_expression(_arguments)
expressions << Expression.new(_pry_, target, arg_string) expressions << Expression.new(_pry_, target, arg_string)
output.puts "Watching #{Code.new(arg_string).highlighted}" output.puts "Watching #{Code.new(arg_string).highlighted}"
end end

View file

@ -61,7 +61,7 @@ module Pry::Helpers::BaseHelpers
# Send the given text through the best available pager (if Pry.config.pager is # Send the given text through the best available pager (if Pry.config.pager is
# enabled). Infers where to send the output if used as a mixin. # enabled). Infers where to send the output if used as a mixin.
# DEPRECATED. # DEPRECATED.
def stagger_output(text, out = nil) def stagger_output(text, _out = nil)
if defined?(_pry_) && _pry_ if defined?(_pry_) && _pry_
_pry_.pager.page text _pry_.pager.page text
else else

View file

@ -15,7 +15,7 @@ class Pry
end end
# Ensure that duplicates have their @hooks object. # Ensure that duplicates have their @hooks object.
def initialize_copy(orig) def initialize_copy(_orig)
hooks_dup = @hooks.dup hooks_dup = @hooks.dup
@hooks.each do |k, v| @hooks.each do |k, v|
hooks_dup[k] = v.dup hooks_dup[k] = v.dup

View file

@ -166,7 +166,7 @@ class Pry
# please use {all_from_obj} instead. # please use {all_from_obj} instead.
# the `method_type` argument is ignored. # the `method_type` argument is ignored.
# #
def all_from_common(obj, method_type = nil, include_super=true) def all_from_common(obj, _method_type = nil, include_super=true)
all_from_obj(obj, include_super) all_from_obj(obj, include_super)
end end

View file

@ -20,7 +20,7 @@ class Pry
# #
# @param [Object] receiver # @param [Object] receiver
# @param [String] method_name # @param [String] method_name
def initialize(receiver, method_name, binding=nil) def initialize(receiver, method_name)
@receiver, @name = receiver, method_name @receiver, @name = receiver, method_name
@method = nil @method = nil
end end

View file

@ -8,7 +8,7 @@ class Pry
@name = name @name = name
end end
def method_missing(*args) def method_missing(*_args)
warn "Warning: The plugin '#{@name}' was not found! (no gem found)" warn "Warning: The plugin '#{@name}' was not found! (no gem found)"
end end
end end

View file

@ -396,7 +396,7 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
Thread.current[:pry_critical_section] > 0 Thread.current[:pry_critical_section] > 0
end end
def self.critical_section(&block) def self.critical_section
Thread.current[:pry_critical_section] ||= 0 Thread.current[:pry_critical_section] ||= 0
Thread.current[:pry_critical_section] += 1 Thread.current[:pry_critical_section] += 1
yield yield

View file

@ -656,7 +656,7 @@ describe Pry::CommandSet do
end end
it "should delegate to commands" do it "should delegate to commands" do
@set.create_command('susan'){ def complete(search); ['--foo']; end } @set.create_command('susan'){ def complete(_search); ['--foo']; end }
expect(@set.complete('susan ')).to eq ['--foo'] expect(@set.complete('susan ')).to eq ['--foo']
end end
end end

View file

@ -226,11 +226,11 @@ describe "Pry::Command" do
output.puts "setup" output.puts "setup"
end end
def subcommands(cmd) def subcommands(_cmd)
output.puts "subcommands" output.puts "subcommands"
end end
def options(opt) def options(_opt)
output.puts "options" output.puts "options"
end end

View file

@ -222,7 +222,7 @@ describe 'cd' do
end end
it 'should cd into complex input (with spaces)' do it 'should cd into complex input (with spaces)' do
def @o.hello(x, y, z) def @o.hello(_x, _y, _z)
:mon_ouie :mon_ouie
end end

View file

@ -47,7 +47,7 @@ describe "show-source" do
end end
it "should find methods even if there are spaces in the arguments" do it "should find methods even if there are spaces in the arguments" do
def @o.foo(*bars) def @o.foo(*_bars)
@foo = "Mr flibble" @foo = "Mr flibble"
self self
end end
@ -213,7 +213,7 @@ describe "show-source" do
describe "finding super methods with help of `--super` switch" do describe "finding super methods with help of `--super` switch" do
before do before do
class Foo class Foo
def foo(*bars) def foo(*_bars)
:super_wibble :super_wibble
end end
end end
@ -226,7 +226,7 @@ describe "show-source" do
it "finds super methods with explicit method argument" do it "finds super methods with explicit method argument" do
o = Foo.new o = Foo.new
def o.foo(*bars) def o.foo(*_bars)
:wibble :wibble
end end

View file

@ -76,7 +76,7 @@ describe Pry do
# regression test for burg's bug (see git history) # regression test for burg's bug (see git history)
it "Should not error when object doesn't have a valid == method" do it "Should not error when object doesn't have a valid == method" do
o = Object.new o = Object.new
def o.==(other) def o.==(_other)
raise raise
end end