summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2018-10-16 04:38:17 +0800
committerKyrylo Silin <silin@kyrylo.org>2018-10-16 04:38:17 +0800
commitc22914273949d29b77d31e3f1f9eeacf0a88131c (patch)
tree86603152d0c60db33c4b90e06ef456693e1e0053
parenteef698b6517ecc2f48d1a6e0dad77710ce6b83c1 (diff)
downloadpry-c22914273949d29b77d31e3f1f9eeacf0a88131c.tar.gz
rubocop: fix offences of the Lint/AmbiguousBlockAssociation coprubocop-lint-ambiguous-block-assosication
-rw-r--r--.rubocop_todo.yml11
-rw-r--r--lib/pry/object_path.rb7
-rw-r--r--spec/commands/show_doc_spec.rb10
-rw-r--r--spec/commands/show_source_spec.rb10
-rw-r--r--spec/config_spec.rb2
-rw-r--r--spec/helper.rb6
-rw-r--r--spec/method_spec.rb31
-rw-r--r--spec/pry_output_spec.rb6
8 files changed, 50 insertions, 33 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 15ddb2c8..a3862bf2 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -563,17 +563,6 @@ Layout/TrailingWhitespace:
- 'spec/commands/edit_spec.rb'
- 'spec/indent_spec.rb'
-# Offense count: 13
-Lint/AmbiguousBlockAssociation:
- Exclude:
- - 'lib/pry/object_path.rb'
- - 'spec/commands/show_doc_spec.rb'
- - 'spec/commands/show_source_spec.rb'
- - 'spec/config_spec.rb'
- - 'spec/helper.rb'
- - 'spec/method_spec.rb'
- - 'spec/pry_output_spec.rb'
-
# Offense count: 15
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
diff --git a/lib/pry/object_path.rb b/lib/pry/object_path.rb
index d509a749..6c9e5f98 100644
--- a/lib/pry/object_path.rb
+++ b/lib/pry/object_path.rb
@@ -74,9 +74,10 @@ class Pry
"Exception: #{err.inspect}"
].join("\n")
- raise CommandError.new(msg).tap { |e|
- e.set_backtrace err.backtrace
- }
+ command_error = CommandError.new(msg)
+ command_error.set_backtrace(err.backtrace)
+
+ raise command_error
end
end
end
diff --git a/spec/commands/show_doc_spec.rb b/spec/commands/show_doc_spec.rb
index a2692d54..1fc1e7c4 100644
--- a/spec/commands/show_doc_spec.rb
+++ b/spec/commands/show_doc_spec.rb
@@ -108,11 +108,13 @@ describe "show-doc" do
it "finds super method docs without `--super` but with the `super` keyword" do
fatty = Grungy.new
- fatty.extend Module.new {
- def initialize
- :nibble
+ fatty.extend(
+ Module.new do
+ def initialize
+ :nibble
+ end
end
- }
+ )
# fatty initialize!
def fatty.initialize
diff --git a/spec/commands/show_source_spec.rb b/spec/commands/show_source_spec.rb
index 8b5624c4..4f54397a 100644
--- a/spec/commands/show_source_spec.rb
+++ b/spec/commands/show_source_spec.rb
@@ -246,11 +246,13 @@ describe "show-source" do
it "finds super methods with multiple --super " do
o = Foo.new
- o.extend Module.new {
- def foo
- :nibble
+ o.extend(
+ Module.new do
+ def foo
+ :nibble
+ end
end
- }
+ )
def o.foo(*bars)
@foo = :wibble
diff --git a/spec/config_spec.rb b/spec/config_spec.rb
index 3066fcef..0050325d 100644
--- a/spec/config_spec.rb
+++ b/spec/config_spec.rb
@@ -11,7 +11,7 @@ describe Pry::Config do
describe "bug #1277" do
specify "a local key has precendence over an inherited method of the same name" do
local = Pry::Config.from_hash(output: 'foobar')
- local.extend Module.new { def output(); 'broken'; end }
+ local.extend(Module.new { def output(); 'broken'; end })
expect(local.output).to eq('foobar')
end
end
diff --git a/spec/helper.rb b/spec/helper.rb
index 3ba607b7..04e67a88 100644
--- a/spec/helper.rb
+++ b/spec/helper.rb
@@ -20,9 +20,11 @@ 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|
+ set_trace_func(
+ proc { |event, file, line, id, binding, classname|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
- }
+ }
+ )
end
RSpec.configure do |config|
diff --git a/spec/method_spec.rb b/spec/method_spec.rb
index 23482569..e8043692 100644
--- a/spec/method_spec.rb
+++ b/spec/method_spec.rb
@@ -277,17 +277,25 @@ describe Pry::Method do
end
it 'should be able to find instance methods defined in modules included into this class' do
- @class = Class.new{ include Module.new{ def meth; 1; end; } }
+ @class = Class.new do
+ include(Module.new { def meth; 1; end })
+ end
should_find_method('meth')
end
it 'should be able to find instance methods defined in modules included into super-classes' do
- @class = Class.new(Class.new{ include Module.new{ def meth; 1; end; } })
+ super_class = Class.new do
+ include(Module.new { def meth; 1; end })
+ end
+ @class = Class.new(super_class)
should_find_method('meth')
end
it 'should attribute overridden methods to the sub-class' do
- @class = Class.new(Class.new{ include Module.new{ def meth; 1; end; } }) { def meth; 2; end }
+ super_class = Class.new do
+ include(Module.new { def meth; 1; end })
+ end
+ @class = Class.new(super_class) { def meth; 2; end }
expect(Pry::Method.all_from_class(@class).detect{ |x| x.name == 'meth' }.owner).to eq @class
end
@@ -314,7 +322,9 @@ describe Pry::Method do
end
it "should find methods defined in modules included into the object's class" do
- @obj = Class.new{ include Module.new{ def meth; 1; end } }.new
+ @obj = Class.new {
+ include(Module.new { def meth; 1; end })
+ }.new
should_find_method('meth')
end
@@ -326,7 +336,7 @@ describe Pry::Method do
it "should find methods in modules included into the object's singleton class" do
@obj = Object.new
- @obj.extend Module.new{ def meth; 1; end }
+ @obj.extend(Module.new { def meth; 1; end })
should_find_method('meth')
end
@@ -361,7 +371,9 @@ describe Pry::Method do
end
it "should find methods defined on modules extended into the class" do
- @class = Class.new{ extend Module.new{ def meth; 1; end; } }
+ @class = Class.new do
+ extend(Module.new { def meth; 1; end })
+ end
should_find_method('meth')
end
@@ -391,7 +403,12 @@ describe Pry::Method do
end
it "should attrbute overridden methods to the class not the module" do
- @class = Class.new { class << self; def meth; 1; end; end; extend Module.new{ def meth; 1; end; } }
+ @class = Class.new do
+ class << self
+ def meth; 1; end
+ end
+ extend(Module.new { def meth; 1; end })
+ end
expect(Pry::Method.all_from_obj(@class).detect{ |x| x.name == 'meth' }.owner).to eq(class << @class; self; end)
end
diff --git a/spec/pry_output_spec.rb b/spec/pry_output_spec.rb
index 9df5beaf..a8b14d36 100644
--- a/spec/pry_output_spec.rb
+++ b/spec/pry_output_spec.rb
@@ -20,7 +20,11 @@ describe Pry do
it "should catch errors serializing exceptions" do
Pry.config.print = lambda do |*a|
- raise Exception.new("catch-22").tap{ |e| class << e; def inspect; raise e; end; end }
+ ex = Exception.new("catch-22")
+ class << ex
+ def inspect; raise ex; end
+ end
+ raise ex
end
expect(mock_pry("1")).to match(/\(pry\) output error: failed to show result/)