summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml15
-rw-r--r--.rubocop_todo.yml36
-rw-r--r--Gemfile4
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/queries_helper.rb2
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/user_preference.rb2
-rw-r--r--test/helpers/application_helper_test.rb8
-rw-r--r--test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb12
-rw-r--r--test/unit/member_test.rb2
11 files changed, 49 insertions, 38 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 3e5f0569f..77857c9cd 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -114,7 +114,10 @@ Naming/VariableNumber:
Naming/BinaryOperatorParameterName:
Enabled: false
-Naming/PredicateName:
+Naming/PredicateMethod:
+ Enabled: false
+
+Naming/PredicatePrefix:
Enabled: false
Performance/CollectionLiteralInLoop:
@@ -166,6 +169,13 @@ Rails/FindEach:
Rails/HelperInstanceVariable:
Enabled: false
+Rails/Output:
+ Exclude:
+ - 'config/routes.rb'
+ - 'lib/redmine/diff.rb'
+ - 'lib/redmine/diff_table.rb'
+ - 'test/unit/lib/redmine/scm/adapters/*.rb'
+
Rails/Pluck:
Exclude:
# `pluck` is not available in Gemfile
@@ -214,6 +224,9 @@ Style/BlockDelimiters:
- 'lib/redmine/string_array_diff/diff.rb'
- 'lib/redmine/string_array_diff/diffable.rb'
+Style/EmptyStringInsideInterpolation:
+ Enabled: false
+
Style/FetchEnvVar:
Enabled: false
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 3fffc0833..1aafe4925 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 20 --no-offense-counts --no-auto-gen-timestamp`
-# using RuboCop version 1.75.2.
+# using RuboCop version 1.76.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@@ -220,9 +220,6 @@ Lint/ParenthesesAsGroupedExpression:
- 'test/unit/attachment_test.rb'
- 'test/unit/lib/redmine/export/pdf_test.rb'
-Lint/ShadowingOuterLocalVariable:
- Enabled: false
-
# Configuration parameters: AllowComments, AllowNil.
Lint/SuppressedException:
Exclude:
@@ -331,7 +328,7 @@ Naming/VariableNumber:
- 'test/unit/project_test.rb'
# Configuration parameters: Severity, Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/ActiveRecordOverride:
Exclude:
- 'app/models/email_address.rb'
@@ -402,7 +399,7 @@ Rails/EagerEvaluationLogMessage:
- 'app/controllers/application_controller.rb'
# Configuration parameters: Include.
-# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb
+# Include: **/app/**/*.rb, **/config/**/*.rb, **/lib/**/*.rb
Rails/Exit:
Exclude:
- 'config/environment.rb'
@@ -410,7 +407,7 @@ Rails/Exit:
- 'config/routes.rb'
# Configuration parameters: Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/changeset.rb'
@@ -425,7 +422,7 @@ Rails/HasAndBelongsToMany:
- 'app/models/user.rb'
# Configuration parameters: Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/auth_source.rb'
@@ -459,7 +456,7 @@ Rails/I18nLocaleTexts:
- 'app/models/mailer.rb'
# Configuration parameters: IgnoreScopes, Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/InverseOf:
Exclude:
- 'app/models/board.rb'
@@ -483,7 +480,7 @@ Rails/InverseOf:
- 'app/models/wiki_page.rb'
# Configuration parameters: Include.
-# Include: app/controllers/**/*.rb, app/mailers/**/*.rb
+# Include: **/app/controllers/**/*.rb, **/app/mailers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/projects_controller.rb'
@@ -495,7 +492,7 @@ Rails/LinkToBlank:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
-# Include: config/routes.rb, config/routes/**/*.rb
+# Include: **/config/routes.rb, **/config/routes/**/*.rb
Rails/MatchRoute:
Exclude:
- 'config/routes.rb'
@@ -504,15 +501,6 @@ Rails/MatchRoute:
Rails/NegateInclude:
Enabled: false
-# This cop supports unsafe autocorrection (--autocorrect-all).
-# Configuration parameters: Include.
-# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
-Rails/Output:
- Exclude:
- - 'config/routes.rb'
- - 'lib/redmine/diff.rb'
- - 'lib/redmine/diff_table.rb'
-
Rails/OutputSafety:
Enabled: false
@@ -541,7 +529,7 @@ Rails/Present:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/ReadWriteAttribute:
Exclude:
- 'app/models/auth_source_ldap.rb'
@@ -600,7 +588,7 @@ Rails/TimeZone:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Include.
-# Include: app/models/**/*.rb
+# Include: **/app/models/**/*.rb
Rails/Validation:
Enabled: false
@@ -708,8 +696,8 @@ Style/CaseLikeIf:
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules.
# SupportedStyles: nested, compact
-# SupportedStylesForClasses: , nested, compact
-# SupportedStylesForModules: , nested, compact
+# SupportedStylesForClasses: ~, nested, compact
+# SupportedStylesForModules: ~, nested, compact
Style/ClassAndModuleChildren:
Enabled: false
diff --git a/Gemfile b/Gemfile
index 2b40e9e5e..3045f0e50 100644
--- a/Gemfile
+++ b/Gemfile
@@ -111,9 +111,9 @@ group :test do
gem "capybara", ">= 3.39"
gem 'selenium-webdriver', '>= 4.11.0'
# RuboCop
- gem 'rubocop', '~> 1.75.2', require: false
+ gem 'rubocop', '~> 1.76.0', require: false
gem 'rubocop-performance', '~> 1.25.0', require: false
- gem 'rubocop-rails', '~> 2.31.0', require: false
+ gem 'rubocop-rails', '~> 2.32.0', require: false
gem 'bundle-audit', require: false
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 99a760c1d..285528422 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -518,6 +518,8 @@ module ApplicationHelper
def render_flash_messages
s = +''
flash.each do |k, v|
+ next unless v.is_a?(String)
+
s << content_tag('div', notice_icon(k) + v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
end
s.html_safe
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index ca7168f27..3aef7083a 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -169,7 +169,7 @@ module QueriesHelper
group_name = format_object(group)
end
group_name ||= ""
- group_count = result_count_by_group ? result_count_by_group[group] : nil
+ group_count = result_count_by_group&.[](group)
group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index bfef3533a..576840843 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1175,7 +1175,7 @@ class Issue < ApplicationRecord
if leaf?
spent_hours
else
- self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f || 0.0
+ self_and_descendants.joins(:time_entries).sum("#{TimeEntry.table_name}.hours").to_f
end
end
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 8b19d9a5a..e1842b131 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -73,7 +73,7 @@ class UserPreference < ApplicationRecord
if has_attribute? attr_name
super
else
- others ? others[attr_name] : nil
+ others&.[](attr_name)
end
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index c9ec72467..2e2e8b933 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -2403,6 +2403,14 @@ class ApplicationHelperTest < Redmine::HelperTest
assert_equal expected, format_activity_description(text)
end
+ def test_render_flash_messages_should_ignore_non_string_values
+ flash[:array_value] = ['1', '2']
+ flash[:hash_value] = { foo: 'bar' }
+
+ result = render_flash_messages
+ assert_equal '', result
+ end
+
private
def wiki_links_with_special_characters
diff --git a/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
index d267abbf9..bb0c5d450 100644
--- a/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/common_mark/formatter_test.rb
@@ -226,7 +226,7 @@ class Redmine::WikiFormatting::CommonMark::FormatterTest < ActionView::TestCase
text = STR_WITH_PRE.join("\n\n")
replacement = "New text"
- assert_equal [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
+ assert_equal [STR_WITH_PRE[0..1], "New text"].join("\n\n"),
@formatter.new(text).update_section(3, replacement)
end
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index 32280cfdf..678d4c6b2 100644
--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
@@ -466,19 +466,19 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
replacement = "New text"
assert_equal(
- [STR_WITHOUT_PRE[0], replacement, STR_WITHOUT_PRE[2..4]].flatten.join("\n\n"),
+ [STR_WITHOUT_PRE[0], replacement, STR_WITHOUT_PRE[2..4]].join("\n\n"),
@formatter.new(TEXT_WITHOUT_PRE).update_section(2, replacement)
)
assert_equal(
- [STR_WITHOUT_PRE[0..1], replacement, STR_WITHOUT_PRE[4]].flatten.join("\n\n"),
+ [STR_WITHOUT_PRE[0..1], replacement, STR_WITHOUT_PRE[4]].join("\n\n"),
@formatter.new(TEXT_WITHOUT_PRE).update_section(3, replacement)
)
assert_equal(
- [STR_WITHOUT_PRE[0..2], replacement, STR_WITHOUT_PRE[4]].flatten.join("\n\n"),
+ [STR_WITHOUT_PRE[0..2], replacement, STR_WITHOUT_PRE[4]].join("\n\n"),
@formatter.new(TEXT_WITHOUT_PRE).update_section(5, replacement)
)
assert_equal(
- [STR_WITHOUT_PRE[0..3], replacement].flatten.join("\n\n"),
+ [STR_WITHOUT_PRE[0..3], replacement].join("\n\n"),
@formatter.new(TEXT_WITHOUT_PRE).update_section(6, replacement)
)
assert_equal TEXT_WITHOUT_PRE, @formatter.new(TEXT_WITHOUT_PRE).update_section(0, replacement)
@@ -488,7 +488,7 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
def test_update_section_with_hash_should_update_the_requested_section
replacement = "New text"
assert_equal(
- [STR_WITHOUT_PRE[0], replacement, STR_WITHOUT_PRE[2..4]].flatten.join("\n\n"),
+ [STR_WITHOUT_PRE[0], replacement, STR_WITHOUT_PRE[2..4]].join("\n\n"),
@formatter.new(TEXT_WITHOUT_PRE).
update_section(2, replacement, ActiveSupport::Digest.hexdigest(STR_WITHOUT_PRE[1]))
)
@@ -552,7 +552,7 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
text = STR_WITH_PRE.join("\n\n")
replacement = "New text"
assert_equal(
- [STR_WITH_PRE[0..1], "New text"].flatten.join("\n\n"),
+ [STR_WITH_PRE[0..1], "New text"].join("\n\n"),
@formatter.new(text).update_section(3, replacement)
)
end
diff --git a/test/unit/member_test.rb b/test/unit/member_test.rb
index 42fba4783..df9088027 100644
--- a/test/unit/member_test.rb
+++ b/test/unit/member_test.rb
@@ -108,7 +108,7 @@ class MemberTest < ActiveSupport::TestCase
assert !member.save
assert_include I18n.translate('activerecord.errors.messages.empty'), member.errors[:role]
assert_equal 'Rôle doit être renseigné(e)',
- [member.errors.full_messages].flatten.join
+ [member.errors.full_messages].join
end
def test_validate_member_role