From c34a33da99c2d606fb54ce20e5ccb8fa7be0380b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 27 Apr 2015 16:41:03 +0200 Subject: [PATCH] Applied rubocop Style/SpaceAroundOperators. --- app/controllers/application_controller.rb | 2 +- app/controllers/getting_started_controller.rb | 2 +- app/controllers/import_otrs_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/models/application_model.rb | 6 +++--- .../application_model/search_index_base.rb | 2 +- app/models/channel/email_parser.rb | 6 +++--- .../ticket/notification/background_job.rb | 6 +++--- app/models/organization/search_index.rb | 2 +- app/models/package.rb | 2 +- ...000001_update_overview_and_ticket_state.rb | 2 +- db/seeds.rb | 6 +++--- lib/fill_db.rb | 12 +++++------ lib/import/otrs2.rb | 12 +++++------ lib/sessions.rb | 2 +- lib/sessions/backend/activity_stream.rb | 2 +- lib/sessions/backend/collections/base.rb | 2 +- lib/sessions/backend/rss.rb | 2 +- lib/time_calculation.rb | 4 ++-- script/source_code_filter.rb | 2 +- script/websocket-server.rb | 4 ++-- test/unit/ticket_sla_test.rb | 20 +++++++++---------- 22 files changed, 51 insertions(+), 51 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 535cc0503..9022ec280 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -267,7 +267,7 @@ class ApplicationController < ActionController::Base next if t.name =~ /^MST/ next if t.name =~ /^ROC/ next if t.name =~ /^ROK/ - diff = t.current_period.utc_total_offset / 60 /60 + diff = t.current_period.utc_total_offset / 60 / 60 config['timezones'][ t.name ] = diff } diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index 3f0f24079..e1b840b97 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -76,7 +76,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} # validate url messages = {} if !Setting.get('system_online_service') - if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ + if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/ messages[:url] = 'A URL looks like http://zammad.example.com' end end diff --git a/app/controllers/import_otrs_controller.rb b/app/controllers/import_otrs_controller.rb index ae38a2395..a694c86c7 100644 --- a/app/controllers/import_otrs_controller.rb +++ b/app/controllers/import_otrs_controller.rb @@ -6,7 +6,7 @@ class ImportOtrsController < ApplicationController return if setup_done_response # validate - if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ + if !params[:url] || params[:url] !~ /^(http|https):\/\/.+?$/ render json: { result: 'invalid', message: 'Invalid!', diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 195a2e08f..463786880 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -283,7 +283,7 @@ class UsersController < ApplicationController user_all.each { |user| realname = user.firstname.to_s + ' ' + user.lastname.to_s if user.email && user.email.to_s != '' - realname = realname + ' <' + user.email.to_s + '>' + realname = realname + ' <' + user.email.to_s + '>' end a = { id: user.id, label: realname, value: realname } users.push a diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 952cd2d1f..1f82b3dd9 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -108,7 +108,7 @@ returns # set relations self.class.reflect_on_all_associations.map { |assoc| - real_key = assoc.name.to_s[0,assoc.name.to_s.length-1] + '_ids' + real_key = assoc.name.to_s[0,assoc.name.to_s.length - 1] + '_ids' if params.has_key?( real_key.to_sym ) list_of_items = params[ real_key.to_sym ] if params[ real_key.to_sym ].class != Array @@ -141,7 +141,7 @@ returns # set relations attributes = self.attributes self.class.reflect_on_all_associations.map { |assoc| - real_key = assoc.name.to_s[0,assoc.name.to_s.length-1] + '_ids' + real_key = assoc.name.to_s[0,assoc.name.to_s.length - 1] + '_ids' if self.respond_to?( real_key ) attributes[ real_key ] = self.send( real_key ) end @@ -873,7 +873,7 @@ log object update history with all updated attributes, if configured - will be e # get attribute name attribute_name = key.to_s if attribute_name[-3,3] == '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] end value_id = [] diff --git a/app/models/application_model/search_index_base.rb b/app/models/application_model/search_index_base.rb index dfc7854f6..802498750 100644 --- a/app/models/application_model/search_index_base.rb +++ b/app/models/application_model/search_index_base.rb @@ -113,7 +113,7 @@ returns attribute_name_with_id = key.to_s attribute_name = key.to_s next if attribute_name[-3,3] != '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] # check if attribute method exists next if !ref_object.respond_to?( attribute_name ) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index f7af05bc5..939202ecb 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -191,7 +191,7 @@ class Channel::EmailParser else # text part only - if !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.downcase == 'text/plain' + if !mail.mime_type || mail.mime_type.to_s == '' || mail.mime_type.to_s.downcase == 'text/plain' data[:body] = mail.body.decoded data[:body] = Encode.conv( mail.charset, data[:body] ) @@ -535,9 +535,9 @@ class Channel::EmailParser next if key == 'created_by_id' # check if id exists - key_short = key[ key.length-3 , key.length ] + key_short = key[ key.length - 3 , key.length ] if key_short == '_id' - key_short = key[ 0, key.length-3 ] + key_short = key[ 0, key.length - 3 ] header = "x-zammad-#{header_name}-#{key_short}" if mail[ header.to_sym ] puts "NOTICE: header #{header} found #{mail[ header.to_sym ]}" diff --git a/app/models/observer/ticket/notification/background_job.rb b/app/models/observer/ticket/notification/background_job.rb index 8716eaa6c..e341b9fec 100644 --- a/app/models/observer/ticket/notification/background_job.rb +++ b/app/models/observer/ticket/notification/background_job.rb @@ -70,7 +70,7 @@ class Observer::Ticket::Notification::BackgroundJob object: 'Ticket', o_id: ticket.id, seen: seen, - created_by_id: ticket.updated_by_id || 1, + created_by_id: ticket.updated_by_id ||  1, user_id: user.id, ) @@ -134,7 +134,7 @@ class Observer::Ticket::Notification::BackgroundJob history_type: 'notification', history_object: 'Ticket', value_to: recipient_list, - created_by_id: ticket.updated_by_id || 1 + created_by_id: ticket.updated_by_id ||  1 ) end end @@ -166,7 +166,7 @@ class Observer::Ticket::Notification::BackgroundJob attribute_name = key.to_s object_manager_attribute = attribute_list[attribute_name] if attribute_name[-3,3] == '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ].to_s + attribute_name = attribute_name[ 0, attribute_name.length - 3 ].to_s end # add item to changes hash diff --git a/app/models/organization/search_index.rb b/app/models/organization/search_index.rb index 26bc44fb7..2df2b46e8 100644 --- a/app/models/organization/search_index.rb +++ b/app/models/organization/search_index.rb @@ -22,7 +22,7 @@ returns # get attribute name attribute_name = key.to_s next if attribute_name[-3,3] != '_id' - attribute_name = attribute_name[ 0, attribute_name.length-3 ] + attribute_name = attribute_name[ 0, attribute_name.length - 3 ] # check if attribute method exists next if !ref_object.respond_to?( attribute_name ) diff --git a/app/models/package.rb b/app/models/package.rb index 6589bbfb0..9c4b22dfd 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -391,7 +391,7 @@ class Package < ApplicationModel # check if directories need to be created directories = location.split '/' - (0..(directories.length-2) ).each {|position| + (0..(directories.length - 2) ).each {|position| tmp_path = '' (1..position).each {|count| tmp_path = tmp_path + '/' + directories[count].to_s diff --git a/db/migrate/20150112000001_update_overview_and_ticket_state.rb b/db/migrate/20150112000001_update_overview_and_ticket_state.rb index cbbf2b51f..e7aa0e6d0 100644 --- a/db/migrate/20150112000001_update_overview_and_ticket_state.rb +++ b/db/migrate/20150112000001_update_overview_and_ticket_state.rb @@ -14,7 +14,7 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration condition: { 'tickets.state_id' => [3], 'tickets.owner_id' => 'current_user.id', - 'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, + 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' }, }, order: { by: 'created_at', diff --git a/db/seeds.rb b/db/seeds.rb index 42fbc22f9..2b4aeca3a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1429,7 +1429,7 @@ Overview.create_if_not_exists( condition: { 'tickets.state_id' => [3], 'tickets.owner_id' => 'current_user.id', - 'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, + 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' }, }, order: { by: 'created_at', @@ -1491,7 +1491,7 @@ Overview.create_if_not_exists( role_id: overview_role.id, condition: { 'tickets.state_id' => [3], - 'tickets.pending_time' => { 'direction' => 'before', 'count'=> 1, 'area' => 'minute' }, + 'tickets.pending_time' => { 'direction' => 'before', 'count' => 1, 'area' => 'minute' }, }, order: { by: 'created_at', @@ -1511,7 +1511,7 @@ Overview.create_if_not_exists( prio: 1040, role_id: overview_role.id, condition: { - 'tickets.escalation_time' => { 'direction' => 'before', 'count'=> 5, 'area' => 'minute' }, + 'tickets.escalation_time' => { 'direction' => 'before', 'count' => 5, 'area' => 'minute' }, }, order: { by: 'escalation_time', diff --git a/lib/fill_db.rb b/lib/fill_db.rb index a9a000dc8..361c9e398 100644 --- a/lib/fill_db.rb +++ b/lib/fill_db.rb @@ -54,7 +54,7 @@ module FillDB suffix = rand(99_999).to_s organization = nil if !organization_pool.empty? && rand(2) == 1 - organization = organization_pool[ organization_pool.length-1 ] + organization = organization_pool[ organization_pool.length - 1 ] end user = User.create_or_update( login: "filldb-customer-#{suffix}", @@ -95,15 +95,15 @@ module FillDB state_pool = Ticket::State.all if tickets && !tickets.zero? (1..tickets).each {|count| - customer = customer_pool[ rand(customer_pool.length-1) ] - agent = agent_pool[ rand(agent_pool.length-1) ] + customer = customer_pool[ rand(customer_pool.length - 1) ] + agent = agent_pool[ rand(agent_pool.length - 1) ] ticket = Ticket.create( title: 'some title äöüß' + rand(999_999).to_s, - group: group_pool[ rand(group_pool.length-1) ], + group: group_pool[ rand(group_pool.length - 1) ], customer: customer, owner: agent, - state: state_pool[ rand(state_pool.length-1) ], - priority: priority_pool[ rand(priority_pool.length-1) ], + state: state_pool[ rand(state_pool.length - 1) ], + priority: priority_pool[ rand(priority_pool.length - 1) ], updated_by_id: agent.id, created_by_id: agent.id, ) diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index c5b54e1b8..8d27ee3d2 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -347,7 +347,7 @@ module Import::OTRS2 run = true while run count += steps - records = load('CustomerUser', steps, count-steps) + records = load('CustomerUser', steps, count - steps) if !records || !records[0] log 'all customers imported.' run = false @@ -371,11 +371,11 @@ module Import::OTRS2 while run count += steps log "loading... thread# #{thread} ..." - offset = count-steps + offset = count - steps if offset != 0 offset = count - steps + 1 end - records = load( 'Ticket', steps, count-steps) + records = load( 'Ticket', steps, count - steps) if !records || !records[0] log "... thread# #{thread}, no more work." run = false @@ -450,11 +450,11 @@ module Import::OTRS2 while run count += steps log 'loading... diff ...' - offset = count-steps + offset = count - steps if offset != 0 offset = count - steps + 1 end - records = load( 'Ticket', steps, count-steps, 1 ) + records = load( 'Ticket', steps, count - steps, 1 ) if !records || !records[0] log '... no more work.' run = false @@ -1037,7 +1037,7 @@ module Import::OTRS2 if group_lookup['Name'] == 'admin' && permissions && permissions.include?('rw') roles.push 'Admin' end - if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') || permissions.include?('rw') ) + if group_lookup['Name'] =~ /^(stats|report)/ && permissions && ( permissions.include?('ro') ||  permissions.include?('rw') ) roles.push 'Report' end end diff --git a/lib/sessions.rb b/lib/sessions.rb index d6dd1c6fc..cae7e09b2 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -269,7 +269,7 @@ returns while check if File::exists?( path + filename ) count += 1 - filename = filename + '-' + count + filename = filename + '-' + count else check = false end diff --git a/lib/sessions/backend/activity_stream.rb b/lib/sessions/backend/activity_stream.rb index 07043b00e..4e872d7d1 100644 --- a/lib/sessions/backend/activity_stream.rb +++ b/lib/sessions/backend/activity_stream.rb @@ -43,7 +43,7 @@ class Sessions::Backend::ActivityStream data = self.load - return if !data||data.empty? + return if !data || data.empty? if !@client return { diff --git a/lib/sessions/backend/collections/base.rb b/lib/sessions/backend/collections/base.rb index d48f55a0c..47217b0f3 100644 --- a/lib/sessions/backend/collections/base.rb +++ b/lib/sessions/backend/collections/base.rb @@ -52,7 +52,7 @@ class Sessions::Backend::Collections::Base # load current data items = self.load - return if !items||items.empty? + return if !items || items.empty? # get relations of data all = [] diff --git a/lib/sessions/backend/rss.rb b/lib/sessions/backend/rss.rb index 1a67fbcf9..5cc0de2fa 100644 --- a/lib/sessions/backend/rss.rb +++ b/lib/sessions/backend/rss.rb @@ -43,7 +43,7 @@ class Sessions::Backend::Rss data = self.load - return if !data||data.empty? + return if !data || data.empty? if !@client return { diff --git a/lib/time_calculation.rb b/lib/time_calculation.rb index 79bcbc3ab..d0b4bca2e 100644 --- a/lib/time_calculation.rb +++ b/lib/time_calculation.rb @@ -197,7 +197,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat # keep it in current day if next_hour == 23 - start_time += diff-1 + start_time += diff - 1 else start_time += diff end @@ -334,7 +334,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat # keep it in current day if next_hour == 23 - start_time += diff-1 + start_time += diff - 1 else start_time += diff end diff --git a/script/source_code_filter.rb b/script/source_code_filter.rb index 5967888ca..6fb5f3db2 100755 --- a/script/source_code_filter.rb +++ b/script/source_code_filter.rb @@ -22,7 +22,7 @@ def checkForHeader(fileName) # detect file type if allLines[0] =~ /(^# Copyright)/ || allLines[1] =~ /(^# Copyright)/ foundHeader = true - elsif allLines[1] =~/^=begin/ #assume external script + elsif allLines[1] =~ /^=begin/ #assume external script foundHeader = true end if allLines[0] =~ /(^#!\/)/ diff --git a/script/websocket-server.rb b/script/websocket-server.rb index aca2645b2..fca06f6fc 100755 --- a/script/websocket-server.rb +++ b/script/websocket-server.rb @@ -64,14 +64,14 @@ puts "Starting websocket server on #{ @options[:b] }:#{ @options[:p] } (secure:# if ARGV[0] == 'stop' # read pid - pid =File.open( @options[:i].to_s ).read + pid = File.open( @options[:i].to_s ).read pid.gsub!(/\r|\n/, '') # kill Process.kill( 9, pid.to_i ) exit end -if ARGV[0] == 'start' && @options[:d] +if ARGV[0] == 'start' && @options[:d] Daemons.daemonize diff --git a/test/unit/ticket_sla_test.rb b/test/unit/ticket_sla_test.rb index 3bacb6ba8..5d39b33dd 100644 --- a/test/unit/ticket_sla_test.rb +++ b/test/unit/ticket_sla_test.rb @@ -28,7 +28,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '8:00', 'end_of_workday' => '18:00', }, @@ -49,9 +49,9 @@ class TicketSlaTest < ActiveSupport::TestCase sla = Sla.create( name: 'test sla 2', - condition: { 'tickets.priority_id' =>['1', '2', '3'] }, + condition: { 'tickets.priority_id' => ['1', '2', '3'] }, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '8:00', 'end_of_workday' => '18:00', }, @@ -360,7 +360,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -402,7 +402,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -445,7 +445,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -549,7 +549,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -612,7 +612,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -706,7 +706,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', }, @@ -816,7 +816,7 @@ class TicketSlaTest < ActiveSupport::TestCase name: 'test sla 1', condition: {}, data: { - 'Mon'=>'Mon', 'Tue'=>'Tue', 'Wed'=>'Wed', 'Thu'=>'Thu', 'Fri'=>'Fri', 'Sat'=>'Sat', 'Sun'=>'Sun', + 'Mon' => 'Mon', 'Tue' => 'Tue', 'Wed' => 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun', 'beginning_of_workday' => '9:00', 'end_of_workday' => '18:00', },