summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-04 18:28:06 +0100
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-03-04 19:25:29 +0100
commitd88d2b4e1a46706a14c8eb821c76aab2775209ff (patch)
tree5a9c4a3eb9265efa1dc488b403b461272695169f
parentc936f74cddbaa7b1cddd9edbce8c8e947da11aa8 (diff)
downloadbundler-d88d2b4e1a46706a14c8eb821c76aab2775209ff.tar.gz
Auto-correct `Style/RescueStandardError` offenses
-rw-r--r--.rubocop_todo.yml15
-rw-r--r--Rakefile2
-rw-r--r--lib/bundler/friendly_errors.rb2
-rw-r--r--lib/bundler/resolver.rb4
-rw-r--r--lib/bundler/retry.rb2
-rw-r--r--lib/bundler/source/rubygems.rb2
-rw-r--r--spec/support/artifice/compact_index.rb4
-rw-r--r--spec/support/helpers.rb4
-rw-r--r--spec/support/matchers.rb6
9 files changed, 13 insertions, 28 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 33ada84d5d..013f193f74 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -545,21 +545,6 @@ Style/RedundantReturn:
Exclude:
- 'lib/bundler/installer/gem_installer.rb'
-# Offense count: 13
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyle.
-# SupportedStyles: implicit, explicit
-Style/RescueStandardError:
- Exclude:
- - 'Rakefile'
- - 'lib/bundler/friendly_errors.rb'
- - 'lib/bundler/resolver.rb'
- - 'lib/bundler/retry.rb'
- - 'lib/bundler/source/rubygems.rb'
- - 'spec/support/artifice/compact_index.rb'
- - 'spec/support/helpers.rb'
- - 'spec/support/matchers.rb'
-
# Offense count: 35
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
diff --git a/Rakefile b/Rakefile
index 4391fc6da5..7b736e6943 100644
--- a/Rakefile
+++ b/Rakefile
@@ -18,7 +18,7 @@ end
def safe_task(&block)
yield
true
-rescue
+rescue StandardError
false
end
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 47efd3a949..451504f21d 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -44,7 +44,7 @@ module Bundler
"Alternatively, you can increase the amount of memory the JVM is able to use by running Bundler with jruby -J-Xmx1024m -S bundle (JRuby defaults to 500MB)."
else request_issue_report_for(error)
end
- rescue
+ rescue StandardError
raise error
end
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 96ff5473fe..266a77e220 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -172,13 +172,13 @@ module Bundler
def name_for_explicit_dependency_source
Bundler.default_gemfile.basename.to_s
- rescue
+ rescue StandardError
"Gemfile"
end
def name_for_locking_dependency_source
Bundler.default_lockfile.basename.to_s
- rescue
+ rescue StandardError
"Gemfile.lock"
end
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index 5e4f0c502d..d64958ba70 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -38,7 +38,7 @@ module Bundler
@failed = false
@current_run += 1
@result = block.call
- rescue => e
+ rescue StandardError => e
fail_attempt(e)
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 88d88320e6..54758c9443 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -124,7 +124,7 @@ module Bundler
begin
s = Bundler.rubygems.spec_from_gem(path, Bundler.settings["trust-policy"])
spec.__swap__(s)
- rescue
+ rescue StandardError
Bundler.rm_rf(path)
raise
end
diff --git a/spec/support/artifice/compact_index.rb b/spec/support/artifice/compact_index.rb
index 38559e2e23..f97c2b3fbc 100644
--- a/spec/support/artifice/compact_index.rb
+++ b/spec/support/artifice/compact_index.rb
@@ -21,7 +21,7 @@ class CompactIndexAPI < Endpoint
headers "Surrogate-Control" => "max-age=2592000, stale-while-revalidate=60"
content_type "text/plain"
requested_range_for(response_body)
- rescue => e
+ rescue StandardError => e
puts e
puts e.backtrace
raise
@@ -83,7 +83,7 @@ class CompactIndexAPI < Endpoint
end
checksum = begin
Digest(:SHA256).file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest
- rescue
+ rescue StandardError
nil
end
CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil,
diff --git a/spec/support/helpers.rb b/spec/support/helpers.rb
index 4eb98645a5..1d7563cae6 100644
--- a/spec/support/helpers.rb
+++ b/spec/support/helpers.rb
@@ -569,7 +569,7 @@ module Spec
tries = 0
sleep 0.5
TCPSocket.new(host, port)
- rescue => e
+ rescue StandardError => e
raise(e) if tries > (seconds * 2)
tries += 1
retry
@@ -579,7 +579,7 @@ module Spec
port = 21_453
begin
port += 1 while TCPSocket.new("127.0.0.1", port)
- rescue
+ rescue StandardError
false
end
port
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 8f0c1e5f91..fb124b30cc 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -152,7 +152,7 @@ module Spec
version_const = name == "bundler" ? "Bundler::VERSION" : Spec::Builders.constantize(name)
begin
run! "require '#{name}.rb'; puts #{version_const}", *groups
- rescue => e
+ rescue StandardError => e
next "#{name} is not installed:\n#{indent(e)}"
end
last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
@@ -167,7 +167,7 @@ module Spec
begin
source_const = "#{Spec::Builders.constantize(name)}_SOURCE"
run! "require '#{name}/source'; puts #{source_const}", *groups
- rescue
+ rescue StandardError
next "#{name} does not have a source defined:\n#{indent(e)}"
end
last_command.stdout.gsub!(/#{MAJOR_DEPRECATION}.*$/, "")
@@ -193,7 +193,7 @@ module Spec
puts "WIN"
end
R
- rescue => e
+ rescue StandardError => e
next "checking for #{name} failed:\n#{e}"
end
next if last_command.stdout == "WIN"