aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2018-12-21 02:44:01 +0900
committerRyuta Kamizono <kamipo@gmail.com>2018-12-21 06:12:42 +0900
commit892e38c78e03c11afaa5f01d995e3a21bd92b415 (patch)
tree628ab7a9e9e81ee778844acfd25860e2bd3ccf20 /activesupport/lib
parentd5699198a45a91250e1adb3ed899b0b46b4ac879 (diff)
downloadrails-892e38c78e03c11afaa5f01d995e3a21bd92b415.tar.gz
rails-892e38c78e03c11afaa5f01d995e3a21bd92b415.tar.bz2
rails-892e38c78e03c11afaa5f01d995e3a21bd92b415.zip
Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin block
Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb10
-rw-r--r--activesupport/lib/active_support/evented_file_update_checker.rb8
-rw-r--r--activesupport/lib/active_support/reloader.rb8
-rw-r--r--activesupport/lib/active_support/testing/parallelization.rb42
4 files changed, 30 insertions, 38 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index 53a2b07536..de1fb1886c 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -108,12 +108,10 @@ module ActiveSupport
def lock_file(file_name, &block)
if File.exist?(file_name)
File.open(file_name, "r+") do |f|
- begin
- f.flock File::LOCK_EX
- yield
- ensure
- f.flock File::LOCK_UN
- end
+ f.flock File::LOCK_EX
+ yield
+ ensure
+ f.flock File::LOCK_UN
end
else
yield
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb
index 97e982eb05..b2ae3dd274 100644
--- a/activesupport/lib/active_support/evented_file_update_checker.rb
+++ b/activesupport/lib/active_support/evented_file_update_checker.rb
@@ -57,11 +57,9 @@ module ActiveSupport
# usage of attr_* macros for private attributes, but adds a lot of noise
# to our test suite. Thus, we lazy load it and disable warnings locally.
silence_warnings do
- begin
- require "listen"
- rescue LoadError => e
- raise LoadError, "Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile", e.backtrace
- end
+ require "listen"
+ rescue LoadError => e
+ raise LoadError, "Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile", e.backtrace
end
end
boot!
diff --git a/activesupport/lib/active_support/reloader.rb b/activesupport/lib/active_support/reloader.rb
index fea18e9712..2f81cd4f80 100644
--- a/activesupport/lib/active_support/reloader.rb
+++ b/activesupport/lib/active_support/reloader.rb
@@ -50,11 +50,9 @@ module ActiveSupport
def self.reload!
executor.wrap do
new.tap do |instance|
- begin
- instance.run!
- ensure
- instance.complete!
- end
+ instance.run!
+ ensure
+ instance.complete!
end
end
prepare!
diff --git a/activesupport/lib/active_support/testing/parallelization.rb b/activesupport/lib/active_support/testing/parallelization.rb
index c5d3a88131..63440069b1 100644
--- a/activesupport/lib/active_support/testing/parallelization.rb
+++ b/activesupport/lib/active_support/testing/parallelization.rb
@@ -69,31 +69,29 @@ module ActiveSupport
def start
@pool = @queue_size.times.map do |worker|
fork do
- begin
- DRb.stop_service
-
- after_fork(worker)
-
- queue = DRbObject.new_with_uri(@url)
-
- while job = queue.pop
- klass = job[0]
- method = job[1]
- reporter = job[2]
- result = Minitest.run_one_method(klass, method)
-
- begin
- queue.record(reporter, result)
- rescue DRb::DRbConnError
- result.failures.each do |failure|
- failure.exception = DRb::DRbRemoteError.new(failure.exception)
- end
- queue.record(reporter, result)
+ DRb.stop_service
+
+ after_fork(worker)
+
+ queue = DRbObject.new_with_uri(@url)
+
+ while job = queue.pop
+ klass = job[0]
+ method = job[1]
+ reporter = job[2]
+ result = Minitest.run_one_method(klass, method)
+
+ begin
+ queue.record(reporter, result)
+ rescue DRb::DRbConnError
+ result.failures.each do |failure|
+ failure.exception = DRb::DRbRemoteError.new(failure.exception)
end
+ queue.record(reporter, result)
end
- ensure
- run_cleanup(worker)
end
+ ensure
+ run_cleanup(worker)
end
end
end