Corrected with rubocop cop 'Style/NilComparison'.

This commit is contained in:
Thorsten Eckel 2015-05-07 12:11:45 +02:00
parent d8190dc5b4
commit 8f54cf18f5
14 changed files with 18 additions and 23 deletions

View file

@ -186,11 +186,6 @@ Rails/FindBy:
Description: 'Prefer find_by over where.first.'
Enabled: false
Style/NilComparison:
Description: 'Prefer x.nil? to x == nil.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
Enabled: false
Style/SymbolProc:
Description: 'Use symbols as procs instead of blocks when possible.'
Enabled: false

View file

@ -20,7 +20,7 @@ curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Conte
def fetch
items = Rss.fetch(params[:url], params[:limit])
if items == nil
if items.nil?
render json: { message: "failed to fetch #{ params[:url] }", status: :unprocessable_entity }
return
end

View file

@ -69,7 +69,7 @@ returns
def self.param_cleanup(params, newObject = false)
if params == nil
if params.nil?
raise "No params for #{self}!"
end
@ -467,7 +467,7 @@ end
key = "#{self.new.class.name}_latest_change"
expires_in = 31_536_000 # 1 year
if updated_at == nil
if updated_at.nil?
Cache.delete( key )
else
Cache.write( key, updated_at, { expires_in: expires_in } )
@ -1037,7 +1037,7 @@ get assets of object list
def attachments_buffer_check
# do nothing if no attachment exists
return 1 if attachments_buffer == nil
return 1 if attachments_buffer.nil?
# store attachments
article_store = []

View file

@ -508,7 +508,7 @@ class Channel::EmailParser
# fillup
%w(firstname lastname).each { |item|
if data[item.to_sym] == nil
if data[item.to_sym].nil?
data[item.to_sym] = ''
end
}

View file

@ -185,11 +185,11 @@ returns
data.delete('history_attribute_id')
data.delete( 'updated_at' )
if data['id_to'] == nil && data['id_from'] == nil
if data['id_to'].nil? && data['id_from'].nil?
data.delete( 'id_to' )
data.delete( 'id_from' )
end
if data['value_to'] == nil && data['value_from'] == nil
if data['value_to'].nil? && data['value_from'].nil?
data.delete( 'value_to' )
data.delete( 'value_from' )
end
@ -198,7 +198,7 @@ returns
end
data.delete( 'related_history_object_id' )
if data['related_o_id'] == nil
if data['related_o_id'].nil?
data.delete( 'related_o_id' )
end

View file

@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateEmail < ActiveRecord::Observer
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender.nil?
return 1 if sender['name'] == 'Customer'
# only apply on emails

View file

@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateFacebook < ActiveRecord::Observer
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender.nil?
return 1 if sender['name'] == 'Customer'
# only apply on emails

View file

@ -10,7 +10,7 @@ class Observer::Ticket::Article::CommunicateTwitter < ActiveRecord::Observer
# if sender is customer, do not communication
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return 1 if sender == nil
return 1 if sender.nil?
return 1 if sender['name'] == 'Customer'
# only apply on tweets

View file

@ -10,7 +10,7 @@ class Observer::Ticket::Article::FillupFromEmail < ActiveRecord::Observer
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return if sender == nil
return if sender.nil?
return if sender['name'] == 'Customer'
# set email attributes

View file

@ -10,7 +10,7 @@ class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.lookup( id: record.sender_id )
return if sender == nil
return if sender.nil?
return if sender['name'] == 'Customer'
# set from if not given

View file

@ -73,8 +73,8 @@ class Observer::Ticket::ArticleChanges < ActiveRecord::Observer
if sender.name == 'Customer'
# check if last communication is done by agent, else do not set last_contact_customer
if record.ticket.last_contact_customer == nil ||
record.ticket.last_contact_agent == nil ||
if record.ticket.last_contact_customer.nil? ||
record.ticket.last_contact_agent.nil? ||
record.ticket.last_contact_agent.to_i > record.ticket.last_contact_customer.to_i
# set last_contact customer

View file

@ -10,7 +10,7 @@ class Store
sha = Digest::SHA256.hexdigest( data )
file = Store::File.where( sha: sha ).first
if file == nil
if file.nil?
# load backend based on config
adapter_name = Setting.get('storage_provider') || 'DB'

View file

@ -175,7 +175,7 @@ returns
def escalation_calculation_get_sla
sla_selected = nil
sla_list = Cache.get( 'SLA::List::Active' )
if sla_list == nil
if sla_list.nil?
sla_list = Sla.where( active: true )
Cache.write( 'SLA::List::Active', sla_list, { expires_in: 1.hour } )
end

View file

@ -46,7 +46,7 @@ module Auth::Ldap
end
end
if user_dn == nil
if user_dn.nil?
Rails.logger.info "ldap entry found for user '#{username}' with filter #{filter} failed!"
return nil
end