Commit 6faa1831 authored by maeda's avatar maeda

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
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -117,7 +117,7 @@ class MessagesController < ApplicationController
@subject = @message.subject
@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"
end
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -22,8 +22,7 @@ class SearchController < ApplicationController
accept_api_auth :index
def index
@question = params[:q] || ""
@question.strip!
@question = params[:q]&.strip || ""
@all_words = params[:all_words] ? params[:all_words].present? : true
@titles_only = params[:titles_only] ? params[:titles_only].present? : false
@search_attachments = params[:attachments].presence || '0'
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -292,7 +292,7 @@ module ApplicationHelper
end
def toggle_link(name, id, options={})
onclick = "$('##{id}').toggle(); "
onclick = +"$('##{id}').toggle(); "
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll]
onclick << "return false;"
......@@ -336,7 +336,7 @@ module ApplicationHelper
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
def render_project_nested_lists(projects, &block)
s = ''
s = +''
if projects.any?
ancestors = []
original_project = @project
......@@ -366,7 +366,7 @@ module ApplicationHelper
end
def render_page_hierarchy(pages, node=nil, options={})
content = ''
content = +''
if pages[node]
content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page|
......@@ -383,7 +383,7 @@ module ApplicationHelper
# Renders flash messages
def render_flash_messages
s = ''
s = +''
flash.each do |k,v|
s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
end
......@@ -422,7 +422,7 @@ module ApplicationHelper
def render_projects_for_jump_box(projects, selected=nil)
jump = params[:jump].presence || current_menu_item
s = ''.html_safe
s = (+'').html_safe
project_tree(projects) do |project, level|
padding = level * 16
text = content_tag('span', project.name, :style => "padding-left:#{padding}px;")
......@@ -483,7 +483,7 @@ module ApplicationHelper
end
def principals_check_box_tags(name, principals)
s = ''
s = +''
principals.each do |principal|
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
end
......@@ -492,11 +492,11 @@ module ApplicationHelper
# Returns a string for users/groups option tags
def principals_options_for_select(collection, selected=nil)
s = ''
s = +''
if collection.include?(User.current)
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id)
end
groups = ''
groups = +''
collection.sort.each do |element|
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>)
......@@ -728,7 +728,7 @@ module ApplicationHelper
def parse_non_pre_blocks(text, obj, macros)
s = StringScanner.new(text)
tags = []
parsed = ''
parsed = +''
while !s.eos?
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im)
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
......@@ -1208,10 +1208,10 @@ module ApplicationHelper
if headings.empty?
''
else
div_class = 'toc'
div_class = +'toc'
div_class << ' right' if right_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
current = root
started = false
......@@ -1272,7 +1272,7 @@ module ApplicationHelper
# Renders a list of error messages
def render_error_messages(errors)
html = ""
html = +""
if errors.present?
html << "<div id='errorExplanation'><ul>\n"
errors.each do |error|
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -59,7 +59,7 @@ module CalendarsHelper
end
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 << " nwday" if non_working_week_days.include?(day.cwday)
css
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -21,14 +21,14 @@ module ContextMenusHelper
def context_menu_link(name, url, options={})
options[:class] ||= ''
if options.delete(:selected)
options[:class] << ' icon-checked disabled'
options[:class] += ' icon-checked disabled'
options[:disabled] = true
end
if options.delete(:disabled)
options.delete(:method)
options.delete(:data)
options[:onclick] = 'return false;'
options[:class] << ' disabled'
options[:class] += ' disabled'
url = '#'
end
link_to h(name), url, options
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -69,7 +69,7 @@ module CustomFieldsHelper
def custom_field_tag_name(prefix, custom_field)
name = "#{prefix}[custom_field_values][#{custom_field.id}]"
name << "[]" if custom_field.multiple?
name += "[]" if custom_field.multiple?
name
end
......@@ -80,7 +80,7 @@ module CustomFieldsHelper
# Return custom field html tag corresponding to its format
def custom_field_tag(prefix, custom_value)
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_field_tag_id(prefix, custom_value.custom_field),
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -42,14 +42,14 @@ module ProjectsHelper
selected = (parent_id.blank? ? nil : Project.find(parent_id))
end
options = ''
options = +''
options << "<option value=''>&nbsp;</option>" if project.allowed_parents.include?(nil)
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')
end
def render_project_action_links
links = "".html_safe
links = (+"").html_safe
if User.current.allowed_to?(:add_project, nil, :global => true)
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
end
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -43,7 +43,7 @@ module RepositoriesHelper
def render_properties(properties)
unless properties.nil? || properties.empty?
content = ''
content = +''
properties.keys.sort.each do |property|
content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>".html_safe)
end
......@@ -87,10 +87,10 @@ module RepositoriesHelper
def render_changes_tree(tree)
return '' if tree.nil?
output = ''
output = +''
output << '<ul>'
tree.keys.sort.each do |file|
style = 'change'
style = +'change'
text = File.basename(h(file))
if s = tree[file][:s]
style << ' folder'
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -22,7 +22,7 @@ module SearchHelper
return text unless text && tokens && !tokens.empty?
re_tokens = tokens.collect {|t| Regexp.escape(t)}
regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
result = ''
result = +''
text.split(regexp).each_with_index do |words, i|
if result.length > 1200
# maximum length of the preview reached
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -22,10 +22,10 @@ module WikiHelper
def wiki_page_options_for_select(pages, selected = nil, parent = nil, level = 0)
pages = pages.group_by(&:parent) unless pages.is_a?(Hash)
s = ''.html_safe
s = (+'').html_safe
if pages.has_key?(parent)
pages[parent].each do |page|
attrs = "value='#{page.id}'"
attrs = +"value='#{page.id}'"
attrs << " selected='selected'" if selected == page
indent = (level > 0) ? ('&nbsp;' * level * 2 + '&#187; ') : ''
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -80,8 +80,8 @@ class Mailer < ActionMailer::Base
@user = user
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue)
subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}]"
subject << " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
subject << " #{issue.subject}"
subject += " (#{issue.status.name})" if Setting.show_status_changes_in_mail_subject?
subject += " #{issue.subject}"
mail :to => user,
:subject => subject
end
......@@ -108,8 +108,8 @@ class Mailer < ActionMailer::Base
references issue
@author = journal.user
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.subject
s += "(#{issue.status.name}) " if journal.new_value_for('status_id') && Setting.show_status_changes_in_mail_subject?
s += issue.subject
@issue = issue
@user = user
@journal = journal
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -71,7 +71,7 @@ class Principal < ActiveRecord::Base
where({})
else
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))"
params = {:p => pattern}
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -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}")
if !options[:skip_pre_condition] && perm && perm.project_module
# 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
if project = options[:project]
project_statement = project.project_condition(options[:with_subprojects])
......@@ -622,7 +622,7 @@ class Project < ActiveRecord::Base
end
def css_classes
s = 'project'
s = +'project'
s << ' root' if root?
s << ' child' if child?
s << (leaf? ? ' leaf' : ' parent')
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -234,8 +234,8 @@ class Repository < ActiveRecord::Base
def diff_format_revisions(cs, cs_to, sep=':')
text = ""
text << cs_to.format_identifier + sep if cs_to
text << cs.format_identifier if cs
text += cs_to.format_identifier + sep if cs_to
text += cs.format_identifier if cs
text
end
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -207,8 +207,8 @@ class Repository::Cvs < Repository
# Returns the next revision number to assign to a CVS changeset
def next_revision_number
# Need to retrieve existing revision numbers to sort them as integers
sql = "SELECT revision FROM #{Changeset.table_name} "
sql << "WHERE repository_id = #{id} AND revision NOT LIKE 'tmp%'"
sql = "SELECT revision FROM #{Changeset.table_name} " \
"WHERE repository_id = #{id} AND revision NOT LIKE 'tmp%'"
@current_revision_number ||= (self.class.connection.select_values(sql).collect(&:to_i).max || 0)
@current_revision_number += 1
end
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......
# frozen_string_literal: false
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
......@@ -369,7 +369,7 @@ class User < Principal
def random_password(length=40)
chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
chars -= %w(0 O 1 l)
password = ''
password = +''
length.times {|i| password << chars[SecureRandom.random_number(chars.size)] }
self.password = password
self.password_confirmation = password
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment