summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop_todo.yml6
-rw-r--r--lib/pry.rb4
-rw-r--r--lib/pry/cli.rb2
-rw-r--r--lib/pry/commands/ls/jruby_hacks.rb2
-rw-r--r--lib/pry/commands/ls/local_vars.rb2
-rw-r--r--lib/pry/commands/show_info.rb2
-rw-r--r--lib/pry/config/behavior.rb2
-rw-r--r--lib/pry/hooks.rb8
-rw-r--r--lib/pry/indent.rb2
-rw-r--r--lib/pry/prompt.rb4
-rw-r--r--lib/pry/repl_file_loader.rb2
-rw-r--r--lib/pry/slop.rb2
-rw-r--r--lib/pry/slop/option.rb2
-rw-r--r--spec/code_spec.rb6
-rw-r--r--spec/command_spec.rb2
-rw-r--r--spec/commands/edit_spec.rb24
-rw-r--r--spec/editor_spec.rb2
-rw-r--r--spec/helper.rb2
-rw-r--r--spec/hooks_spec.rb12
-rw-r--r--spec/pry_defaults_spec.rb2
-rw-r--r--spec/pry_output_spec.rb6
21 files changed, 45 insertions, 51 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index cdf354ff..846350d1 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -504,12 +504,6 @@ Lint/ShadowedException:
Lint/UnderscorePrefixedVariableName:
Enabled: false
-# Offense count: 49
-# Cop supports --auto-correct.
-# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
-Lint/UnusedBlockArgument:
- Enabled: false
-
# Offense count: 1
Lint/UselessAssignment:
Exclude:
diff --git a/lib/pry.rb b/lib/pry.rb
index c3dfd4b3..afe1c12f 100644
--- a/lib/pry.rb
+++ b/lib/pry.rb
@@ -7,14 +7,14 @@ require 'pry/hooks'
class Pry
# The default hooks - display messages when beginning and ending Pry sessions.
- DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |out, target, _pry_|
+ DEFAULT_HOOKS = Pry::Hooks.new.add_hook(:before_session, :default) do |_out, _target, _pry_|
next if _pry_.quiet?
_pry_.run_command("whereami --quiet")
end
# The default print
- DEFAULT_PRINT = proc do |output, value, _pry_|
+ DEFAULT_PRINT = proc do |_output, value, _pry_|
_pry_.pager.open do |pager|
pager.print _pry_.config.output_prefix
Pry::ColorPrinter.pp(value, pager, Pry::Terminal.width! - 1)
diff --git a/lib/pry/cli.rb b/lib/pry/cli.rb
index 58c0ccea..8edf5d3d 100644
--- a/lib/pry/cli.rb
+++ b/lib/pry/cli.rb
@@ -199,7 +199,7 @@ Pry::CLI.add_options do
$LOAD_PATH.unshift(*load_path)
end
- on "gem", "Shorthand for -I./lib -rgemname" do |load_path|
+ on "gem", "Shorthand for -I./lib -rgemname" do |_load_path|
$LOAD_PATH.unshift("./lib")
Dir["./lib/*.rb"].each do |file|
Pry.config.requires << file
diff --git a/lib/pry/commands/ls/jruby_hacks.rb b/lib/pry/commands/ls/jruby_hacks.rb
index dd3be273..8f846ee6 100644
--- a/lib/pry/commands/ls/jruby_hacks.rb
+++ b/lib/pry/commands/ls/jruby_hacks.rb
@@ -19,7 +19,7 @@ module Pry::Command::Ls::JRubyHacks
m.name.sub(/\A(is|get|set)(?=[A-Z_])/, '').gsub(/[_?=]/, '').downcase
end
- grouped.flat_map do |key, values|
+ grouped.flat_map do |_key, values|
values = values.sort_by do |m|
rubbishness(m.name)
end
diff --git a/lib/pry/commands/ls/local_vars.rb b/lib/pry/commands/ls/local_vars.rb
index 77500f26..6a1be469 100644
--- a/lib/pry/commands/ls/local_vars.rb
+++ b/lib/pry/commands/ls/local_vars.rb
@@ -19,7 +19,7 @@ class Pry
private
def format(name_value_pairs)
- name_value_pairs.sort_by { |name, value|
+ name_value_pairs.sort_by { |_name, value|
value.to_s.size
}.reverse.map { |name, value|
colorized_assignment_style(name, format_value(value))
diff --git a/lib/pry/commands/show_info.rb b/lib/pry/commands/show_info.rb
index 574a89d1..37a7d1ee 100644
--- a/lib/pry/commands/show_info.rb
+++ b/lib/pry/commands/show_info.rb
@@ -155,7 +155,7 @@ class Pry
owner: "\n#{bold("Owner:")} #{code_object.owner || "N/A"}\n",
visibility: "#{bold("Visibility:")} #{code_object.visibility}",
signature: "\n#{bold("Signature:")} #{code_object.signature}"
- }.merge(header_options) { |key, old, new| (new && old).to_s }
+ }.merge(header_options) { |_key, old, new| (new && old).to_s }
end
def header_options
diff --git a/lib/pry/config/behavior.rb b/lib/pry/config/behavior.rb
index bd020064..e8050ac3 100644
--- a/lib/pry/config/behavior.rb
+++ b/lib/pry/config/behavior.rb
@@ -164,7 +164,7 @@ class Pry
def eager_load!
default = @default
while default
- default.memoized_methods.each { |method| self[key] = default.public_send(key) } if default.respond_to?(:memoized_methods)
+ default.memoized_methods.each { |_method| self[key] = default.public_send(key) } if default.respond_to?(:memoized_methods)
default = @default.default
end
end
diff --git a/lib/pry/hooks.rb b/lib/pry/hooks.rb
index a14db0a2..6f5b3fe0 100644
--- a/lib/pry/hooks.rb
+++ b/lib/pry/hooks.rb
@@ -34,7 +34,7 @@ class Pry
# @return [Pry:Hooks] The receiver.
# @see #merge
def merge!(other)
- @hooks.merge!(other.dup.hooks) do |key, array, other_array|
+ @hooks.merge!(other.dup.hooks) do |_key, array, other_array|
temp_hash, output = {}, []
(array + other_array).reverse_each do |pair|
@@ -79,7 +79,7 @@ class Pry
end
# ensure we only have one anonymous hook
- @hooks[event_name].delete_if { |h, k| h.nil? } if hook_name.nil?
+ @hooks[event_name].delete_if { |h, _k| h.nil? } if hook_name.nil?
if block
@hooks[event_name] << [hook_name, block]
@@ -95,7 +95,7 @@ class Pry
# @param [Array] args The arguments to pass to each hook function.
# @return [Object] The return value of the last executed hook.
def exec_hook(event_name, *args, &block)
- @hooks[event_name.to_s].map do |hook_name, callable|
+ @hooks[event_name.to_s].map do |_hook_name, callable|
begin
callable.call(*args, &block)
rescue RescuableException => e
@@ -115,7 +115,7 @@ class Pry
# @param [Symbol] hook_name The name of the hook
# @return [#call] a specific hook for a given event.
def get_hook(event_name, hook_name)
- hook = @hooks[event_name.to_s].find do |current_hook_name, callable|
+ hook = @hooks[event_name.to_s].find do |current_hook_name, _callable|
current_hook_name == hook_name
end
hook.last if hook
diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb
index 62391de1..c0fe5391 100644
--- a/lib/pry/indent.rb
+++ b/lib/pry/indent.rb
@@ -145,7 +145,7 @@ class Pry
input.lines.each do |line|
if in_string?
tokens = tokenize("#{open_delimiters_line}\n#{line}")
- tokens = tokens.drop_while { |token, type| !(String === token && token.include?("\n")) }
+ tokens = tokens.drop_while { |token, _type| !(String === token && token.include?("\n")) }
previously_in_string = true
else
tokens = tokenize(line)
diff --git a/lib/pry/prompt.rb b/lib/pry/prompt.rb
index f8c0bde2..81d7990d 100644
--- a/lib/pry/prompt.rb
+++ b/lib/pry/prompt.rb
@@ -117,7 +117,7 @@ class Pry
"A prompt that displays the binding stack as a path and includes information \n" \
"about #{Helpers::Text.bold('_in_')} and #{Helpers::Text.bold('_out_')}.",
%w[> *]
- ) do |context, nesting, _pry_, sep|
+ ) do |_context, _nesting, _pry_, sep|
tree = _pry_.binding_stack.map { |b| Pry.view_clip(b.eval('self')) }
format(
"[%<in_count>s] (%<name>s) %<tree>s: %<stack_size>s%<separator>s ",
@@ -133,7 +133,7 @@ class Pry
'shell',
'A prompt that displays `$PWD` as you change it.',
%w[$ *]
- ) do |context, nesting, _pry_, sep|
+ ) do |context, _nesting, _pry_, sep|
format(
"%<name>s %<context>s:%<pwd>s %<separator>s ",
name: prompt_name(_pry_.config.prompt_name),
diff --git a/lib/pry/repl_file_loader.rb b/lib/pry/repl_file_loader.rb
index c21f3e74..91a9b523 100644
--- a/lib/pry/repl_file_loader.rb
+++ b/lib/pry/repl_file_loader.rb
@@ -34,7 +34,7 @@ class Pry
# @param [Pry] _pry_ the Pry instance to make non-interactive.
def non_interactive_mode(_pry_, content)
_pry_.print = proc {}
- _pry_.exception_handler = proc do |o, e, _p_|
+ _pry_.exception_handler = proc do |o, _e, _p_|
_p_.run_command "cat --ex"
o.puts "...exception encountered, going interactive!"
interactive_mode(_pry_)
diff --git a/lib/pry/slop.rb b/lib/pry/slop.rb
index 61c2128f..11ab66f6 100644
--- a/lib/pry/slop.rb
+++ b/lib/pry/slop.rb
@@ -224,7 +224,7 @@ class Pry::Slop
autocreate(items, index) if config[:autocreate]
process_item(items, index, &block) unless @trash.include?(index)
end
- items.reject!.with_index { |item, index| @trash.include?(index) }
+ items.reject!.with_index { |_item, index| @trash.include?(index) }
missing_options = options.select { |opt| opt.required? && opt.count < 1 }
if missing_options.any?
diff --git a/lib/pry/slop/option.rb b/lib/pry/slop/option.rb
index 8af20a2d..5d7707c7 100644
--- a/lib/pry/slop/option.rb
+++ b/lib/pry/slop/option.rb
@@ -45,7 +45,7 @@ class Pry::Slop
integer: proc { |v| value_to_integer(v) },
float: proc { |v| value_to_float(v) },
range: proc { |v| value_to_range(v) },
- count: proc { |v| @count }
+ count: proc { |_v| @count }
}
if long && long.size > @slop.config[:longest_flag]
diff --git a/spec/code_spec.rb b/spec/code_spec.rb
index aa2d377c..f24731c8 100644
--- a/spec/code_spec.rb
+++ b/spec/code_spec.rb
@@ -30,19 +30,19 @@ describe Pry::Code do
end
specify 'check for files relative to origin pwd' do
- Dir.chdir('spec') do |f|
+ Dir.chdir('spec') do |_f|
expect(Pry::Code.from_file('spec/' + File.basename(__FILE__)).code_type).to eq :ruby
end
end
specify 'check for Ruby files relative to origin pwd with `.rb` omitted' do
- Dir.chdir('spec') do |f|
+ Dir.chdir('spec') do |_f|
expect(Pry::Code.from_file('spec/' + File.basename(__FILE__, '.*')).code_type).to eq :ruby
end
end
specify 'find files that are relative to the current working directory' do
- Dir.chdir('spec') do |f|
+ Dir.chdir('spec') do |_f|
expect(Pry::Code.from_file(File.basename(__FILE__)).code_type).to eq :ruby
end
end
diff --git a/spec/command_spec.rb b/spec/command_spec.rb
index 1409aa0b..d7c6359f 100644
--- a/spec/command_spec.rb
+++ b/spec/command_spec.rb
@@ -465,7 +465,7 @@ describe "Pry::Command" do
describe "block-related content removed from arguments" do
describe "arg_string" do
it 'should remove block-related content from arg_string (with one normal arg)' do
- @set.block_command "walking-spanish", "down the hall", takes_block: true do |x, y|
+ @set.block_command "walking-spanish", "down the hall", takes_block: true do |x, _y|
insert_variable(:@arg_string, arg_string, target)
insert_variable(:@x, x, target)
end
diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb
index 0b61a895..d4b92a6c 100644
--- a/spec/commands/edit_spec.rb
+++ b/spec/commands/edit_spec.rb
@@ -74,7 +74,7 @@ describe "edit" do
if respond_to?(:require_relative, true)
it "should work with require relative" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << 'require_relative "baz.rb"' }
File.open(file.gsub('bar.rb', 'baz.rb'), 'w') { |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" }
nil
@@ -87,7 +87,7 @@ describe "edit" do
describe do
before do
Pad.counter = 0
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "Pad.counter = Pad.counter + 1" }
nil
}
@@ -186,7 +186,7 @@ describe "edit" do
end
it "should reload the file" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "FOO = 'BAR'" }
nil
}
@@ -220,7 +220,7 @@ describe "edit" do
end
it "should not reload the file if -n is passed" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "FOO2 = 'BAZ'" }
nil
}
@@ -235,7 +235,7 @@ describe "edit" do
describe "with --patch" do
# Original source code must be untouched.
it "should apply changes only in memory (monkey patching)" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "FOO3 = 'PIYO'" }
@patched_def = File.open(file, 'r').read
nil
@@ -332,7 +332,7 @@ describe "edit" do
end
it "should evaluate the expression" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "'FOO'\n" }
nil
}
@@ -341,7 +341,7 @@ describe "edit" do
end
it "should ignore -n for tempfiles" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "'FOO'\n" }
nil
}
@@ -350,7 +350,7 @@ describe "edit" do
end
it "should not evaluate a file with -n" do
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f| f << "'FOO'\n" }
nil
}
@@ -365,7 +365,7 @@ describe "edit" do
it "should write the evaluated command to history" do
quote = 'history repeats itself, first as tradegy...'
- Pry.config.editor = lambda { |file, line|
+ Pry.config.editor = lambda { |file, _line|
File.open(file, 'w') { |f|
f << quote
}
@@ -408,7 +408,7 @@ describe "edit" do
describe 'when editing a method by name' do
def use_editor(tester, options)
- tester.pry.config.editor = lambda do |filename, line|
+ tester.pry.config.editor = lambda do |filename, _line|
File.open(filename, 'w') { |f| f.write options.fetch(:replace_all) }
nil
end
@@ -555,7 +555,7 @@ describe "edit" do
describe 'with -p' do
before do
- Pry.config.editor = lambda do |file, line|
+ Pry.config.editor = lambda do |file, _line|
lines = File.read(file).lines.to_a
lines[1] = if lines[2] =~ /end/
":maybe\n"
@@ -706,7 +706,7 @@ describe "edit" do
describe 'on an aliased method' do
before do
- Pry.config.editor = lambda do |file, line|
+ Pry.config.editor = lambda do |file, _line|
lines = File.read(file).lines.to_a
lines[1] = '"#{super}aa".to_sym' + "\n"
File.open(file, 'w') do |f|
diff --git a/spec/editor_spec.rb b/spec/editor_spec.rb
index 974dcb44..9ba7992e 100644
--- a/spec/editor_spec.rb
+++ b/spec/editor_spec.rb
@@ -41,7 +41,7 @@ describe Pry::Editor do
describe 'invoke_editor with a proc' do
it 'should not shell-escape files' do
- editor = Pry::Editor.new(Pry.new(editor: proc { |file, line, blocking|
+ editor = Pry::Editor.new(Pry.new(editor: proc { |file, _line, _blocking|
@file = file
nil
}))
diff --git a/spec/helper.rb b/spec/helper.rb
index efe48af7..2a269fa0 100644
--- a/spec/helper.rb
+++ b/spec/helper.rb
@@ -21,7 +21,7 @@ end.new(nil)
# to help with tracking down bugs that cause an infinite loop in the test suite
if ENV["SET_TRACE_FUNC"]
set_trace_func(
- proc { |event, file, line, id, binding, classname|
+ proc { |event, file, line, id, _binding, classname|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
)
diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb
index c8d7720e..43fe4857 100644
--- a/spec/hooks_spec.rb
+++ b/spec/hooks_spec.rb
@@ -309,7 +309,7 @@ describe Pry::Hooks do
describe "when_started hook" do
it 'should yield options to the hook' do
options = nil
- Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| options = opt }
+ Pry.config.hooks.add_hook(:when_started, :test_hook) { |_target, opt, _| options = opt }
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
Pry.start binding, hello: :baby
@@ -323,7 +323,7 @@ describe Pry::Hooks do
describe "target" do
it 'should yield the target, as a binding ' do
b = nil
- Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
+ Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, _opt, _| b = target }
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
Pry.start 5, hello: :baby
@@ -335,7 +335,7 @@ describe Pry::Hooks do
it 'should yield the target to the hook' do
b = nil
- Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _| b = target }
+ Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, _opt, _| b = target }
redirect_pry_io(StringIO.new("exit"), StringIO.new) do
Pry.start 5, hello: :baby
@@ -350,7 +350,7 @@ describe Pry::Hooks do
o = Object.new
class << o; attr_accessor :value; end
- Pry.config.hooks.add_hook(:when_started, :test_hook) { |target, opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
+ Pry.config.hooks.add_hook(:when_started, :test_hook) { |_target, _opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] }
redirect_pry_io(InputTester.new("@value = true","exit-all")) do
Pry.start binding, hello: :baby
@@ -393,7 +393,7 @@ describe Pry::Hooks do
describe "before_eval hook" do
describe "modifying input code" do
it 'should replace input code with code determined by hook' do
- hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, pry| code.replace(":little_duck") }
+ hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, _pry| code.replace(":little_duck") }
redirect_pry_io(InputTester.new(":jemima", "exit-all"), out = StringIO.new) do
Pry.start(self, hooks: hooks)
end
@@ -410,7 +410,7 @@ describe Pry::Hooks do
end
end
- hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, pry| code.replace(":little_duck") }
+ hooks = Pry::Hooks.new.add_hook(:before_eval, :quirk) { |code, _pry| code.replace(":little_duck") }
redirect_pry_io(InputTester.new("how-do-you-like-your-blue-eyed-boy-now-mister-death", "exit-all"), out = StringIO.new) do
Pry.start(self, hooks: hooks, commands: commands)
diff --git a/spec/pry_defaults_spec.rb b/spec/pry_defaults_spec.rb
index eb81fa29..a0d79424 100644
--- a/spec/pry_defaults_spec.rb
+++ b/spec/pry_defaults_spec.rb
@@ -87,7 +87,7 @@ describe "test Pry defaults" do
end
it "should set the print default, and the default should be overridable" do
- new_print = proc { |out, value| out.puts "=> LOL" }
+ new_print = proc { |out, _value| out.puts "=> LOL" }
Pry.config.print = new_print
expect(Pry.new.print).to eq Pry.config.print
diff --git a/spec/pry_output_spec.rb b/spec/pry_output_spec.rb
index a8b14d36..a4168b83 100644
--- a/spec/pry_output_spec.rb
+++ b/spec/pry_output_spec.rb
@@ -7,19 +7,19 @@ describe Pry do
end
it "should catch serialization exceptions" do
- Pry.config.print = lambda { |*a| raise "catch-22" }
+ Pry.config.print = lambda { |*_a| raise "catch-22" }
expect { mock_pry("1") }.to_not raise_error
end
it "should display serialization exceptions" do
- Pry.config.print = lambda { |*a| raise "catch-22" }
+ Pry.config.print = lambda { |*_a| raise "catch-22" }
expect(mock_pry("1")).to match(/\(pry\) output error: #<RuntimeError: catch-22>/)
end
it "should catch errors serializing exceptions" do
- Pry.config.print = lambda do |*a|
+ Pry.config.print = lambda do |*_a|
ex = Exception.new("catch-22")
class << ex
def inspect; raise ex; end