Skip to content

Commit

Permalink
Maintenance: Activated rubocop Layout/SpaceInsideParens.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsteneckel authored and mgruner committed Jul 19, 2021
1 parent 5243efb commit 916bb77
Show file tree
Hide file tree
Showing 96 changed files with 310 additions and 315 deletions.
5 changes: 0 additions & 5 deletions .rubocop/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ Style/RescueStandardError:
Enabled: true
EnforcedStyle: implicit

Layout/SpaceInsideParens:
Description: 'No spaces after ( or before ).'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
Enabled: false

Layout/LeadingCommentSpace:
Description: 'Comments should start with a space.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/channels_google_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def inbound
channel.refresh_xoauth2!(force: true)

result = EmailHelper::Probe.inbound(channel.options[:inbound])
raise Exceptions::UnprocessableEntity, ( result[:message_human] || result[:message] ) if result[:result] == 'invalid'
raise Exceptions::UnprocessableEntity, (result[:message_human] || result[:message]) if result[:result] == 'invalid'

channel.status_in = 'ok'
channel.status_out = 'ok'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/channels_microsoft365_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def inbound
channel.refresh_xoauth2!(force: true)

result = EmailHelper::Probe.inbound(channel.options[:inbound])
raise Exceptions::UnprocessableEntity, ( result[:message_human] || result[:message] ) if result[:result] == 'invalid'
raise Exceptions::UnprocessableEntity, (result[:message_human] || result[:message]) if result[:result] == 'invalid'

channel.status_in = 'ok'
channel.status_out = 'ok'
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/user_devices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def destroy
next if !session.data['user_device_id']
next if session.data['user_device_id'] != user_device.id

SessionHelper.destroy( session.id )
SessionHelper.destroy(session.id)
end
user_device.destroy
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/activity_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def self.add(data)
# return if old entry is really fresh
if result
activity_record_delay = 90.seconds
return result if result.created_at.to_i >= ( data[:created_at].to_i - activity_record_delay )
return result if result.created_at.to_i >= (data[:created_at].to_i - activity_record_delay)
end

# create history
Expand Down
2 changes: 1 addition & 1 deletion app/models/application_model/can_associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def attributes_with_association_ids

if keys.size > 1
values = ids.transpose.map(&:compact).map(&:uniq)
attributes.merge!( keys.zip( values ).to_h )
attributes.merge!(keys.zip(values).to_h)
else
attributes[ keys.first ] = ids.compact
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/channel/filter/follow_up_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def self.run(_channel, mail, _transaction_params)
end

# get ticket# from references
return true if ( setting.include?('references') || (mail[:'x-zammad-is-auto-response'] == true || Setting.get('ticket_hook_position') == 'none') ) && follow_up_by_md5(mail)
return true if (setting.include?('references') || (mail[:'x-zammad-is-auto-response'] == true || Setting.get('ticket_hook_position') == 'none')) && follow_up_by_md5(mail)

# get ticket# from references current email has same subject as initial article
if mail[:subject].present?
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/has_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def group_access(group_id, access)

# check direct access
instances = joins(group_through.name)
.where( group_through.table_name => { group_id: group_id, access: access }, active: true )
.where(group_through.table_name => { group_id: group_id, access: access }, active: true)

if method_defined?(:permissions?)
permissions = Permission.with_parents('ticket.agent')
Expand Down
2 changes: 1 addition & 1 deletion app/models/knowledge_base/menu_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class KnowledgeBase::MenuItem < ApplicationModel
acts_as_list scope: %i[kb_locale_id location], top_of_list: 0

scope :sorted, -> { order(position: :asc) }
scope :using_locale, ->(locale) { locale.present? ? joins(:kb_locale).where(knowledge_base_locales: { system_locale_id: locale.id } ) : none }
scope :using_locale, ->(locale) { locale.present? ? joins(:kb_locale).where(knowledge_base_locales: { system_locale_id: locale.id }) : none }
scope :location, ->(location) { sorted.where(location: location) }

scope :location_header, -> { location(:header) }
Expand Down
10 changes: 5 additions & 5 deletions app/models/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Link < ApplicationModel
=end

def self.list(data)
linkobject = link_object_get( name: data[:link_object] )
linkobject = link_object_get(name: data[:link_object])
return if !linkobject

items = []
Expand All @@ -35,8 +35,8 @@ def self.list(data)

list.each do |item|
link = {}
link['link_type'] = @map[ Link::Type.find( item.link_type_id ).name ]
link['link_object'] = Link::Object.find( item.link_object_target_id ).name
link['link_type'] = @map[ Link::Type.find(item.link_type_id).name ]
link['link_object'] = Link::Object.find(item.link_object_target_id).name
link['link_object_value'] = item.link_object_target_value
items.push link
end
Expand All @@ -47,8 +47,8 @@ def self.list(data)
)
list.each do |item|
link = {}
link['link_type'] = Link::Type.find( item.link_type_id ).name
link['link_object'] = Link::Object.find( item.link_object_source_id ).name
link['link_type'] = Link::Type.find(item.link_type_id).name
link['link_object'] = Link::Object.find(item.link_object_source_id).name
link['link_object_value'] = item.link_object_source_value
items.push link
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def self._write_file(file, permission, data)

# check if directories need to be created
directories = location.split '/'
(0..(directories.length - 2) ).each do |position|
(0..(directories.length - 2)).each do |position|
tmp_path = ''
(1..position).each do |count|
tmp_path = "#{tmp_path}/#{directories[count]}"
Expand Down
4 changes: 2 additions & 2 deletions app/models/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def self.access_condition(user, access)
end

if user.permissions?('ticket.customer')
if !user.organization || ( !user.organization.shared || user.organization.shared == false )
if !user.organization || (!user.organization.shared || user.organization.shared == false)
sql.push('tickets.customer_id = ?')
bind.push(user.id)
else
Expand Down Expand Up @@ -661,7 +661,7 @@ def self.selector2sql(selectors, options = {})
biz = Calendar.lookup(id: selector['value'])&.biz
next if biz.blank?

if ( selector['operator'] == 'is in working time' && !biz.in_hours?(Time.zone.now) ) || ( selector['operator'] == 'is not in working time' && biz.in_hours?(Time.zone.now) )
if (selector['operator'] == 'is in working time' && !biz.in_hours?(Time.zone.now)) || (selector['operator'] == 'is not in working time' && biz.in_hours?(Time.zone.now))
no_result = true
break
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/ticket/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def self.insert_urls(article)
return article if article['body'] !~ %r{<img}i

inline_attachments = {}
article['body'].gsub!( %r{(<img[[:space:]](|.+?)src=")cid:(.+?)"(|.+?)>}im ) do |item|
article['body'].gsub!(%r{(<img[[:space:]](|.+?)src=")cid:(.+?)"(|.+?)>}im) do |item|
tag_start = $1
cid = $3
tag_end = $4
replace = item

# look for attachment
article['attachments'].each do |file|
next if !file[:preferences] || !file[:preferences]['Content-ID'] || (file[:preferences]['Content-ID'] != cid && file[:preferences]['Content-ID'] != "<#{cid}>" )
next if !file[:preferences] || !file[:preferences]['Content-ID'] || (file[:preferences]['Content-ID'] != cid && file[:preferences]['Content-ID'] != "<#{cid}>")

replace = "#{tag_start}/api/v1/ticket_attachment/#{article['ticket_id']}/#{article['id']}/#{file[:id]}?view=inline\"#{tag_end}>"
inline_attachments[file[:id]] = true
Expand Down Expand Up @@ -132,13 +132,13 @@ def self.insert_urls(article)

def attachments_inline
inline_attachments = {}
body.gsub( %r{<img[[:space:]](|.+?)src="cid:(.+?)"(|.+?)>}im ) do |_item|
body.gsub(%r{<img[[:space:]](|.+?)src="cid:(.+?)"(|.+?)>}im) do |_item|
cid = $2

# look for attachment
attachments.each do |file|
content_id = file.preferences['Content-ID'] || file.preferences['content_id']
next if content_id.blank? || (content_id != cid && content_id != "<#{cid}>" )
next if content_id.blank? || (content_id != cid && content_id != "<#{cid}>")

inline_attachments[file.id] = true
break
Expand Down
4 changes: 2 additions & 2 deletions app/models/ticket/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def search(params)
end
end
if current_user.permissions?('ticket.customer')
access_condition = if !current_user.organization || ( !current_user.organization.shared || current_user.organization.shared == false )
access_condition = if !current_user.organization || (!current_user.organization.shared || current_user.organization.shared == false)
{
'query_string' => { 'default_field' => 'customer_id', 'query' => current_user.id }
}
Expand Down Expand Up @@ -202,7 +202,7 @@ def search(params)
query.delete! '*'
tickets_all = Ticket.select("DISTINCT(tickets.id), #{order_select_sql}")
.where(access_condition)
.where('(tickets.title LIKE ? OR tickets.number LIKE ? OR ticket_articles.body LIKE ? OR ticket_articles.from LIKE ? OR ticket_articles.to LIKE ? OR ticket_articles.subject LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" )
.where('(tickets.title LIKE ? OR tickets.number LIKE ? OR ticket_articles.body LIKE ? OR ticket_articles.from LIKE ? OR ticket_articles.to LIKE ? OR ticket_articles.subject LIKE ?)', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%")
.joins(:articles)
.order(Arel.sql(order_sql))
.offset(offset)
Expand Down
8 changes: 4 additions & 4 deletions app/models/type_lookup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

class TypeLookup < ApplicationModel

def self.by_id( id )
lookup = self.lookup( id: id )
def self.by_id(id)
lookup = self.lookup(id: id)
return if !lookup

lookup.name
end

def self.by_name( name )
def self.by_name(name)
# lookup
lookup = self.lookup( name: name )
lookup = self.lookup(name: name)
if lookup
return lookup.id
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/core_ext.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/

# load all core_ext extensions
Dir.glob( Rails.root.join('lib/core_ext/**/*') ).sort.each do |file|
Dir.glob(Rails.root.join('lib/core_ext/**/*')).sort.each do |file|
if File.file?(file)
require file
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# load routes from external files
dir = File.expand_path(__dir__)
files = Dir.glob( "#{dir}/routes/*.rb" )
files = Dir.glob("#{dir}/routes/*.rb")
files.each do |file|
if Rails.configuration.cache_classes
require_dependency file
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/20170123000002_fixed_translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def up
]

settings_update.each do |setting|
fetched_setting = Setting.find_by(name: setting['name'] )
fetched_setting = Setting.find_by(name: setting['name'])
next if !fetched_setting

if setting['title']
Expand Down
2 changes: 1 addition & 1 deletion lib/calendar_subscriptions/tickets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def owner_ids(method)
owner_ids = [ @user.id ]
end
if preferences[:not_assigned]
owner_ids.push( 1 )
owner_ids.push(1)
end

owner_ids
Expand Down
6 changes: 3 additions & 3 deletions lib/import/exchange/item_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def normalize(properties)
def sub_elems(elems)
elems.each_with_object({}) do |elem, result|
if elem[:entry]
result.merge!( sub_elem_entry( elem[:entry] ) )
result.merge!(sub_elem_entry(elem[:entry]))
else
result.merge!( normalize(elem) )
result.merge!(normalize(elem))
end
end
end
Expand Down Expand Up @@ -88,7 +88,7 @@ def flatten(properties, prefix: nil)

result_key = key
if prefix
result_key = if keys.include?(key) && ( !result[result_key] || result[result_key] == value )
result_key = if keys.include?(key) && (!result[result_key] || result[result_key] == value)
prefix
else
:"#{prefix}.#{key}"
Expand Down
2 changes: 1 addition & 1 deletion lib/import/otrs/ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def dynamic_fields(ticket)

dynamic_field_name = key_string[13, key_string.length]

next if Import::OTRS::DynamicFieldFactory.skip_field?( dynamic_field_name )
next if Import::OTRS::DynamicFieldFactory.skip_field?(dynamic_field_name)

dynamic_field_name = Import::OTRS::DynamicField.convert_name(dynamic_field_name)

Expand Down
2 changes: 1 addition & 1 deletion lib/import/otrs/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def groups_from_otrs_group(role_object, group)
end

return result if !group['Name'].match?(%r{^(stats|report)})
return result if !( permissions.include?('ro') || permissions.include?('rw') )
return result if !(permissions.include?('ro') || permissions.include?('rw'))

result.push 'Report'
result
Expand Down
2 changes: 1 addition & 1 deletion lib/import/zendesk/object_attribute/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(object, name, attribute)
def init_callback(_attribute); end

def add(object, name, attribute)
ObjectManager::Attribute.add( attribute_config(object, name, attribute) )
ObjectManager::Attribute.add(attribute_config(object, name, attribute))
ObjectManager::Attribute.migration_execute(false)
rescue
# rubocop:disable Style/SpecialGlobalVars
Expand Down
2 changes: 1 addition & 1 deletion lib/report/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def self.time_max(data)
end

def self.ticket_condition(ticket_id, condition)
ticket = Ticket.lookup( id: ticket_id )
ticket = Ticket.lookup(id: ticket_id)
condition.each do |key, value|
if ticket[key.to_sym] != value
return false
Expand Down
4 changes: 2 additions & 2 deletions lib/report/ticket_first_solution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def self.aggs(params_origin)
ticket_list.each do |ticket|
closed_at = ticket.close_at
created_at = ticket.created_at
if (closed_at - (60 * 15) ) < created_at
if (closed_at - (60 * 15)) < created_at
count += 1
end
end
Expand Down Expand Up @@ -112,7 +112,7 @@ def self.items(params)
ticket_list.each do |ticket|
closed_at = ticket.close_at
created_at = ticket.created_at
if (closed_at - (60 * 15) ) < created_at
if (closed_at - (60 * 15)) < created_at
count += 1
ticket_ids.push ticket.id
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sequencer/unit/import/zendesk/user_group_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def mapping
result = {}
client.group_memberships.all! do |group_membership|
result[ group_membership.user_id ] ||= []
result[ group_membership.user_id ].push( group_membership.group_id )
result[ group_membership.user_id ].push(group_membership.group_id)
end
result
end
Expand Down
2 changes: 1 addition & 1 deletion lib/session_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def self.default_collections(user)

# load collections to deliver from external files
dir = File.expand_path('..', __dir__)
files = Dir.glob( "#{dir}/lib/session_helper/collection_*.rb")
files = Dir.glob("#{dir}/lib/session_helper/collection_*.rb")
files.each do |file|
file =~ %r{/(session_helper/collection_.*)\.rb\z}
(default_collection, assets) = $1.camelize.constantize.session(default_collection, assets, user)
Expand Down
2 changes: 1 addition & 1 deletion lib/session_helper/collection_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SessionHelper::CollectionBase

module_function

def session( collections, assets, user )
def session(collections, assets, user)

# all base stuff
collections[ Locale.to_app_model ] = Locale.where(active: true)
Expand Down
2 changes: 1 addition & 1 deletion lib/session_helper/collection_dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SessionHelper::CollectionDashboard

module_function

def session( collections, assets, user )
def session(collections, assets, user)
return [collections, assets] if !user

item = StatsStore.find_by(
Expand Down
2 changes: 1 addition & 1 deletion lib/session_helper/collection_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SessionHelper::CollectionTicket

module_function

def session( collections, assets, user )
def session(collections, assets, user)

# all ticket stuff
collections[ Ticket::StateType.to_app_model ] = []
Expand Down
6 changes: 3 additions & 3 deletions lib/sessions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def self.destroy_idle_sessions(idle_time_in_sec = 240)
list_of_closed_sessions = []
clients = Sessions.list
clients.each do |client_id, client|
if !client[:meta] || !client[:meta][:last_ping] || ( client[:meta][:last_ping].to_i + idle_time_in_sec ) < Time.now.utc.to_i
if !client[:meta] || !client[:meta][:last_ping] || (client[:meta][:last_ping].to_i + idle_time_in_sec) < Time.now.utc.to_i
list_of_closed_sessions.push client_id
Sessions.destroy(client_id)
end
Expand Down Expand Up @@ -579,7 +579,7 @@ def self.thread_client(client_id, try_count = 0, try_run_time = Time.now.utc, no
Sessions::Client.new(client_id, node_id)
rescue => e
log('error', "thread_client #{client_id} exited with error #{e.inspect}")
log('error', e.backtrace.join("\n ") )
log('error', e.backtrace.join("\n "))
sleep 10
begin
ActiveRecord::Base.connection_pool.release_connection
Expand All @@ -591,7 +591,7 @@ def self.thread_client(client_id, try_count = 0, try_run_time = Time.now.utc, no
try_count += 1

# reset error counter if to old
if try_run_time + ( 60 * 5 ) < Time.now.utc
if try_run_time + (60 * 5) < Time.now.utc
try_count = 0
end
try_run_time = Time.now.utc
Expand Down
Loading

0 comments on commit 916bb77

Please sign in to comment.