Commit 6faa1831 authored by maeda's avatar maeda
Browse files

Support frozen_string_literal in app/**/*.rb (#26561).

Contributed by Pavel Rosický.


git-svn-id: https://svn.redmine.org/redmine/trunk@17987 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 1a67aaf2
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -117,7 +117,7 @@ class MessagesController < ApplicationController ...@@ -117,7 +117,7 @@ class MessagesController < ApplicationController
@subject = @message.subject @subject = @message.subject
@subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
@content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " @content = +"#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
@content << @message.content.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" @content << @message.content.to_s.strip.gsub(%r{<pre>(.*?)</pre>}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
end end
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -22,8 +22,7 @@ class SearchController < ApplicationController ...@@ -22,8 +22,7 @@ class SearchController < ApplicationController
accept_api_auth :index accept_api_auth :index
def index def index
@question = params[:q] || "" @question = params[:q]&.strip || ""
@question.strip!
@all_words = params[:all_words] ? params[:all_words].present? : true @all_words = params[:all_words] ? params[:all_words].present? : true
@titles_only = params[:titles_only] ? params[:titles_only].present? : false @titles_only = params[:titles_only] ? params[:titles_only].present? : false
@search_attachments = params[:attachments].presence || '0' @search_attachments = params[:attachments].presence || '0'
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -292,7 +292,7 @@ module ApplicationHelper ...@@ -292,7 +292,7 @@ module ApplicationHelper
end end
def toggle_link(name, id, options={}) def toggle_link(name, id, options={})
onclick = "$('##{id}').toggle(); " onclick = +"$('##{id}').toggle(); "
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll] onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll]
onclick << "return false;" onclick << "return false;"
...@@ -336,7 +336,7 @@ module ApplicationHelper ...@@ -336,7 +336,7 @@ module ApplicationHelper
# The given collection may be a subset of the whole project tree # The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen) # (eg. some intermediate nodes are private and can not be seen)
def render_project_nested_lists(projects, &block) def render_project_nested_lists(projects, &block)
s = '' s = +''
if projects.any? if projects.any?
ancestors = [] ancestors = []
original_project = @project original_project = @project
...@@ -366,7 +366,7 @@ module ApplicationHelper ...@@ -366,7 +366,7 @@ module ApplicationHelper
end end
def render_page_hierarchy(pages, node=nil, options={}) def render_page_hierarchy(pages, node=nil, options={})
content = '' content = +''
if pages[node] if pages[node]
content << "<ul class=\"pages-hierarchy\">\n" content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page| pages[node].each do |page|
...@@ -383,7 +383,7 @@ module ApplicationHelper ...@@ -383,7 +383,7 @@ module ApplicationHelper
# Renders flash messages # Renders flash messages
def render_flash_messages def render_flash_messages
s = '' s = +''
flash.each do |k,v| flash.each do |k,v|
s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}") s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
end end
...@@ -422,7 +422,7 @@ module ApplicationHelper ...@@ -422,7 +422,7 @@ module ApplicationHelper
def render_projects_for_jump_box(projects, selected=nil) def render_projects_for_jump_box(projects, selected=nil)
jump = params[:jump].presence || current_menu_item jump = params[:jump].presence || current_menu_item
s = ''.html_safe s = (+'').html_safe
project_tree(projects) do |project, level| project_tree(projects) do |project, level|
padding = level * 16 padding = level * 16
text = content_tag('span', project.name, :style => "padding-left:#{padding}px;") text = content_tag('span', project.name, :style => "padding-left:#{padding}px;")
...@@ -483,7 +483,7 @@ module ApplicationHelper ...@@ -483,7 +483,7 @@ module ApplicationHelper
end end
def principals_check_box_tags(name, principals) def principals_check_box_tags(name, principals)
s = '' s = +''
principals.each do |principal| principals.each do |principal|
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n" s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
end end
...@@ -492,11 +492,11 @@ module ApplicationHelper ...@@ -492,11 +492,11 @@ module ApplicationHelper
# Returns a string for users/groups option tags # Returns a string for users/groups option tags
def principals_options_for_select(collection, selected=nil) def principals_options_for_select(collection, selected=nil)
s = '' s = +''
if collection.include?(User.current) if collection.include?(User.current)
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id) s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
end end
groups = '' groups = +''
collection.sort.each do |element| collection.sort.each do |element|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>) (element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
...@@ -728,7 +728,7 @@ module ApplicationHelper ...@@ -728,7 +728,7 @@ module ApplicationHelper
def parse_non_pre_blocks(text, obj, macros) def parse_non_pre_blocks(text, obj, macros)
s = StringScanner.new(text) s = StringScanner.new(text)
tags = [] tags = []
parsed = '' parsed = +''
while !s.eos? while !s.eos?
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im) s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im)
text, full_tag, closing, tag = s[1], s[2], s[3], s[4] text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
...@@ -1208,10 +1208,10 @@ module ApplicationHelper ...@@ -1208,10 +1208,10 @@ module ApplicationHelper
if headings.empty? if headings.empty?
'' ''
else else
div_class = 'toc' div_class = +'toc'
div_class << ' right' if right_align div_class << ' right' if right_align
div_class << ' left' if left_align div_class << ' left' if left_align
out = "<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>" out = +"<ul class=\"#{div_class}\"><li><strong>#{l :label_table_of_contents}</strong></li><li>"
root = headings.map(&:first).min root = headings.map(&:first).min
current = root current = root
started = false started = false
...@@ -1272,7 +1272,7 @@ module ApplicationHelper ...@@ -1272,7 +1272,7 @@ module ApplicationHelper
# Renders a list of error messages # Renders a list of error messages
def render_error_messages(errors) def render_error_messages(errors)
html = "" html = +""
if errors.present? if errors.present?
html << "<div id='errorExplanation'><ul>\n" html << "<div id='errorExplanation'><ul>\n"
errors.each do |error| errors.each do |error|
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -59,7 +59,7 @@ module CalendarsHelper ...@@ -59,7 +59,7 @@ module CalendarsHelper
end end
def calendar_day_css_classes(calendar, day) def calendar_day_css_classes(calendar, day)
css = day.month==calendar.month ? 'even' : 'odd' css = day.month==calendar.month ? +'even' : +'odd'
css << " today" if User.current.today == day css << " today" if User.current.today == day
css << " nwday" if non_working_week_days.include?(day.cwday) css << " nwday" if non_working_week_days.include?(day.cwday)
css css
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -21,14 +21,14 @@ module ContextMenusHelper ...@@ -21,14 +21,14 @@ module ContextMenusHelper
def context_menu_link(name, url, options={}) def context_menu_link(name, url, options={})
options[:class] ||= '' options[:class] ||= ''
if options.delete(:selected) if options.delete(:selected)
options[:class] << ' icon-checked disabled' options[:class] += ' icon-checked disabled'
options[:disabled] = true options[:disabled] = true
end end
if options.delete(:disabled) if options.delete(:disabled)
options.delete(:method) options.delete(:method)
options.delete(:data) options.delete(:data)
options[:onclick] = 'return false;' options[:onclick] = 'return false;'
options[:class] << ' disabled' options[:class] += ' disabled'
url = '#' url = '#'
end end
link_to h(name), url, options link_to h(name), url, options
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -69,7 +69,7 @@ module CustomFieldsHelper ...@@ -69,7 +69,7 @@ module CustomFieldsHelper
def custom_field_tag_name(prefix, custom_field) def custom_field_tag_name(prefix, custom_field)
name = "#{prefix}[custom_field_values][#{custom_field.id}]" name = "#{prefix}[custom_field_values][#{custom_field.id}]"
name << "[]" if custom_field.multiple? name += "[]" if custom_field.multiple?
name name
end end
...@@ -80,7 +80,7 @@ module CustomFieldsHelper ...@@ -80,7 +80,7 @@ module CustomFieldsHelper
# Return custom field html tag corresponding to its format # Return custom field html tag corresponding to its format
def custom_field_tag(prefix, custom_value) def custom_field_tag(prefix, custom_value)
css = "#{custom_value.custom_field.field_format}_cf" css = "#{custom_value.custom_field.field_format}_cf"
css << ' wiki-edit' if custom_value.custom_field.full_text_formatting? css += ' wiki-edit' if custom_value.custom_field.full_text_formatting?
custom_value.custom_field.format.edit_tag self, custom_value.custom_field.format.edit_tag self,
custom_field_tag_id(prefix, custom_value.custom_field), custom_field_tag_id(prefix, custom_value.custom_field),
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -42,14 +42,14 @@ module ProjectsHelper ...@@ -42,14 +42,14 @@ module ProjectsHelper
selected = (parent_id.blank? ? nil : Project.find(parent_id)) selected = (parent_id.blank? ? nil : Project.find(parent_id))
end end
options = '' options = +''
options << "<option value=''>&nbsp;</option>" if project.allowed_parents.include?(nil) options << "<option value=''>&nbsp;</option>" if project.allowed_parents.include?(nil)
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
end end
def render_project_action_links def render_project_action_links
links = "".html_safe links = (+"").html_safe
if User.current.allowed_to?(:add_project, nil, :global => true) if User.current.allowed_to?(:add_project, nil, :global => true)
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add') links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
end end
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -43,7 +43,7 @@ module RepositoriesHelper ...@@ -43,7 +43,7 @@ module RepositoriesHelper
def render_properties(properties) def render_properties(properties)
unless properties.nil? || properties.empty? unless properties.nil? || properties.empty?
content = '' content = +''
properties.keys.sort.each do |property| properties.keys.sort.each do |property|
content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>".html_safe) content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>".html_safe)
end end
...@@ -87,10 +87,10 @@ module RepositoriesHelper ...@@ -87,10 +87,10 @@ module RepositoriesHelper
def render_changes_tree(tree) def render_changes_tree(tree)
return '' if tree.nil? return '' if tree.nil?
output = '' output = +''
output << '<ul>' output << '<ul>'
tree.keys.sort.each do |file| tree.keys.sort.each do |file|
style = 'change' style = +'change'
text = File.basename(h(file)) text = File.basename(h(file))
if s = tree[file][:s] if s = tree[file][:s]
style << ' folder' style << ' folder'
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -22,7 +22,7 @@ module SearchHelper ...@@ -22,7 +22,7 @@ module SearchHelper
return text unless text && tokens && !tokens.empty? return text unless text && tokens && !tokens.empty?
re_tokens = tokens.collect {|t| Regexp.escape(t)} re_tokens = tokens.collect {|t| Regexp.escape(t)}
regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
result = '' result = +''
text.split(regexp).each_with_index do |words, i| text.split(regexp).each_with_index do |words, i|
if result.length > 1200 if result.length > 1200
# maximum length of the preview reached # maximum length of the preview reached
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -22,10 +22,10 @@ module WikiHelper ...@@ -22,10 +22,10 @@ module WikiHelper
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0) def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
pages = pages.group_by(&:parent) unless pages.is_a?(Hash) pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
s = ''.html_safe s = (+'').html_safe
if pages.has_key?(parent) if pages.has_key?(parent)
pages[parent].each do |page| pages[parent].each do |page|
attrs = "value='#{page.id}'" attrs = +"value='#{page.id}'"
attrs << " selected='selected'" if selected == page attrs << " selected='selected'" if selected == page
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : '' indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : ''
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -80,8 +80,8 @@ class Mailer < ActionMailer::Base ...@@ -80,8 +80,8 @@ class Mailer < ActionMailer::Base
@user = user @user = user
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue) @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]" subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
subject << " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject? subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
subject << " #{issue.subject}" subject += " #{issue.subject}"
mail :to => user, mail :to => user,
:subject => subject :subject => subject
end end
...@@ -108,8 +108,8 @@ class Mailer < ActionMailer::Base ...@@ -108,8 +108,8 @@ class Mailer < ActionMailer::Base
references issue references issue
@author = journal.user @author = journal.user
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] " s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject? s += "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
s << issue.subject s += issue.subject
@issue = issue @issue = issue
@user = user @user = user
@journal = journal @journal = journal
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -71,7 +71,7 @@ class Principal < ActiveRecord::Base ...@@ -71,7 +71,7 @@ class Principal < ActiveRecord::Base
where({}) where({})
else else
pattern = "%#{q}%" pattern = "%#{q}%"
sql = "LOWER(#{table_name}.login) LIKE LOWER(:p)" sql = +"LOWER(#{table_name}.login) LIKE LOWER(:p)"
sql << " OR #{table_name}.id IN (SELECT user_id FROM #{EmailAddress.table_name} WHERE LOWER(address) LIKE LOWER(:p))" sql << " OR #{table_name}.id IN (SELECT user_id FROM #{EmailAddress.table_name} WHERE LOWER(address) LIKE LOWER(:p))"
params = {:p => pattern} params = {:p => pattern}
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -181,7 +181,7 @@ class Project < ActiveRecord::Base ...@@ -181,7 +181,7 @@ class Project < ActiveRecord::Base
base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}") base_statement = (perm && perm.read? ? "#{Project.table_name}.status <> #{Project::STATUS_ARCHIVED}" : "#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
if !options[:skip_pre_condition] && perm && perm.project_module if !options[:skip_pre_condition] && perm && perm.project_module
# If the permission belongs to a project module, make sure the module is enabled # If the permission belongs to a project module, make sure the module is enabled
base_statement << " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em WHERE em.project_id = #{Project.table_name}.id AND em.name='#{perm.project_module}')" base_statement += " AND EXISTS (SELECT 1 AS one FROM #{EnabledModule.table_name} em WHERE em.project_id = #{Project.table_name}.id AND em.name='#{perm.project_module}')"
end end
if project = options[:project] if project = options[:project]
project_statement = project.project_condition(options[:with_subprojects]) project_statement = project.project_condition(options[:with_subprojects])
...@@ -622,7 +622,7 @@ class Project < ActiveRecord::Base ...@@ -622,7 +622,7 @@ class Project < ActiveRecord::Base
end end
def css_classes def css_classes
s = 'project' s = +'project'
s << ' root' if root? s << ' root' if root?
s << ' child' if child? s << ' child' if child?
s << (leaf? ? ' leaf' : ' parent') s << (leaf? ? ' leaf' : ' parent')
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
...@@ -234,8 +234,8 @@ class Repository < ActiveRecord::Base ...@@ -234,8 +234,8 @@ class Repository < ActiveRecord::Base
def diff_format_revisions(cs, cs_to, sep=':') def diff_format_revisions(cs, cs_to, sep=':')
text = "" text = ""
text << cs_to.format_identifier + sep if cs_to text += cs_to.format_identifier + sep if cs_to
text << cs.format_identifier if cs text += cs.format_identifier if cs
text text
end end
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang # Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false # frozen_string_literal: true
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang