Просмотр исходного кода

Corrected with rubocop cop 'Lint/StringConversionInInterpolation'.

Thorsten Eckel 9 лет назад
Родитель
Сommit
650e17be7c

+ 0 - 2
.rubocop.yml

@@ -234,8 +234,6 @@ Metrics/CyclomaticComplexity:
   Enabled: false
 Style/ClassAndModuleChildren:
   Enabled: false
-Lint/StringConversionInInterpolation:
-  Enabled: false
 Style/GlobalVars:
   Enabled: false
 Rails/TimeZone:

+ 4 - 4
app/models/application_model.rb

@@ -70,7 +70,7 @@ returns
   def self.param_cleanup(params, newObject = false)
 
     if params == nil
-      raise "No params for #{self.to_s}!"
+      raise "No params for #{self}!"
     end
 
     # ignore id for new objects
@@ -190,7 +190,7 @@ returns
     if self.class.column_names.include? 'updated_by_id'
       if UserInfo.current_user_id
         if self.updated_by_id && self.updated_by_id != UserInfo.current_user_id
-          logger.info "NOTICE create - self.updated_by_id is different: #{self.updated_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
+          logger.info "NOTICE create - self.updated_by_id is different: #{self.updated_by_id}/#{UserInfo.current_user_id}"
         end
         self.updated_by_id = UserInfo.current_user_id
       end
@@ -201,7 +201,7 @@ returns
     return if !UserInfo.current_user_id
 
     if self.created_by_id && self.created_by_id != UserInfo.current_user_id
-      logger.info "NOTICE create - self.created_by_id is different: #{self.created_by_id.to_s}/#{UserInfo.current_user_id.to_s}"
+      logger.info "NOTICE create - self.created_by_id is different: #{self.created_by_id}/#{UserInfo.current_user_id}"
     end
     self.created_by_id = UserInfo.current_user_id
   end
@@ -1082,7 +1082,7 @@ check string/varchar size and cut them if needed
       if column && limit
         current_length = attribute[1].to_s.length
         if limit < current_length
-          logger.warn "WARNING: cut string because of database length #{self.class.to_s}.#{attribute[0]}(#{limit} but is #{current_length}:#{attribute[1].to_s})"
+          logger.warn "WARNING: cut string because of database length #{self.class}.#{attribute[0]}(#{limit} but is #{current_length}:#{attribute[1]})"
           self[ attribute[0] ] = attribute[1][ 0, limit ]
         end
       end

+ 1 - 1
app/models/channel/email_parser.rb

@@ -72,7 +72,7 @@ class Channel::EmailParser
         data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s )
 
         # if we need to access the lines by objects later again
-        data[ "raw-#{field.name.downcase.to_s}".to_sym ] = field
+        data[ "raw-#{field.name.downcase}".to_sym ] = field
       end
     }
 

+ 1 - 1
app/models/channel/imap.rb

@@ -60,7 +60,7 @@ class Channel::IMAP < Channel::EmailParser
 
     message_ids.each do |message_id|
       count += 1
-      Rails.logger.info " - message #{count.to_s}/#{count_all.to_s}"
+      Rails.logger.info " - message #{count}/#{count_all}"
       #Rails.logger.info msg.to_s
 
       # check for verify message

+ 1 - 1
app/models/channel/pop3.rb

@@ -45,7 +45,7 @@ class Channel::POP3 < Channel::EmailParser
 
     mails.each do |m|
       count += 1
-      Rails.logger.info " - message #{count.to_s}/#{count_all.to_s}"
+      Rails.logger.info " - message #{count}/#{count_all}"
 
       # check for verify message
       if check_type == 'verify'

+ 1 - 1
app/models/observer/ticket/notification/background_job.rb

@@ -217,7 +217,7 @@ class Observer::Ticket::Notification::BackgroundJob
         display = object_manager_attribute[:display].to_s
       end
       if object_manager_attribute && object_manager_attribute[:translate]
-        changes[display] = ["i18n(#{value_str[0].to_s})", "i18n(#{value_str[1].to_s})"]
+        changes[display] = ["i18n(#{value_str[0]})", "i18n(#{value_str[1]})"]
       else
         changes[display] = [value_str[0].to_s, value_str[1].to_s]
       end

+ 6 - 6
app/models/package.rb

@@ -109,13 +109,13 @@ class Package < ApplicationModel
       dest = @@root + '/' + file
 
       if File.symlink?( dest.to_s )
-        logger.info "Unlink file: #{dest.to_s}"
+        logger.info "Unlink file: #{dest}"
         File.delete( dest.to_s )
       end
 
       backup_file = dest.to_s + '.link_backup'
       if File.exist?( backup_file )
-        logger.info "Restore backup file of #{backup_file} -> #{dest.to_s}."
+        logger.info "Restore backup file of #{backup_file} -> #{dest}."
         File.rename( backup_file, dest.to_s )
       end
     end
@@ -146,7 +146,7 @@ class Package < ApplicationModel
 
       if File.directory?( entry.to_s )
         if !File.exist?( dest.to_s )
-          logger.info "Create dir: #{dest.to_s}"
+          logger.info "Create dir: #{dest}"
           FileUtils.mkdir_p( dest.to_s )
         end
       end
@@ -154,9 +154,9 @@ class Package < ApplicationModel
       if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) )
         backup_file = dest.to_s + '.link_backup'
         if File.exist?( backup_file )
-          raise "Can't link #{entry.to_s} -> #{dest.to_s}, destination and .link_backup already exists!"
+          raise "Can't link #{entry} -> #{dest}, destination and .link_backup already exists!"
         else
-          logger.info "Create backup file of #{dest.to_s} -> #{backup_file}."
+          logger.info "Create backup file of #{dest} -> #{backup_file}."
           File.rename( dest.to_s, backup_file )
         end
       end
@@ -165,7 +165,7 @@ class Package < ApplicationModel
         if File.symlink?( dest.to_s )
           File.delete( dest.to_s )
         end
-        logger.info "Link file: #{entry.to_s} -> #{dest.to_s}"
+        logger.info "Link file: #{entry} -> #{dest}"
         File.symlink( entry.to_s, dest.to_s )
       end
     end

+ 4 - 4
app/models/scheduler.rb

@@ -99,7 +99,7 @@ class Scheduler < ApplicationModel
 
   def self.worker
     wait = 10
-    logger.info "*** Starting worker #{Delayed::Job.to_s}"
+    logger.info "*** Starting worker #{Delayed::Job}"
 
     loop do
       result = nil
@@ -135,14 +135,14 @@ class Scheduler < ApplicationModel
       exit 2
     end
     if scheduler.last_run < time_critical_time
-      puts "CRITICAL - scheduler jobs was not running in last '#{time_critical.to_s}' minutes - last run at '#{scheduler.last_run.to_s}' '#{name}'"
+      puts "CRITICAL - scheduler jobs was not running in last '#{time_critical}' minutes - last run at '#{scheduler.last_run}' '#{name}'"
       exit 2
     end
     if scheduler.last_run < time_warning_time
-      puts "CRITICAL - scheduler jobs was not running in last '#{time_warning.to_s}' minutes - last run at '#{scheduler.last_run.to_s}' '#{name}'"
+      puts "CRITICAL - scheduler jobs was not running in last '#{time_warning}' minutes - last run at '#{scheduler.last_run}' '#{name}'"
       exit 2
     end
-    puts "ok - scheduler jobs was running at '#{scheduler.last_run.to_s}' '#{name}'"
+    puts "ok - scheduler jobs was running at '#{scheduler.last_run}' '#{name}'"
     exit 0
   end
 end

+ 1 - 1
lib/auth/ldap.rb

@@ -22,7 +22,7 @@ module Auth::Ldap
         return
       end
     rescue Exception => e
-      Rails.logger.info "Can't connect to '#{config[:host]}', #{e.to_s}"
+      Rails.logger.info "Can't connect to '#{config[:host]}', #{e}"
       return
     end
 

+ 1 - 1
lib/auto_wizard.rb

@@ -21,7 +21,7 @@ returns
   def self.setup
 
     auto_wizard_file_name = 'auto_wizard.json'
-    auto_wizard_file_name = "#{Rails.root.to_s}/#{auto_wizard_file_name}"
+    auto_wizard_file_name = "#{Rails.root}/#{auto_wizard_file_name}"
 
     return if !File.file?(auto_wizard_file_name)
 

Некоторые файлы не были показаны из-за большого количества измененных файлов