From 650e17be7c6f36a4e0e6583375c35d884210a58d Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 6 May 2015 11:30:39 +0200 Subject: [PATCH] Corrected with rubocop cop 'Lint/StringConversionInInterpolation'. --- .rubocop.yml | 2 -- app/models/application_model.rb | 8 ++++---- app/models/channel/email_parser.rb | 2 +- app/models/channel/imap.rb | 2 +- app/models/channel/pop3.rb | 2 +- .../observer/ticket/notification/background_job.rb | 2 +- app/models/package.rb | 12 ++++++------ app/models/scheduler.rb | 8 ++++---- lib/auth/ldap.rb | 2 +- lib/auto_wizard.rb | 2 +- lib/geo_ip/zammad_geo_ip.rb | 2 +- lib/search_index_backend.rb | 6 +++--- lib/sessions/backend/collections/base.rb | 6 +++--- lib/sessions/backend/rss.rb | 4 ++-- lib/sessions/backend/ticket_create.rb | 2 +- lib/sessions/backend/ticket_overview_index.rb | 2 +- lib/sessions/backend/ticket_overview_list.rb | 2 +- lib/static_assets.rb | 2 +- lib/user_agent.rb | 4 ++-- script/websocket-server.rb | 8 ++++---- 20 files changed, 39 insertions(+), 41 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a773040f4..dab552a55 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -234,8 +234,6 @@ Metrics/CyclomaticComplexity: Enabled: false Style/ClassAndModuleChildren: Enabled: false -Lint/StringConversionInInterpolation: - Enabled: false Style/GlobalVars: Enabled: false Rails/TimeZone: diff --git a/app/models/application_model.rb b/app/models/application_model.rb index daa1e992f..caee214d1 100644 --- a/app/models/application_model.rb +++ b/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 diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 0b2354a31..f519ee85d 100644 --- a/app/models/channel/email_parser.rb +++ b/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 } diff --git a/app/models/channel/imap.rb b/app/models/channel/imap.rb index 4066db00c..f62701236 100644 --- a/app/models/channel/imap.rb +++ b/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 diff --git a/app/models/channel/pop3.rb b/app/models/channel/pop3.rb index 633a33455..1a98c6502 100644 --- a/app/models/channel/pop3.rb +++ b/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' diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb index 502ccadba..3c68b4947 100644 --- a/app/models/observer/ticket/notification/background_job.rb +++ b/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 diff --git a/app/models/package.rb b/app/models/package.rb index 10c90c91f..800fb8e35 100644 --- a/app/models/package.rb +++ b/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 diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index f59c13795..37172a651 100644 --- a/app/models/scheduler.rb +++ b/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 diff --git a/lib/auth/ldap.rb b/lib/auth/ldap.rb index c7b83c349..f205911e6 100644 --- a/lib/auth/ldap.rb +++ b/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 diff --git a/lib/auto_wizard.rb b/lib/auto_wizard.rb index b5a9cf417..c3ed73378 100644 --- a/lib/auto_wizard.rb +++ b/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) diff --git a/lib/geo_ip/zammad_geo_ip.rb b/lib/geo_ip/zammad_geo_ip.rb index 8fb1285c0..b3a317e8d 100644 --- a/lib/geo_ip/zammad_geo_ip.rb +++ b/lib/geo_ip/zammad_geo_ip.rb @@ -25,7 +25,7 @@ class GeoIp::ZammadGeoIp }, ) if !response.success? && response.code.to_s !~ /^40.$/ - raise "ERROR: #{response.code.to_s}/#{response.body}" + raise "ERROR: #{response.code}/#{response.body}" end data = response.data diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index 8a66d3f32..78f7fbb82 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -89,7 +89,7 @@ add new object to search index password: Setting.get('es_password'), } ) - Rails.logger.info "# #{response.code.to_s}" + Rails.logger.info "# #{response.code}" return true if response.success? raise response.inspect end @@ -208,7 +208,7 @@ return search result } ) - Rails.logger.info "# #{response.code.to_s}" + Rails.logger.info "# #{response.code}" if !response.success? Rails.logger.error "ERROR: #{response.inspect}" return [] @@ -220,7 +220,7 @@ return search result return ids if !data['hits'] return ids if !data['hits']['hits'] data['hits']['hits'].each { |item| - Rails.logger.info "... #{item['_type'].to_s} #{item['_id'].to_s}" + Rails.logger.info "... #{item['_type']} #{item['_id']}" data = { id: item['_id'], type: item['_type'], diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index 98a0c294e..3af51b68e 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -16,7 +16,7 @@ class Sessions::Backend::Collections::Base end def client_key - "collections::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" + "collections::load::#{ self.class }::#{ @user.id }::#{ @client_id }" end def push @@ -77,13 +77,13 @@ class Sessions::Backend::Collections::Base assets: assets, } end - @client.log "push assets for push_collection #{ items.first.class.to_s } for user #{ @user.id }" + @client.log "push assets for push_collection #{ items.first.class } for user #{ @user.id }" @client.send( data: assets, event: [ 'loadAssets' ], ) - @client.log "push push_collection #{ items.first.class.to_s } for user #{ @user.id }" + @client.log "push push_collection #{ items.first.class } for user #{ @user.id }" @client.send( event: 'resetCollection', data: { diff --git a/lib/sessions/backend/rss.rb b/lib/sessions/backend/rss.rb index 3df8319b2..1b3fdabf8 100644 --- a/lib/sessions/backend/rss.rb +++ b/lib/sessions/backend/rss.rb @@ -10,7 +10,7 @@ class Sessions::Backend::Rss end def collection_key - "rss::load::#{ self.class.to_s }::#{ @user.id }" + "rss::load::#{ self.class }::#{ @user.id }" end def load @@ -29,7 +29,7 @@ class Sessions::Backend::Rss end def client_key - "rss::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" + "rss::load::#{ self.class }::#{ @user.id }::#{ @client_id }" end def push diff --git a/lib/sessions/backend/ticket_create.rb b/lib/sessions/backend/ticket_create.rb index 1f5caaf10..fb7bea69f 100644 --- a/lib/sessions/backend/ticket_create.rb +++ b/lib/sessions/backend/ticket_create.rb @@ -27,7 +27,7 @@ class Sessions::Backend::TicketCreate end def client_key - "as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" + "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }" end def push diff --git a/lib/sessions/backend/ticket_overview_index.rb b/lib/sessions/backend/ticket_overview_index.rb index 87ecd0653..131fb557b 100644 --- a/lib/sessions/backend/ticket_overview_index.rb +++ b/lib/sessions/backend/ticket_overview_index.rb @@ -28,7 +28,7 @@ class Sessions::Backend::TicketOverviewIndex end def client_key - "as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" + "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }" end def push diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb index 56832a72a..4e36a3a3b 100644 --- a/lib/sessions/backend/ticket_overview_list.rb +++ b/lib/sessions/backend/ticket_overview_list.rb @@ -39,7 +39,7 @@ class Sessions::Backend::TicketOverviewList end def client_key - "as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" + "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }" end def push diff --git a/lib/static_assets.rb b/lib/static_assets.rb index 7ebda92de..892cf7ea8 100644 --- a/lib/static_assets.rb +++ b/lib/static_assets.rb @@ -76,7 +76,7 @@ module StaticAssets return if !file hash = Digest::MD5.hexdigest( file.content ) - path = "#{Rails.root.to_s}/public/assets/images/#{hash}" + path = "#{Rails.root}/public/assets/images/#{hash}" File.open( path, 'wb' ) do |f| f.puts file.content end diff --git a/lib/user_agent.rb b/lib/user_agent.rb index b29e9ab2e..3878306f5 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -283,7 +283,7 @@ returns def self.process(response, uri, count, params, options) if !response return Result.new( - error: "Can't connect to #{uri.to_s}, got no response!", + error: "Can't connect to #{uri}, got no response!", success: false, code: 0, ) @@ -292,7 +292,7 @@ returns case response when Net::HTTPNotFound return Result.new( - error: "No such file #{uri.to_s}, 404!", + error: "No such file #{uri}, 404!", success: false, code: response.code, ) diff --git a/script/websocket-server.rb b/script/websocket-server.rb index 29c712d37..92fa5bee3 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -58,7 +58,7 @@ if ARGV[0] != 'start' && ARGV[0] != 'stop' exit end -puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#{ @options[:s].to_s },pid:#{@options[:i].to_s})" +puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:#{ @options[:s] },pid:#{@options[:i]})" #puts options.inspect if ARGV[0] == 'stop' @@ -139,7 +139,7 @@ EventMachine.run { # error handling if data['timestamp'] - log 'notice', "request spool data > '#{Time.at(data['timestamp']).to_s}'", client_id + log 'notice', "request spool data > '#{Time.at(data['timestamp'])}'", client_id else log 'notice', 'request spool with init data', client_id end @@ -199,7 +199,7 @@ EventMachine.run { else data['recipient']['user_id'].each { |user_id| if local_client[:user]['id'].to_i == user_id.to_i - log 'notice', "send broadcast from (#{client_id.to_s}) to (user_id=#{user_id})", local_client_id + log 'notice', "send broadcast from (#{client_id}) to (user_id=#{user_id})", local_client_id if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] @clients[ local_client_id ][:websocket].send( "[#{msg}]" ) else @@ -213,7 +213,7 @@ EventMachine.run { # broadcast every client else - log 'notice', "send broadcast from (#{client_id.to_s})", local_client_id + log 'notice', "send broadcast from (#{client_id})", local_client_id if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ] @clients[ local_client_id ][:websocket].send( "[#{msg}]" ) else