From d4daf4e23b2cab7f02f49aa9e5c3cf328ce37407 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 17 Mar 2019 00:29:58 +0000 Subject: [PATCH] Support frozen_string_literal in issue, journal, and query (#26561). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Patch by Pavel Rosický. git-svn-id: http://svn.redmine.org/redmine/trunk@17980 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/journals_controller.rb | 4 ++-- app/helpers/issues_helper.rb | 12 ++++++------ app/helpers/queries_helper.rb | 10 +++++----- app/models/issue.rb | 4 ++-- app/models/journal.rb | 4 ++-- app/models/query.rb | 6 +++--- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index ade2a5f6a..4e31faea9 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -72,7 +72,7 @@ class JournalsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
(.*?)
}m, '[...]') - @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = +"#{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" rescue ActiveRecord::RecordNotFound render_404 diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 47b71e37d..b49fe8983 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -74,7 +74,7 @@ module IssuesHelper end def render_issue_subject_with_tree(issue) - s = '' + s = +'' ancestors = issue.root? ? [] : issue.ancestors.visible.to_a ancestors.each do |ancestor| s << '
' + content_tag('p', link_to_issue(ancestor, :project => (issue.project_id != ancestor.project_id))) @@ -91,9 +91,9 @@ module IssuesHelper def render_descendants_tree(issue) manage_relations = User.current.allowed_to?(:manage_subtasks, issue.project) - s = '' + s = +'
' issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level| - css = "issue issue-#{child.id} hascontextmenu #{child.css_classes}" + css = +"issue issue-#{child.id} hascontextmenu #{child.css_classes}" css << " idnt idnt-#{level}" if level > 0 buttons = manage_relations ? link_to(l(:label_delete_link_to_subtask), issue_path({:id => child.id, :issue => {:parent_issue_id => ''}, :back_url => issue_path(issue.id), :no_flash => '1'}), @@ -156,7 +156,7 @@ module IssuesHelper l_hours_short(issue.estimated_hours) else s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : "" - s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})" + s += " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})" s.html_safe end end @@ -170,7 +170,7 @@ module IssuesHelper link_to(l_hours_short(issue.spent_hours), path) else s = issue.spent_hours > 0 ? l_hours_short(issue.spent_hours) : "" - s << " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})" + s += " (#{l(:label_total)}: #{link_to l_hours_short(issue.total_spent_hours), path})" s.html_safe end end diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index f57a44ae5..24207b4c1 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -290,9 +290,9 @@ module QueriesHelper session_key = klass.name.underscore.to_sym if params[:query_id].present? - cond = "project_id IS NULL" - cond << " OR project_id = #{@project.id}" if @project - @query = klass.where(cond).find(params[:query_id]) + scope = klass.where(:project_id => nil) + scope = scope.or(klass.where(:project_id => @project)) if @project + @query = scope.find(params[:query_id]) raise ::Unauthorized unless @query.visible? @query.project = @project session[session_key] = {:id => @query.id, :project_id => @query.project_id} if use_session @@ -389,7 +389,7 @@ module QueriesHelper content_tag('h3', title) + "\n" + content_tag('ul', queries.collect {|query| - css = 'query' + css = +'query' css << ' selected' if query == @query content_tag('li', link_to(query.name, url_params.merge(:query_id => query), :class => css)) }.join("\n").html_safe, diff --git a/app/models/issue.rb b/app/models/issue.rb index c5589e73e..cd13fd3c5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -1352,7 +1352,7 @@ class Issue < ActiveRecord::Base # Returns a string of css classes that apply to the issue def css_classes(user=User.current) - s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}" + s = +"issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}" s << ' closed' if closed? s << ' overdue' if overdue? s << ' child' if child? diff --git a/app/models/journal.rb b/app/models/journal.rb index 39542ed9c..0077b548d 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -126,7 +126,7 @@ class Journal < ActiveRecord::Base # Returns a string of css classes def css_classes - s = 'journal' + s = +'journal' s << ' has-notes' unless notes.blank? s << ' has-details' unless details.blank? s << ' private-notes' if private_notes? diff --git a/app/models/query.rb b/app/models/query.rb index a06d75dee..d4d8f0434 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang @@ -1144,10 +1144,10 @@ class Query < ActiveRecord::Base end when "!*" sql = "#{db_table}.#{db_field} IS NULL" - sql << " OR #{db_table}.#{db_field} = ''" if (is_custom_filter || [:text, :string].include?(type_for(field))) + sql += " OR #{db_table}.#{db_field} = ''" if (is_custom_filter || [:text, :string].include?(type_for(field))) when "*" sql = "#{db_table}.#{db_field} IS NOT NULL" - sql << " AND #{db_table}.#{db_field} <> ''" if is_custom_filter + sql += " AND #{db_table}.#{db_field} <> ''" if is_custom_filter when ">=" if [:date, :date_past].include?(type_for(field)) sql = date_clause(db_table, db_field, parse_date(value.first), nil, is_custom_filter) -- 2.39.5