]> source.dussan.org Git - redmine.git/commitdiff
Support frozen_string_literal in issue, journal, and query (#26561).
authorGo MAEDA <maeda@farend.jp>
Sun, 17 Mar 2019 00:29:58 +0000 (00:29 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 17 Mar 2019 00:29:58 +0000 (00:29 +0000)
Patch by Pavel Rosický.

git-svn-id: http://svn.redmine.org/redmine/trunk@17980 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/journals_controller.rb
app/helpers/issues_helper.rb
app/helpers/queries_helper.rb
app/models/issue.rb
app/models/journal.rb
app/models/query.rb

index ade2a5f6aa35dd32e66f66ed74b06fb07ee86e6d..4e31faea9984b4cc0cd2bad1a2418d4cc6ab2930 100644 (file)
@@ -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{<pre>(.*?)</pre>}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
index 47b71e37ddd3375982e0f0c371f4b596258203e7..b49fe8983a16960cc0b82f4f1a47b5f4f001c380 100644 (file)
@@ -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 << '<div>' + 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 = '<table class="list issues odd-even">'
+    s = +'<table class="list issues odd-even">'
     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
index f57a44ae559fe2241afce39f0220ddc69434515e..24207b4c18fcb1af1f90ae159a2f169f9a7ef64b 100644 (file)
@@ -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,
index c5589e73e55295bb4e6b42bea396c81b9a92a758..cd13fd3c55a862418f401117a9e13ac6694ffc89 100644 (file)
@@ -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?
index 39542ed9c587f0ff63d2500c802539a00b5ab75b..0077b548dc2f6eee0eea2bf67e5cb9dd1b8f2948 100644 (file)
@@ -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?
index a06d75dee125af8c52ff18854eefbefae58fb7f4..d4d8f0434896ccd79718762b45293c38a28ae3da 100644 (file)
@@ -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)