diff options
author | Go MAEDA <maeda@farend.jp> | 2019-03-17 13:36:03 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-03-17 13:36:03 +0000 |
commit | bd5977d97eaf92f852c1bfe499052b6b07ab8aae (patch) | |
tree | 714a9672c2007f78dbe7c2c5a649e24505ae9863 /app | |
parent | 72a163d8b30978f23059ba2a2083675a38bd5680 (diff) | |
download | redmine-bd5977d97eaf92f852c1bfe499052b6b07ab8aae.tar.gz redmine-bd5977d97eaf92f852c1bfe499052b6b07ab8aae.zip |
Support frozen_string_literal in app/**/*.rb (#26561).
Contributed by Pavel Rosický.
git-svn-id: http://svn.redmine.org/redmine/trunk@17987 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
26 files changed, 65 insertions, 66 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 4b8199166..1f1b05899 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_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 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9cffeea70..f0e289be2 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_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 @@ -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 diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 5fdac37e9..e0af12a3c 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_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 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 8ae53e7ff..b48ebc38c 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_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 @@ -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' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 23520d953..8dab89735 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_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 @@ -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| diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 899472b25..0719db2a3 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_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 diff --git a/app/helpers/calendars_helper.rb b/app/helpers/calendars_helper.rb index 8375a9792..865c5c8b7 100644 --- a/app/helpers/calendars_helper.rb +++ b/app/helpers/calendars_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 @@ -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 diff --git a/app/helpers/context_menus_helper.rb b/app/helpers/context_menus_helper.rb index f0bbf15cc..06d4a2245 100644 --- a/app/helpers/context_menus_helper.rb +++ b/app/helpers/context_menus_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 @@ -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 diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 13ee985b0..b4b44b238 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_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 @@ -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), diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index fb38ab26a..6a34a79e7 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_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 @@ -42,14 +42,14 @@ module ProjectsHelper selected = (parent_id.blank? ? nil : Project.find(parent_id)) end - options = '' + options = +'' options << "<option value=''> </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 diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 9c025c581..fb5392e73 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_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 @@ -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' diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index f236f3181..0b0160c6b 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_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 @@ -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 diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb index f640ee48d..bf3164440 100644 --- a/app/helpers/wiki_helper.rb +++ b/app/helpers/wiki_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 @@ -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) ? (' ' * level * 2 + '» ') : '' diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 0291a1013..a4870e380 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index c94a81022..ddda8bb16 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d8fbf9cd4..5ef10c1d7 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1,4 +1,4 @@ -# 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 diff --git a/app/models/principal.rb b/app/models/principal.rb index 1d9c288cb..6e77cd866 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -1,4 +1,4 @@ -# 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} diff --git a/app/models/project.rb b/app/models/project.rb index 75f99e397..04766c857 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1,4 +1,4 @@ -# 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') diff --git a/app/models/repository.rb b/app/models/repository.rb index 336884071..f44c02f50 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1,4 +1,4 @@ -# 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 diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb index c95f501a8..65c7eaa61 100644 --- a/app/models/repository/bazaar.rb +++ b/app/models/repository/bazaar.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb index 4e4e1a239..c956eec6b 100644 --- a/app/models/repository/cvs.rb +++ b/app/models/repository/cvs.rb @@ -1,4 +1,4 @@ -# 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 diff --git a/app/models/repository/filesystem.rb b/app/models/repository/filesystem.rb index c06114520..5c3f63a92 100644 --- a/app/models/repository/filesystem.rb +++ b/app/models/repository/filesystem.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb index 65da33c4d..a8c5efd33 100644 --- a/app/models/repository/git.rb +++ b/app/models/repository/git.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index 704c4e2a7..a0560735f 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb index de2758dde..a7c41d73a 100644 --- a/app/models/repository/subversion.rb +++ b/app/models/repository/subversion.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # Redmine - project management software # Copyright (C) 2006-2017 Jean-Philippe Lang diff --git a/app/models/user.rb b/app/models/user.rb index e9b414fd4..698b1bac9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,4 @@ -# 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 |