Corrected with rubocop cop 'Lint/StringConversionInInterpolation'.

This commit is contained in:
Thorsten Eckel 2015-05-06 11:30:39 +02:00
parent 0fc920df18
commit 650e17be7c
20 changed files with 39 additions and 41 deletions

View file

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

View file

@ -70,7 +70,7 @@ returns
def self.param_cleanup(params, newObject = false) def self.param_cleanup(params, newObject = false)
if params == nil if params == nil
raise "No params for #{self.to_s}!" raise "No params for #{self}!"
end end
# ignore id for new objects # ignore id for new objects
@ -190,7 +190,7 @@ returns
if self.class.column_names.include? 'updated_by_id' if self.class.column_names.include? 'updated_by_id'
if UserInfo.current_user_id if UserInfo.current_user_id
if self.updated_by_id && self.updated_by_id != 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 end
self.updated_by_id = UserInfo.current_user_id self.updated_by_id = UserInfo.current_user_id
end end
@ -201,7 +201,7 @@ returns
return if !UserInfo.current_user_id return if !UserInfo.current_user_id
if self.created_by_id && self.created_by_id != 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 end
self.created_by_id = UserInfo.current_user_id self.created_by_id = UserInfo.current_user_id
end end
@ -1082,7 +1082,7 @@ check string/varchar size and cut them if needed
if column && limit if column && limit
current_length = attribute[1].to_s.length current_length = attribute[1].to_s.length
if limit < current_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 ] self[ attribute[0] ] = attribute[1][ 0, limit ]
end end
end end

View file

@ -72,7 +72,7 @@ class Channel::EmailParser
data[field.name.to_s.downcase.to_sym] = Encode.conv( 'utf8', field.to_s ) 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 # 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 end
} }

View file

@ -60,7 +60,7 @@ class Channel::IMAP < Channel::EmailParser
message_ids.each do |message_id| message_ids.each do |message_id|
count += 1 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 #Rails.logger.info msg.to_s
# check for verify message # check for verify message

View file

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

View file

@ -217,7 +217,7 @@ class Observer::Ticket::Notification::BackgroundJob
display = object_manager_attribute[:display].to_s display = object_manager_attribute[:display].to_s
end end
if object_manager_attribute && object_manager_attribute[:translate] 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 else
changes[display] = [value_str[0].to_s, value_str[1].to_s] changes[display] = [value_str[0].to_s, value_str[1].to_s]
end end

View file

@ -109,13 +109,13 @@ class Package < ApplicationModel
dest = @@root + '/' + file dest = @@root + '/' + file
if File.symlink?( dest.to_s ) if File.symlink?( dest.to_s )
logger.info "Unlink file: #{dest.to_s}" logger.info "Unlink file: #{dest}"
File.delete( dest.to_s ) File.delete( dest.to_s )
end end
backup_file = dest.to_s + '.link_backup' backup_file = dest.to_s + '.link_backup'
if File.exist?( backup_file ) 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 ) File.rename( backup_file, dest.to_s )
end end
end end
@ -146,7 +146,7 @@ class Package < ApplicationModel
if File.directory?( entry.to_s ) if File.directory?( entry.to_s )
if !File.exist?( dest.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 ) FileUtils.mkdir_p( dest.to_s )
end end
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 ) ) if File.file?( entry.to_s ) && ( File.file?( dest.to_s ) && !File.symlink?( dest.to_s ) )
backup_file = dest.to_s + '.link_backup' backup_file = dest.to_s + '.link_backup'
if File.exist?( backup_file ) 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 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 ) File.rename( dest.to_s, backup_file )
end end
end end
@ -165,7 +165,7 @@ class Package < ApplicationModel
if File.symlink?( dest.to_s ) if File.symlink?( dest.to_s )
File.delete( dest.to_s ) File.delete( dest.to_s )
end 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 ) File.symlink( entry.to_s, dest.to_s )
end end
end end

View file

@ -99,7 +99,7 @@ class Scheduler < ApplicationModel
def self.worker def self.worker
wait = 10 wait = 10
logger.info "*** Starting worker #{Delayed::Job.to_s}" logger.info "*** Starting worker #{Delayed::Job}"
loop do loop do
result = nil result = nil
@ -135,14 +135,14 @@ class Scheduler < ApplicationModel
exit 2 exit 2
end end
if scheduler.last_run < time_critical_time 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 exit 2
end end
if scheduler.last_run < time_warning_time 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 exit 2
end 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 exit 0
end end
end end

View file

@ -22,7 +22,7 @@ module Auth::Ldap
return return
end end
rescue Exception => e 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 return
end end

View file

@ -21,7 +21,7 @@ returns
def self.setup def self.setup
auto_wizard_file_name = 'auto_wizard.json' 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) return if !File.file?(auto_wizard_file_name)

View file

@ -25,7 +25,7 @@ class GeoIp::ZammadGeoIp
}, },
) )
if !response.success? && response.code.to_s !~ /^40.$/ if !response.success? && response.code.to_s !~ /^40.$/
raise "ERROR: #{response.code.to_s}/#{response.body}" raise "ERROR: #{response.code}/#{response.body}"
end end
data = response.data data = response.data

View file

@ -89,7 +89,7 @@ add new object to search index
password: Setting.get('es_password'), password: Setting.get('es_password'),
} }
) )
Rails.logger.info "# #{response.code.to_s}" Rails.logger.info "# #{response.code}"
return true if response.success? return true if response.success?
raise response.inspect raise response.inspect
end end
@ -208,7 +208,7 @@ return search result
} }
) )
Rails.logger.info "# #{response.code.to_s}" Rails.logger.info "# #{response.code}"
if !response.success? if !response.success?
Rails.logger.error "ERROR: #{response.inspect}" Rails.logger.error "ERROR: #{response.inspect}"
return [] return []
@ -220,7 +220,7 @@ return search result
return ids if !data['hits'] return ids if !data['hits']
return ids if !data['hits']['hits'] return ids if !data['hits']['hits']
data['hits']['hits'].each { |item| data['hits']['hits'].each { |item|
Rails.logger.info "... #{item['_type'].to_s} #{item['_id'].to_s}" Rails.logger.info "... #{item['_type']} #{item['_id']}"
data = { data = {
id: item['_id'], id: item['_id'],
type: item['_type'], type: item['_type'],

View file

@ -16,7 +16,7 @@ class Sessions::Backend::Collections::Base
end end
def client_key def client_key
"collections::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" "collections::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
end end
def push def push
@ -77,13 +77,13 @@ class Sessions::Backend::Collections::Base
assets: assets, assets: assets,
} }
end 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( @client.send(
data: assets, data: assets,
event: [ 'loadAssets' ], 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( @client.send(
event: 'resetCollection', event: 'resetCollection',
data: { data: {

View file

@ -10,7 +10,7 @@ class Sessions::Backend::Rss
end end
def collection_key def collection_key
"rss::load::#{ self.class.to_s }::#{ @user.id }" "rss::load::#{ self.class }::#{ @user.id }"
end end
def load def load
@ -29,7 +29,7 @@ class Sessions::Backend::Rss
end end
def client_key def client_key
"rss::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" "rss::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
end end
def push def push

View file

@ -27,7 +27,7 @@ class Sessions::Backend::TicketCreate
end end
def client_key def client_key
"as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
end end
def push def push

View file

@ -28,7 +28,7 @@ class Sessions::Backend::TicketOverviewIndex
end end
def client_key def client_key
"as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
end end
def push def push

View file

@ -39,7 +39,7 @@ class Sessions::Backend::TicketOverviewList
end end
def client_key def client_key
"as::load::#{ self.class.to_s }::#{ @user.id }::#{ @client_id }" "as::load::#{ self.class }::#{ @user.id }::#{ @client_id }"
end end
def push def push

View file

@ -76,7 +76,7 @@ module StaticAssets
return if !file return if !file
hash = Digest::MD5.hexdigest( file.content ) 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| File.open( path, 'wb' ) do |f|
f.puts file.content f.puts file.content
end end

View file

@ -283,7 +283,7 @@ returns
def self.process(response, uri, count, params, options) def self.process(response, uri, count, params, options)
if !response if !response
return Result.new( 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, success: false,
code: 0, code: 0,
) )
@ -292,7 +292,7 @@ returns
case response case response
when Net::HTTPNotFound when Net::HTTPNotFound
return Result.new( return Result.new(
error: "No such file #{uri.to_s}, 404!", error: "No such file #{uri}, 404!",
success: false, success: false,
code: response.code, code: response.code,
) )

View file

@ -58,7 +58,7 @@ if ARGV[0] != 'start' && ARGV[0] != 'stop'
exit exit
end 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 #puts options.inspect
if ARGV[0] == 'stop' if ARGV[0] == 'stop'
@ -139,7 +139,7 @@ EventMachine.run {
# error handling # error handling
if data['timestamp'] 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 else
log 'notice', 'request spool with init data', client_id log 'notice', 'request spool with init data', client_id
end end
@ -199,7 +199,7 @@ EventMachine.run {
else else
data['recipient']['user_id'].each { |user_id| data['recipient']['user_id'].each { |user_id|
if local_client[:user]['id'].to_i == user_id.to_i 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 ] if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" ) @clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else else
@ -213,7 +213,7 @@ EventMachine.run {
# broadcast every client # broadcast every client
else 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 ] if local_client[:meta][:type] == 'websocket' && @clients[ local_client_id ]
@clients[ local_client_id ][:websocket].send( "[#{msg}]" ) @clients[ local_client_id ][:websocket].send( "[#{msg}]" )
else else