Corrected with rubocop cop 'Style/WordArray'.

This commit is contained in:
Thorsten Eckel 2015-05-07 09:23:16 +02:00
parent f982288eb4
commit b3b76acc89
29 changed files with 59 additions and 67 deletions

View file

@ -215,11 +215,6 @@ Style/SignalException:
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
Enabled: false Enabled: false
Style/WordArray:
Description: 'Use %w or %W for arrays of words.'
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
Enabled: false
Metrics/AbcSize: Metrics/AbcSize:
Description: >- Description: >-
A calculated magnitude based on number of assignments, A calculated magnitude based on number of assignments,

View file

@ -75,10 +75,7 @@ class IcalTicketsController < ApplicationController
'tickets.owner_id' => current_user.id, 'tickets.owner_id' => current_user.id,
'tickets.state_id' => Ticket::State.where( 'tickets.state_id' => Ticket::State.where(
state_type_id: Ticket::StateType.where( state_type_id: Ticket::StateType.where(
name: [ name: %w(new open),
'new',
'open',
],
), ),
), ),
} }

View file

@ -20,7 +20,7 @@ class SearchController < ApplicationController
assets = {} assets = {}
result = [] result = []
if SearchIndexBackend.enabled? if SearchIndexBackend.enabled?
items = SearchIndexBackend.search( query, limit, ['User', 'Organization'] ) items = SearchIndexBackend.search( query, limit, %w(User Organization) )
items.each { |item| items.each { |item|
require item[:type].to_filename require item[:type].to_filename
record = Kernel.const_get( item[:type] ).find( item[:id] ) record = Kernel.const_get( item[:type] ).find( item[:id] )

View file

@ -30,7 +30,7 @@ returns
end end
return data if !self['created_by_id'] && !self['updated_by_id'] return data if !self['created_by_id'] && !self['updated_by_id']
['created_by_id', 'updated_by_id'].each {|item| %w(created_by_id updated_by_id).each {|item|
next if !self[ item ] next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ] if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] ) user = User.lookup( id: self[ item ] )

View file

@ -72,7 +72,7 @@ returns
def search_index_data def search_index_data
attributes = {} attributes = {}
['name', 'note'].each { |key| %w(name note).each { |key|
if self[key] && !self[key].empty? if self[key] && !self[key].empty?
attributes[key] = self[key] attributes[key] = self[key]
end end

View file

@ -503,7 +503,7 @@ class Channel::EmailParser
roles = Role.where( name: 'Customer' ) roles = Role.where( name: 'Customer' )
# fillup # fillup
['firstname', 'lastname'].each { |item| %w(firstname lastname).each { |item|
if data[item.to_sym] == nil if data[item.to_sym] == nil
data[item.to_sym] = '' data[item.to_sym] = ''
end end

View file

@ -11,7 +11,7 @@ list all backend managed object
=end =end
def self.list_objects def self.list_objects
['Ticket', 'TicketArticle', 'User', 'Organization', 'Group' ] %w(Ticket TicketArticle User Organization Group)
end end
=begin =begin
@ -23,7 +23,7 @@ list all frontend managed object
=end =end
def self.list_frontend_objects def self.list_frontend_objects
['Ticket', 'User', 'Organization' ] #, 'Group' ] %w(Ticket User Organization) #, 'Group' ]
end end
end end

View file

@ -13,7 +13,7 @@ class Observer::User::Geo < ActiveRecord::Observer
# check if geo need to be updated # check if geo need to be updated
def check_geo(record) def check_geo(record)
location = ['street', 'zip', 'city', 'country'] location = %w(street zip city country)
# check if geo update is needed based on old/new location # check if geo update is needed based on old/new location
if record.id if record.id
@ -42,7 +42,7 @@ class Observer::User::Geo < ActiveRecord::Observer
# update geo data of user # update geo data of user
def geo_update(record) def geo_update(record)
address = '' address = ''
location = ['street', 'zip', 'city', 'country'] location = %w(street zip city country)
location.each { |item| location.each { |item|
if record[item] && record[item] != '' if record[item] && record[item] != ''
address = address + ',' + record[item] address = address + ',' + record[item]

View file

@ -40,7 +40,7 @@ returns
} }
end end
end end
['created_by_id', 'updated_by_id'].each {|item| %w(created_by_id updated_by_id).each {|item|
next if !self[ item ] next if !self[ item ]
if !data[ User.to_app_model ][ self[ item ] ] if !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] ) user = User.lookup( id: self[ item ] )

View file

@ -311,7 +311,7 @@ class Package < ApplicationModel
# reload .rb files in case they have changed # reload .rb files in case they have changed
def self.reload_classes def self.reload_classes
['app', 'lib'].each {|dir| %w(app lib).each {|dir|
Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry| Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry|
if entry =~ /\.rb$/ if entry =~ /\.rb$/
begin begin

View file

@ -41,7 +41,7 @@ returns
data[ Ticket::Article.to_app_model ][ self.id ]['attachments'] = self.attachments data[ Ticket::Article.to_app_model ][ self.id ]['attachments'] = self.attachments
end end
['created_by_id', 'updated_by_id'].each {|item| %w(created_by_id updated_by_id).each {|item|
next if !self[ item ] next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ] if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] ) user = User.lookup( id: self[ item ] )

View file

@ -29,7 +29,7 @@ returns
if !data[ Ticket.to_app_model ][ self.id ] if !data[ Ticket.to_app_model ][ self.id ]
data[ Ticket.to_app_model ][ self.id ] = self.attributes_with_associations data[ Ticket.to_app_model ][ self.id ] = self.attributes_with_associations
end end
['created_by_id', 'updated_by_id', 'owner_id', 'customer_id'].each {|item| %w(created_by_id updated_by_id owner_id customer_id).each {|item|
next if !self[ item ] next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ] if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] ) user = User.lookup( id: self[ item ] )

View file

@ -83,7 +83,7 @@ returns
type_ids = [] type_ids = []
if params[:ticket] if params[:ticket]
types = ['note', 'phone'] types = %w(note phone)
if params[:ticket].group.email_address_id if params[:ticket].group.email_address_id
types.push 'email' types.push 'email'
end end

View file

@ -63,7 +63,7 @@ returns
article_attributes = article.attributes article_attributes = article.attributes
# remove note needed attributes # remove note needed attributes
ignore = ['created_by_id', 'updated_by_id', 'updated_at', 'references', 'message_id_md5', 'message_id', 'in_reply_to', 'ticket_id'] ignore = %w(created_by_id updated_by_id updated_at references message_id_md5 message_id in_reply_to ticket_id)
ignore.each {|attribute| ignore.each {|attribute|
article_attributes.delete( attribute ) article_attributes.delete( attribute )
} }

View file

@ -46,7 +46,7 @@ returns:
=end =end
def ignore_escalation? def ignore_escalation?
ignore_escalation = ['removed', 'closed', 'merged'] ignore_escalation = %w(removed closed merged)
return true if ignore_escalation.include?( self.name ) return true if ignore_escalation.include?( self.name )
false false
end end

View file

@ -74,7 +74,7 @@ returns
data = organization.assets( data ) data = organization.assets( data )
end end
end end
['created_by_id', 'updated_by_id'].each {|item| %w(created_by_id updated_by_id).each {|item|
next if !self[ item ] next if !self[ item ]
if !data[ User.to_app_model ][ self[ item ] ] if !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] ) user = User.lookup( id: self[ item ] )

View file

@ -18,7 +18,7 @@ returns
def search_index_data def search_index_data
attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" } attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" }
['login', 'firstname', 'lastname', 'phone', 'email', 'city', 'country', 'note', 'created_at'].each { |key| %w(login firstname lastname phone email city country note created_at).each { |key|
if self[key] && (!self.respond_to?('empty?') || !self[key].empty?) if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
attributes[key] = self[key] attributes[key] = self[key]
end end

View file

@ -35,7 +35,7 @@ class UpdateAuth < ActiveRecord::Migration
uid: 'mail', uid: 'mail',
base: 'dc=example,dc=org', base: 'dc=example,dc=org',
always_filter: '', always_filter: '',
always_roles: ['Admin', 'Agent'], always_roles: %w(Admin Agent),
always_groups: ['Users'], always_groups: ['Users'],
sync_params: { sync_params: {
firstname: 'sn', firstname: 'sn',

View file

@ -23,9 +23,9 @@ class UpdateOverviewAndTicketState < ActiveRecord::Migration
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'created_at' ], d: %w(title customer group created_at),
s: [ 'title', 'customer', 'group', 'created_at' ], s: %w(title customer group created_at),
m: [ 'number', 'title', 'customer', 'group', 'created_at' ], m: %w(number title customer group created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )

View file

@ -19,7 +19,7 @@ class CreateAddress < ActiveRecord::Migration
end end
} }
['street', 'zip', 'city', 'department'].each {|attribute_name| %w(street zip city department).each {|attribute_name|
attribute = ObjectManager::Attribute.get( attribute = ObjectManager::Attribute.get(
object: 'User', object: 'User',
name: attribute_name, name: attribute_name,

View file

@ -20,9 +20,9 @@ class UpdateOverview2 < ActiveRecord::Migration
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'created_at' ], d: %w(title customer group created_at),
s: [ 'title', 'customer', 'group', 'created_at' ], s: %w(title customer group created_at),
m: [ 'number', 'title', 'customer', 'group', 'created_at' ], m: %w(number title customer group created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )

View file

@ -363,7 +363,7 @@ Setting.create_if_not_exists(
uid: 'mail', uid: 'mail',
base: 'dc=example,dc=org', base: 'dc=example,dc=org',
always_filter: '', always_filter: '',
always_roles: ['Admin', 'Agent'], always_roles: %w(Admin Agent),
always_groups: ['Users'], always_groups: ['Users'],
sync_params: { sync_params: {
firstname: 'sn', firstname: 'sn',
@ -1432,9 +1432,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'created_at' ], d: %w(title customer group created_at),
s: [ 'title', 'customer', 'group', 'created_at' ], s: %w(title customer group created_at),
m: [ 'number', 'title', 'customer', 'group', 'created_at' ], m: %w(number title customer group created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1454,9 +1454,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'created_at' ], d: %w(title customer group created_at),
s: [ 'title', 'customer', 'group', 'created_at' ], s: %w(title customer group created_at),
m: [ 'number', 'title', 'customer', 'group', 'created_at' ], m: %w(number title customer group created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1475,9 +1475,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'created_at' ], d: %w(title customer group created_at),
s: [ 'title', 'customer', 'group', 'created_at' ], s: %w(title customer group created_at),
m: [ 'number', 'title', 'customer', 'group', 'created_at' ], m: %w(number title customer group created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1495,9 +1495,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'state', 'owner', 'created_at' ], d: %w(title customer group state owner created_at),
s: [ 'title', 'customer', 'group', 'state', 'owner', 'created_at' ], s: %w(title customer group state owner created_at),
m: [ 'number', 'title', 'customer', 'group', 'state', 'owner', 'created_at' ], m: %w(number title customer group state owner created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1516,9 +1516,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'owner', 'created_at' ], d: %w(title customer group owner created_at),
s: [ 'title', 'customer', 'group', 'owner', 'created_at' ], s: %w(title customer group owner created_at),
m: [ 'number', 'title', 'customer', 'group', 'owner', 'created_at' ], m: %w(number title customer group owner created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1536,9 +1536,9 @@ Overview.create_if_not_exists(
direction: 'ASC', direction: 'ASC',
}, },
view: { view: {
d: [ 'title', 'customer', 'group', 'owner', 'escalation_time' ], d: %w(title customer group owner escalation_time),
s: [ 'title', 'customer', 'group', 'owner', 'escalation_time' ], s: %w(title customer group owner escalation_time),
m: [ 'number', 'title', 'customer', 'group', 'owner', 'escalation_time' ], m: %w(number title customer group owner escalation_time),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1558,9 +1558,9 @@ Overview.create_if_not_exists(
direction: 'DESC', direction: 'DESC',
}, },
view: { view: {
d: [ 'title', 'customer', 'state', 'created_at' ], d: %w(title customer state created_at),
s: [ 'number', 'title', 'state', 'created_at' ], s: %w(number title state created_at),
m: [ 'number', 'title', 'state', 'created_at' ], m: %w(number title state created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )
@ -1579,9 +1579,9 @@ Overview.create_if_not_exists(
direction: 'DESC', direction: 'DESC',
}, },
view: { view: {
d: [ 'title', 'customer', 'state', 'created_at' ], d: %w(title customer state created_at),
s: [ 'number', 'title', 'customer', 'state', 'created_at' ], s: %w(number title customer state created_at),
m: [ 'number', 'title', 'customer', 'state', 'created_at' ], m: %w(number title customer state created_at),
view_mode_default: 's', view_mode_default: 's',
}, },
) )

View file

@ -34,7 +34,7 @@ returns
# create Users # create Users
if auto_wizard_hash['Users'] if auto_wizard_hash['Users']
roles = Role.where( name: ['Agent', 'Admin'] ) roles = Role.where( name: %w(Agent Admin) )
groups = Group.all groups = Group.all
auto_wizard_hash['Users'].each { |user_data| auto_wizard_hash['Users'].each { |user_data|

View file

@ -4,7 +4,7 @@ require 'test_helper'
class AssetsTest < ActiveSupport::TestCase class AssetsTest < ActiveSupport::TestCase
test 'user' do test 'user' do
roles = Role.where( name: [ 'Agent', 'Admin'] ) roles = Role.where( name: %w(Agent Admin) )
groups = Group.all groups = Group.all
org = Organization.create_or_update( org = Organization.create_or_update(
name: 'some org', name: 'some org',

View file

@ -15,7 +15,7 @@ Setting.create_or_update(
uid: 'mail', uid: 'mail',
base: 'dc=example,dc=org', base: 'dc=example,dc=org',
always_filter: '', always_filter: '',
always_roles: ['Admin', 'Agent'], always_roles: %w(Admin Agent),
always_groups: ['Users'], always_groups: ['Users'],
sync_params: { sync_params: {
firstname: 'sn', firstname: 'sn',

View file

@ -12,7 +12,7 @@ class RestTest < ActiveSupport::TestCase
end end
# create agent # create agent
roles = Role.where( name: ['Admin', 'Agent'] ) roles = Role.where( name: %w(Admin Agent) )
groups = Group.all groups = Group.all
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1

View file

@ -181,7 +181,7 @@ class SessionBasicTest < ActiveSupport::TestCase
end end
user = User.lookup(id: 1) user = User.lookup(id: 1)
roles = Role.where( name: [ 'Agent', 'Admin'] ) roles = Role.where( name: %w(Agent Admin) )
user.roles = roles user.roles = roles
user.save user.save
@ -258,7 +258,7 @@ class SessionBasicTest < ActiveSupport::TestCase
test 'c activity stream' do test 'c activity stream' do
# create users # create users
roles = Role.where( name: [ 'Agent', 'Admin'] ) roles = Role.where( name: %w(Agent Admin) )
groups = Group.all groups = Group.all
UserInfo.current_user_id = 2 UserInfo.current_user_id = 2

View file

@ -9,7 +9,7 @@ class SessionCollectionsTest < ActiveSupport::TestCase
UserInfo.current_user_id = 1 UserInfo.current_user_id = 1
# create users # create users
roles = Role.where( name: [ 'Agent', 'Admin'] ) roles = Role.where( name: %w(Agent Admin) )
groups = Group.all groups = Group.all
agent1 = User.create_or_update( agent1 = User.create_or_update(

View file

@ -49,7 +49,7 @@ class TicketSlaTest < ActiveSupport::TestCase
sla = Sla.create( sla = Sla.create(
name: 'test sla 2', name: 'test sla 2',
condition: { 'tickets.priority_id' => ['1', '2', '3'] }, condition: { 'tickets.priority_id' => %w(1 2 3) },
data: { 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', 'beginning_of_workday' => '8:00',