summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2025-04-11 09:00:58 +0000
committerGo MAEDA <maeda@farend.jp>2025-04-11 09:00:58 +0000
commit5668aa651f76e5bb084b8c78c58d975e09560dcb (patch)
tree8733d840705245457c11a6df3a2aedbb44b20dfd
parentc77c1d078b96748956d87176db8ec66d0db70ccb (diff)
downloadredmine-5668aa651f76e5bb084b8c78c58d975e09560dcb.tar.gz
redmine-5668aa651f76e5bb084b8c78c58d975e09560dcb.zip
Fix RuboCop Lint/SuppressedExceptionInNumberConversion (#41884).
git-svn-id: https://svn.redmine.org/redmine/trunk@23626 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--.rubocop_todo.yml6
-rw-r--r--lib/redmine/core_ext/string/conversions.rb2
-rw-r--r--test/unit/query_test.rb2
3 files changed, 2 insertions, 8 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 682017a02..9c4c38b69 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -232,12 +232,6 @@ Lint/SuppressedException:
- 'lib/redmine/scm/adapters/cvs_adapter.rb'
- 'lib/redmine/scm/adapters/subversion_adapter.rb'
-# This cop supports unsafe autocorrection (--autocorrect-all).
-Lint/SuppressedExceptionInNumberConversion:
- Exclude:
- - 'lib/redmine/core_ext/string/conversions.rb'
- - 'test/unit/query_test.rb'
-
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
diff --git a/lib/redmine/core_ext/string/conversions.rb b/lib/redmine/core_ext/string/conversions.rb
index e98e400e4..bbf57e363 100644
--- a/lib/redmine/core_ext/string/conversions.rb
+++ b/lib/redmine/core_ext/string/conversions.rb
@@ -39,7 +39,7 @@ module Redmine
end
# 2,5 => 2.5
s.tr!(',', '.')
- begin; Kernel.Float(s); rescue; nil; end
+ Kernel.Float(s, exception: false)
end
end
end
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index ff2cef903..24f4b1404 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -2326,7 +2326,7 @@ class QueryTest < ActiveSupport::TestCase
values =
issues.filter_map do |i|
begin
- Kernel.Float(i.custom_value_for(c.custom_field).to_s)
+ Kernel.Float(i.custom_value_for(c.custom_field).to_s, exception: false)
rescue
nil
end