]> source.dussan.org Git - redmine.git/commitdiff
Support frozen_string_literal in app/**/*.rb (#26561).
authorGo MAEDA <maeda@farend.jp>
Sun, 17 Mar 2019 13:36:03 +0000 (13:36 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 17 Mar 2019 13:36:03 +0000 (13:36 +0000)
Contributed by Pavel Rosický.

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

26 files changed:
app/controllers/attachments_controller.rb
app/controllers/messages_controller.rb
app/controllers/repositories_controller.rb
app/controllers/search_controller.rb
app/helpers/application_helper.rb
app/helpers/attachments_helper.rb
app/helpers/calendars_helper.rb
app/helpers/context_menus_helper.rb
app/helpers/custom_fields_helper.rb
app/helpers/projects_helper.rb
app/helpers/repositories_helper.rb
app/helpers/search_helper.rb
app/helpers/wiki_helper.rb
app/models/attachment.rb
app/models/auth_source_ldap.rb
app/models/mailer.rb
app/models/principal.rb
app/models/project.rb
app/models/repository.rb
app/models/repository/bazaar.rb
app/models/repository/cvs.rb
app/models/repository/filesystem.rb
app/models/repository/git.rb
app/models/repository/mercurial.rb
app/models/repository/subversion.rb
app/models/user.rb

index 4b81991666a65ddb8154a81b0f3006d1bb6df279..1f1b058994ea9daa52349446b57e523fb14d21a1 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
index 9cffeea7093e5f66c1603afbcc26d1c64e436854..f0e289be2439a362c2becd19097e0ede520e2517 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
@@ -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
 
index 5fdac37e97d92390589c495f0cd0e882f1995c4d..e0af12a3ca7fd44b07db765920081d30c834ad69 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
index 8ae53e7ffdc6b930e06c6623e054cd6d83d254ce..b48ebc38cbd4893f13d84f33d585130332bbd2eb 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
@@ -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'
index 23520d953f062bb686493a15b967a31630a0f8e9..8dab8973577ac430907e2030b4f6fa04df17cc7e 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
@@ -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|
index 899472b25dbfdbe0b1245baf1e840b2fbe2dbe8a..0719db2a3167196717390208b7883bbfe5e5a1fd 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
index 8375a9792201a44da4c3705c155b2c0ff49aafd3..865c5c8b7bc11c2a89c65d90c22840bd31806f55 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
@@ -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
index f0bbf15cc99bf201a96b5ed8f0131de90aa07a37..06d4a224576acca9750394eaf184a531de878367 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
@@ -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
index 13ee985b0dbe08c8f61245e6230703d36239e191..b4b44b238adc2aafe4ed06fe535dc9997cea17d4 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
@@ -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),
index fb38ab26adc88f6fabffda6576fce00795652f58..6a34a79e705129c4466ea08c6be130d34dfe511a 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
@@ -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
index 9c025c581ee8c37b0edd2b3b105ff29aff433d8d..fb5392e7367d23e14f7f7ad6b2b4cca25e1aedc6 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
@@ -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'
index f236f31815e4878687d575c73b1188c0c6679881..0b0160c6b20c2923d526edf41cbc912cbf25cfec 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
@@ -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
index f640ee48ddd7390fc59d45d217a2f71647c35d3a..bf316444049edbd182dc65e05d86ae7bf43f1018 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
@@ -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; ') : ''
 
index 0291a101344b3731dd14e4ee43d95dff4918e3e1..a4870e3805b2da5451eb5a5d0b09aa93d4ec7adb 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
index c94a8102263857958b301192c24355c42df66100..ddda8bb161d3477ea42ea31be7fe4842bf9d5d79 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
index d8fbf9cd499bce5244e06be2f4c8ff2e6dfb02bc..5ef10c1d7ec8ba696cef5f30739a7b66f5500219 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
@@ -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
index 1d9c288cb53fe80f27478e132b76141b2b0a510d..6e77cd8666f77e1e78d99545c06cd7a2abfcb453 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
@@ -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}
 
index 75f99e397e204804d9b9bcd860015b8fbc8ad3ff..04766c8578facc764c4347c06d1e4822991239cd 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
@@ -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')
index 33688407170e7b4a1cff410d5d0d1ba19049235d..f44c02f502bb90de06bca10d5e96f62fc5de85c7 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
@@ -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
 
index c95f501a8d2e7b3d63816918572889e12fc42a16..65c7eaa6102a3621cd9ea0ba6238ef01cee223b1 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
index 4e4e1a239cb004f5c1b491a896934a053213bf8e..c956eec6b0d9f7f64a53aff8004cc089597c1d5f 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
@@ -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
index c061145205adf9eaf80e824384e1c13ee3d4cb5a..5c3f63a92d0e6e35ec5cc8c1724171da48df1153 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
index 65da33c4df0561bb3fe9d806a78c5158e687aef5..a8c5efd33f66e1d2f0f0e9135071ed044f48b301 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
index 704c4e2a77db0dffac9f2d9c0f96521dfcc24c62..a0560735fad710f6ba8b1ea417d3c8d6f0f396f7 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
index de2758dde30056ff389db66998cfadf66436affa..a7c41d73a05737c8103c6004b4485e4c7ac8a188 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
index e9b414fd44a2d2278ef8d175857a2b093daaa0d5..698b1bac9b82fe6b23ceaec8fedfeb7ccabcbcfe 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
@@ -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