Some new rubocop checks.

This commit is contained in:
Martin Edenhofer 2015-04-27 23:27:51 +02:00
parent 5b98be93e1
commit a2d49cefc5
26 changed files with 1178 additions and 1138 deletions

View file

@ -31,12 +31,11 @@ returns
return data if !self['created_by_id'] && !self['updated_by_id']
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end
}
data
end

View file

@ -16,7 +16,6 @@ class Locale < ApplicationModel
raise "Can't load locales from #{url}: #{result.error}" if !result.success?
result.data.each {|locale|
puts locale.inspect
exists = Locale.where(locale: locale['locale']).first
if exists
exists.update(locale.symbolize_keys!)

View file

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

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::ActivityStreamLog
class Ticket
module ActivityStreamLog
=begin
@ -35,5 +36,5 @@ returns
created_by_id: user_id,
)
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Article < ApplicationModel
class Ticket
class Article < ApplicationModel
load 'ticket/article/assets.rb'
include Ticket::Article::Assets
load 'ticket/article/history_log.rb'
@ -48,3 +49,4 @@ class Ticket::Article < ApplicationModel
latest_change_support
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Article::ActivityStreamLog
class Ticket
class Article
module ActivityStreamLog
=begin
@ -36,5 +38,6 @@ returns
created_by_id: user_id,
)
end
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Article::Assets
class Ticket
class Article
module Assets
=begin
@ -42,14 +44,14 @@ returns
end
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end
}
data
end
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Article::HistoryLog
class Ticket
class Article
module HistoryLog
=begin
@ -27,5 +29,6 @@ returns
data[:created_by_id] = user_id
History.add(data)
end
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Assets
class Ticket
module Assets
=begin
@ -30,14 +31,13 @@ returns
data[ Ticket.to_app_model ][ self.id ] = self.attributes_with_associations
end
['created_by_id', 'updated_by_id', 'owner_id', 'customer_id'].each {|item|
if self[ item ]
next if !self[ item ]
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end
}
data
end
end
end

View file

@ -1,4 +1,6 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Counter < ApplicationModel
class Ticket
class Counter < ApplicationModel
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Escalation
class Ticket
module Escalation
=begin
@ -321,3 +322,4 @@ returns
return escalation_time
end
end
end

View file

@ -1,4 +1,6 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Flag < ApplicationModel
class Ticket
class Flag < ApplicationModel
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::HistoryLog
class Ticket
module HistoryLog
=begin
@ -77,5 +78,5 @@ returns
assets: assets,
}
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Number
class Ticket
class Number
include ApplicationLib
=begin
@ -56,3 +57,4 @@ returns
adapter
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Number::Date
class Ticket
class Number
module Date
extend self
def generate
@ -8,7 +10,7 @@ module Ticket::Number::Date
# get config
config = Setting.get('ticket_number_date')
t = Time.now
t = Time.zone.now
date = t.strftime('%Y-%m-%d')
# read counter
@ -64,6 +66,7 @@ module Ticket::Number::Date
end
number
end
def check(string)
# get config
@ -73,11 +76,13 @@ module Ticket::Number::Date
ticket = nil
# probe format
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i then
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,50})/i
ticket = Ticket.where( number: $1 ).first
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i then
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,50})/i
ticket = Ticket.where( number: $1 ).first
end
ticket
end
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Number::Increment
class Ticket
class Number
module Increment
extend self
def generate
@ -77,11 +79,13 @@ module Ticket::Number::Increment
ticket = nil
# probe format
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i then
if string =~ /#{ticket_hook}#{ticket_hook_divider}(#{system_id}\d{2,48})/i
ticket = Ticket.where( number: $1 ).first
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i then
elsif string =~ /#{ticket_hook}\s{0,2}(#{system_id}\d{2,48})/i
ticket = Ticket.where( number: $1 ).first
end
ticket
end
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Overviews
class Ticket
module Overviews
=begin
@ -189,6 +190,7 @@ returns
end
private
def self._condition(condition)
sql = ''
bind = [nil]
@ -248,3 +250,4 @@ returns
bind
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Permission
class Ticket
module Permission
=begin
@ -43,5 +44,5 @@ returns
}
false
end
end
end

View file

@ -1,6 +1,8 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::Priority < ApplicationModel
class Ticket
class Priority < ApplicationModel
self.table_name = 'ticket_priorities'
validates :name, presence: true
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::ScreenOptions
class Ticket
module ScreenOptions
=begin
@ -173,5 +174,5 @@ returns
assets: assets,
}
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Search
class Ticket
module Search
=begin
@ -63,9 +64,9 @@ returns
query_extention['bool']['must'] = []
if current_user.is_role('Agent')
groups = Group.joins(:users).
where( 'groups_users.user_id = ?', current_user.id ).
where( 'groups.active = ?', true )
groups = Group.joins(:users)
.where( 'groups_users.user_id = ?', current_user.id )
.where( 'groups.active = ?', true )
group_condition = []
groups.each {|group|
group_condition.push group.name
@ -113,18 +114,18 @@ returns
# - stip out * we already search for *query* -
if query
query.gsub! '*', ''
tickets_all = Ticket.select('DISTINCT(tickets.id)').
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}%" ).
joins(:articles).
order('`tickets`.`created_at` DESC').
limit(limit)
tickets_all = Ticket.select('DISTINCT(tickets.id)')
.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}%" )
.joins(:articles)
.order('`tickets`.`created_at` DESC')
.limit(limit)
else
tickets_all = Ticket.select('DISTINCT(tickets.id)').
where(access_condition).
where(params[:condition]).
order('`tickets`.`created_at` DESC').
limit(limit)
tickets_all = Ticket.select('DISTINCT(tickets.id)')
.where(access_condition)
.where(params[:condition])
.order('`tickets`.`created_at` DESC')
.limit(limit)
end
# build result list
@ -142,5 +143,5 @@ returns
}
tickets
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::SearchIndex
class Ticket
module SearchIndex
=begin
@ -105,5 +106,5 @@ returns
return if !attributes
SearchIndexBackend.add(self.class.to_s, attributes)
end
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::State < ApplicationModel
class Ticket
class State < ApplicationModel
belongs_to :state_type, class_name: 'Ticket::StateType'
validates :name, presence: true
@ -51,3 +52,4 @@ returns:
false
end
end
end

View file

@ -1,7 +1,9 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
class Ticket::StateType < ApplicationModel
class Ticket
class StateType < ApplicationModel
has_many :states, class_name: 'Ticket::State'
validates :name, presence: true
latest_change_support
end
end

View file

@ -1,6 +1,7 @@
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
module Ticket::Subject
class Ticket
module Subject
=begin
@ -76,3 +77,4 @@ returns
subject
end
end
end

View file

@ -75,12 +75,11 @@ returns
end
end
['created_by_id', 'updated_by_id'].each {|item|
if self[ item ]
next if !self[ item ]
if !data[ User.to_app_model ][ self[ item ] ]
user = User.lookup( id: self[ item ] )
data = user.assets( data )
end
end
}
data
end