Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make a few more files ready to handle frozen string literals

Jan Sandbrinkbc861f09295a
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index a5c285d01e0..9f486f37550 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -475,8 +475,6 @@ module ApplicationHelper
def password_complexity_requirements
rules = OpenProject::Passwords::Evaluator.rules_description
- # use 0..0, so this doesn't fail if rules is an empty string
- rules[0] = rules[0..0].upcase
s = raw "<em>" + OpenProject::Passwords::Evaluator.min_length_description + "</em>"
s += raw "<br /><em>" + rules + "</em>" unless rules.empty?
diff --git a/app/helpers/mail_layout_helper.rb b/app/helpers/mail_layout_helper.rb
index f9c897cd852..e76cdaa6c85 100644
--- a/app/helpers/mail_layout_helper.rb
+++ b/app/helpers/mail_layout_helper.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
diff --git a/lib/open_project/passwords.rb b/lib/open_project/passwords.rb
index ed5cc7aa026..df62e3a6a75 100644
--- a/lib/open_project/passwords.rb
+++ b/lib/open_project/passwords.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -152,7 +154,7 @@ module OpenProject
"]", "^", "_", "`", "{", "|", "}", "~"]
begin
- password = ""
+ password = +""
length = [RANDOM_PASSWORD_MIN_LENGTH, Evaluator.min_length].max
length.times { |_i| password << chars[SecureRandom.random_number(chars.size - 1)] }
end while not Evaluator.conforming? password
diff --git a/lib/tabular_form_builder.rb b/lib/tabular_form_builder.rb
index 21196056ca2..bb6f823c934 100644
--- a/lib/tabular_form_builder.rb
+++ b/lib/tabular_form_builder.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -44,7 +46,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
input_options, label_options = extract_from options
if field_has_errors?(field)
- input_options[:class] << " -error"
+ add_error_class(input_options)
end
label = label_for_field(field, label_options)
@@ -92,7 +94,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
input_options, label_options = extract_from options
if field_has_errors?(field)
- input_options[:class] << " -error"
+ add_error_class(input_options)
end
@object_name.to_s.sub!(/\[\]$/, "") || @object_name.to_s.sub!(/\[\]\]$/, "]")
@@ -130,7 +132,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
label_options[:for] = "#{sanitized_object_name}_#{field}_#{value.downcase}"
if field_has_errors?(field)
- input_options[:class] << " -error"
+ add_error_class(input_options)
end
label = label_for_field(field, label_options)
@@ -146,7 +148,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
end
if field_has_errors?(field)
- html_options[:class] << " -error"
+ add_error_class(html_options)
end
merge_required_attributes(options[:required], html_options)
@@ -239,14 +241,14 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def field_container_css_class(selector, options)
classes = if TEXT_LIKE_FIELDS.include?(selector)
- "form--text-field-container"
+ ["form--text-field-container"]
else
- "form--#{selector.to_s.tr('_', '-')}-container"
+ ["form--#{selector.to_s.tr('_', '-')}-container"]
end
- classes << (" #{options.fetch(:container_class, '')}")
+ classes << options[:container_class]
- classes.strip
+ classes.compact
end
##
@@ -295,7 +297,7 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
def label_for_field_errors(content, options, field)
if field_has_errors?(field)
- options[:class] << " -error"
+ add_error_class(options)
error_label = I18n.t("errors.field_erroneous_label",
full_errors: @object.errors.full_messages_for(field).join(" "))
content << content_tag("p", error_label, class: "hidden-for-sighted")
@@ -370,4 +372,8 @@ class TabularFormBuilder < ActionView::Helpers::FormBuilder
method.to_s.camelize
end
end
+
+ def add_error_class(options)
+ options[:class] = Array(options[:class]) + ["-error"]
+ end
end
diff --git a/modules/bim/app/views/bim/bcf/issues/_render_issues.html.erb b/modules/bim/app/views/bim/bcf/issues/_render_issues.html.erb
index 70c7421c270..9ff615bfe14 100644
--- a/modules/bim/app/views/bim/bcf/issues/_render_issues.html.erb
+++ b/modules/bim/app/views/bim/bcf/issues/_render_issues.html.erb
@@ -3,7 +3,7 @@
<% issues.each do |issue| %>
<% status_id = issue.work_package&.status_id %>
<% highlighting_class = status_id.present? ? "__hl_background_status_#{status_id}" : "" %>
- <% highlighting_class << " -failed" if issue.errors.present? %>
+ <% highlighting_class += " -failed" if issue.errors.present? %>
<div class="<%= highlighting_class %>">
<p>
<% if issue.work_package %>
diff --git a/spec/lib/api/v3/formatter/txt_charset_spec.rb b/spec/lib/api/v3/formatter/txt_charset_spec.rb
index 02668adf0e7..4ee95852337 100644
--- a/spec/lib/api/v3/formatter/txt_charset_spec.rb
+++ b/spec/lib/api/v3/formatter/txt_charset_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -29,7 +31,7 @@
require "spec_helper"
RSpec.describe API::V3::Formatter::TxtCharset do
- let(:umlaut_object_ascii) { "ümläutß".force_encoding("ASCII-8BIT") }
+ let(:umlaut_object_ascii) { (+"ümläutß").force_encoding("ASCII-8BIT") }
let(:umlaut_object_utf8) { umlaut_object_ascii.force_encoding("utf-8") }
let(:env) { {} }