From 0bbe96cb72ede55638001121538f027080f8ba52 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 4 Jun 2023 02:32:19 +0900 Subject: [PATCH] Revert "Workaround for Style/RedundantBegin when using JRuby 9.2" ## Summary Revert https://github.com/rubocop/rubocop/commit/1533ece5b3d41ee8a1a2f154f23b7c1297e53a85 Current RuboCop (1.52) requires Ruby 2.7+ and JRuby 9.4+. So JRuby 9.2 has been dropped from runtime version. ## Additional Information https://github.com/jruby/jruby/issues/6642 has been resolved in JRuby 9.4: ```ruby # example.rb require 'ripper' class RipperParser < Ripper def on_parse_error(message) raise message end end RipperParser.new(<<~RUBY).parse foo do bar do end rescue NameError converted << nil end RUBY ``` ```console $ ruby -v jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913fda Java HotSpot(TM) 64-Bit Server VM 25.271-b09 on 1.8.0_271-b09 +jit [x86_64-darwin] $ ruby example.rb # No errors ``` --- lib/rubocop/cop/lint/shadowed_exception.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/rubocop/cop/lint/shadowed_exception.rb b/lib/rubocop/cop/lint/shadowed_exception.rb index 7de1be5ae7a..2c9ce9a72fa 100644 --- a/lib/rubocop/cop/lint/shadowed_exception.rb +++ b/lib/rubocop/cop/lint/shadowed_exception.rb @@ -121,18 +121,12 @@ def evaluate_exceptions(group) if rescued_exceptions.any? rescued_exceptions.each_with_object([]) do |exception, converted| - # FIXME: Workaround `rubocop:disable` comment for JRuby. - # https://github.com/jruby/jruby/issues/6642 - # rubocop:disable Style/RedundantBegin - begin - RuboCop::Util.silence_warnings do - # Avoid printing deprecation warnings about constants - converted << Kernel.const_get(exception.source) - end - rescue NameError - converted << nil + RuboCop::Util.silence_warnings do + # Avoid printing deprecation warnings about constants + converted << Kernel.const_get(exception.source) end - # rubocop:enable Style/RedundantBegin + rescue NameError + converted << nil end else # treat an empty `rescue` as `rescue StandardError`