summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2019-03-02 14:13:59 +0200
committerKyrylo Silin <silin@kyrylo.org>2019-03-02 14:13:59 +0200
commite9cfdc8b45835ff9ac82fbe857aac9fd0c937b84 (patch)
treecf5146d76d4023ba14cf5059f8ac73a8a8dbfc8e
parentac24bad339e19f576592d98178ce0ae0a1659605 (diff)
downloadpry-e9cfdc8b45835ff9ac82fbe857aac9fd0c937b84.tar.gz
rubocop: fix offences of the Style/RescueStandardError cop
-rw-r--r--.rubocop_todo.yml17
-rw-r--r--lib/pry/color_printer.rb4
-rw-r--r--lib/pry/commands/watch_expression/expression.rb2
-rw-r--r--lib/pry/input_completer.rb2
-rw-r--r--lib/pry/method/weird_method_locator.rb2
-rw-r--r--lib/pry/pager.rb2
-rw-r--r--lib/pry/plugins.rb2
-rw-r--r--lib/pry/pry_class.rb4
-rw-r--r--spec/commands/cat_spec.rb2
-rw-r--r--spec/commands/ls_spec.rb2
-rw-r--r--spec/hooks_spec.rb2
11 files changed, 12 insertions, 29 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 7e88f9d4..dc5421ea 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -314,23 +314,6 @@ Style/PerlBackrefs:
- 'lib/pry/method.rb'
- 'lib/pry/rubygem.rb'
-# Offense count: 11
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: implicit, explicit
-Style/RescueStandardError:
- Exclude:
- - 'lib/pry/color_printer.rb'
- - 'lib/pry/commands/watch_expression/expression.rb'
- - 'lib/pry/input_completer.rb'
- - 'lib/pry/method/weird_method_locator.rb'
- - 'lib/pry/pager.rb'
- - 'lib/pry/plugins.rb'
- - 'lib/pry/pry_class.rb'
- - 'spec/commands/cat_spec.rb'
- - 'spec/commands/ls_spec.rb'
- - 'spec/hooks_spec.rb'
-
# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: AllowAsExpressionSeparator.
diff --git a/lib/pry/color_printer.rb b/lib/pry/color_printer.rb
index f209478d..c3410fc3 100644
--- a/lib/pry/color_printer.rb
+++ b/lib/pry/color_printer.rb
@@ -38,7 +38,7 @@ class Pry
else
super
end
- rescue => e
+ rescue StandardError => e
raise if e.is_a? Pry::Pager::StopPaging
begin
@@ -51,7 +51,7 @@ class Pry
klass = ancestors.reject { |k| k == singleton }.first
obj_id = begin
obj.__id__.to_s(16)
- rescue
+ rescue StandardError
0
end
str = "#<#{klass}:0x#{obj_id}>"
diff --git a/lib/pry/commands/watch_expression/expression.rb b/lib/pry/commands/watch_expression/expression.rb
index f69bf10b..aa2f4d45 100644
--- a/lib/pry/commands/watch_expression/expression.rb
+++ b/lib/pry/commands/watch_expression/expression.rb
@@ -31,7 +31,7 @@ class Pry
def target_eval(target, source)
target.eval(source)
- rescue => e
+ rescue StandardError => e
e
end
end
diff --git a/lib/pry/input_completer.rb b/lib/pry/input_completer.rb
index 4840142b..788e9dde 100644
--- a/lib/pry/input_completer.rb
+++ b/lib/pry/input_completer.rb
@@ -108,7 +108,7 @@ class Pry
context = target.eval("self")
context = context.class unless context.respond_to? :constants
candidates = context.constants.collect(&:to_s)
- rescue
+ rescue StandardError
candidates = []
end
candidates = candidates.grep(/^#{message}/).collect(&path)
diff --git a/lib/pry/method/weird_method_locator.rb b/lib/pry/method/weird_method_locator.rb
index da36c8c6..e9ab3b42 100644
--- a/lib/pry/method/weird_method_locator.rb
+++ b/lib/pry/method/weird_method_locator.rb
@@ -34,7 +34,7 @@ class Pry
(File.expand_path(method.source_file) == File.expand_path(binding_file)) &&
method.source_range.include?(binding_line)
end
- rescue
+ rescue StandardError
false
end
diff --git a/lib/pry/pager.rb b/lib/pry/pager.rb
index 8c67332a..9ef5ea69 100644
--- a/lib/pry/pager.rb
+++ b/lib/pry/pager.rb
@@ -148,7 +148,7 @@ class Pry
`which #{pager_executable}`
end
$?.success?
- rescue
+ rescue StandardError
false
end
else
diff --git a/lib/pry/plugins.rb b/lib/pry/plugins.rb
index d09e8620..3cf36638 100644
--- a/lib/pry/plugins.rb
+++ b/lib/pry/plugins.rb
@@ -57,7 +57,7 @@ class Pry
rescue LoadError => e
warn "Found plugin #{gem_name}, but could not require '#{gem_name}'"
warn e
- rescue => e
+ rescue StandardError => e
warn "require '#{gem_name}' # Failed, saying: #{e}"
end
diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb
index 2f677885..c08412cb 100644
--- a/lib/pry/pry_class.rb
+++ b/lib/pry/pry_class.rb
@@ -323,12 +323,12 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly
trap :WINCH do
begin
Readline.set_screen_size(*Terminal.size!)
- rescue => e
+ rescue StandardError => e
warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}"
end
begin
Readline.refresh_line
- rescue => e
+ rescue StandardError => e
warn "\nPry.auto_resize!'s Readline.refresh_line failed: #{e}"
end
end
diff --git a/spec/commands/cat_spec.rb b/spec/commands/cat_spec.rb
index 813ff4a1..1a07a67c 100644
--- a/spec/commands/cat_spec.rb
+++ b/spec/commands/cat_spec.rb
@@ -87,7 +87,7 @@ describe "cat" do
it 'cat --ex should correctly display code that generated exception' do
begin
@o.broken_method
- rescue => e
+ rescue StandardError => e
@t.last_exception = e
end
expect(@t.eval('cat --ex')).to match(/this method is broken/)
diff --git a/spec/commands/ls_spec.rb b/spec/commands/ls_spec.rb
index 1ca25ec3..cabf7e0f 100644
--- a/spec/commands/ls_spec.rb
+++ b/spec/commands/ls_spec.rb
@@ -109,7 +109,7 @@ describe "ls" do
begin
pry_eval(test_case, "class GeFromulate2; @flurb=1.3; end", "cd GeFromulate2", "ls")
pry_eval(normalize)
- rescue
+ rescue StandardError
pry_eval(normalize)
raise
end
diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb
index 2c19d47e..f3375761 100644
--- a/spec/hooks_spec.rb
+++ b/spec/hooks_spec.rb
@@ -373,7 +373,7 @@ describe Pry::Hooks do
redirect_pry_io(StringIO.new("raise great_escape"), StringIO.new) do
Pry.start o, hooks: Pry::Hooks.new.add_hook(:after_session, :cleanup) { array = nil }
end
- rescue => ex
+ rescue StandardError => ex
exception = ex
end