Corrected with rubocop cop 'Style/VariableName'.

This commit is contained in:
Thorsten Eckel 2015-05-05 16:14:18 +02:00
parent d63b9d2f9b
commit 50806a4b5e
4 changed files with 26 additions and 28 deletions

View file

@ -256,8 +256,6 @@ Style/ColonMethodCall:
Enabled: false Enabled: false
Rails/Date: Rails/Date:
Enabled: false Enabled: false
Style/VariableName:
Enabled: false
Lint/UnreachableCode: Lint/UnreachableCode:
Enabled: false Enabled: false
Lint/ShadowingOuterLocalVariable: Lint/ShadowingOuterLocalVariable:

View file

@ -15,7 +15,7 @@ class ImportOtrsController < ApplicationController
end end
# connection test # connection test
translationMap = { translation_map = {
'authentication failed' => 'Authentication failed!', 'authentication failed' => 'Authentication failed!',
'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!', 'getaddrinfo: nodename nor servname provided, or not known' => 'Hostname not found!',
'No route to host' => 'No route to host!', 'No route to host' => 'No route to host!',
@ -26,7 +26,7 @@ class ImportOtrsController < ApplicationController
response = UserAgent.request(params[:url]) response = UserAgent.request(params[:url])
if !response.success? && response.code.to_s !~ /^40.$/ if !response.success? && response.code.to_s !~ /^40.$/
message_human = '' message_human = ''
translationMap.each {|key, message| translation_map.each {|key, message|
if response.error.to_s =~ /#{Regexp.escape(key)}/i if response.error.to_s =~ /#{Regexp.escape(key)}/i
message_human = message message_human = message
end end

View file

@ -18,8 +18,8 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
EventBuffer.reset EventBuffer.reset
# get uniq objects # get uniq objects
listObjects = get_uniq_changes(list) list_objects = get_uniq_changes(list)
listObjects.each {|ticket_id, item| list_objects.each {|ticket_id, item|
# send background job # send background job
Delayed::Job.enqueue( Observer::Ticket::Notification::BackgroundJob.new( item ) ) Delayed::Job.enqueue( Observer::Ticket::Notification::BackgroundJob.new( item ) )
@ -49,7 +49,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
=end =end
def self.get_uniq_changes(events) def self.get_uniq_changes(events)
listObjects = {} list_objects = {}
events.each { |event| events.each { |event|
# get current state of objects # get current state of objects
@ -60,14 +60,14 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
next if !article next if !article
ticket = article.ticket ticket = article.ticket
if !listObjects[ticket.id] if !list_objects[ticket.id]
listObjects[ticket.id] = {} list_objects[ticket.id] = {}
end end
listObjects[ticket.id][:article_id] = article.id list_objects[ticket.id][:article_id] = article.id
listObjects[ticket.id][:ticket_id] = ticket.id list_objects[ticket.id][:ticket_id] = ticket.id
if !listObjects[ticket.id][:type] if !list_objects[ticket.id][:type]
listObjects[ticket.id][:type] = 'update' list_objects[ticket.id][:type] = 'update'
end end
elsif event[:name] == 'Ticket' elsif event[:name] == 'Ticket'
@ -76,25 +76,25 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
# next if ticket is already deleted # next if ticket is already deleted
next if !ticket next if !ticket
if !listObjects[ticket.id] if !list_objects[ticket.id]
listObjects[ticket.id] = {} list_objects[ticket.id] = {}
end end
listObjects[ticket.id][:ticket_id] = ticket.id list_objects[ticket.id][:ticket_id] = ticket.id
if !listObjects[ticket.id][:type] || listObjects[ticket.id][:type] == 'update' if !list_objects[ticket.id][:type] || list_objects[ticket.id][:type] == 'update'
listObjects[ticket.id][:type] = event[:type] list_objects[ticket.id][:type] = event[:type]
end end
# merge changes # merge changes
if event[:changes] if event[:changes]
if !listObjects[ticket.id][:changes] if !list_objects[ticket.id][:changes]
listObjects[ticket.id][:changes] = event[:changes] list_objects[ticket.id][:changes] = event[:changes]
else else
event[:changes].each {|key, value| event[:changes].each {|key, value|
if !listObjects[ticket.id][:changes][key] if !list_objects[ticket.id][:changes][key]
listObjects[ticket.id][:changes][key] = value list_objects[ticket.id][:changes][key] = value
else else
listObjects[ticket.id][:changes][key][1] = value[1] list_objects[ticket.id][:changes][key][1] = value[1]
end end
} }
end end
@ -103,7 +103,7 @@ class Observer::Ticket::Notification < ActiveRecord::Observer
raise "unknown object for notification #{event[:name]}" raise "unknown object for notification #{event[:name]}"
end end
} }
listObjects list_objects
end end
def after_create(record) def after_create(record)

View file

@ -260,10 +260,10 @@ returns
file.flock( File::LOCK_EX ) file.flock( File::LOCK_EX )
all = file.read all = file.read
file.flock( File::LOCK_UN ) file.flock( File::LOCK_UN )
dataJSON = JSON.parse( all ) data_json = JSON.parse( all )
if dataJSON if data_json
data = self.symbolize_keys(dataJSON) data = self.symbolize_keys(data_json)
data[:user] = dataJSON['user'] # for compat. reasons data[:user] = data_json['user'] # for compat. reasons
end end
} }
rescue Exception => e rescue Exception => e