From 8b822a7ddcbf13e2b954270832fa4a279d2ce586 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 8 May 2015 15:47:27 +0200 Subject: [PATCH] Corrected with rubocop cop 'Style/ClassVars'. --- .rubocop.yml | 2 -- app/models/application_model.rb | 7 ++++--- app/models/history.rb | 2 ++ app/models/object_lookup.rb | 2 +- app/models/package.rb | 4 ++-- app/models/setting.rb | 2 +- app/models/tag.rb | 2 ++ app/models/type_lookup.rb | 2 +- lib/sessions.rb | 2 +- lib/sessions/cache_in.rb | 3 +++ 10 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 7aeed4256..8c8a4d7f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -187,7 +187,5 @@ Style/Documentation: Lint/RescueException: Enabled: false -Style/ClassVars: - Enabled: false Lint/UselessAssignment: Enabled: false diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 81f48305b..470f5c2c7 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -41,12 +41,13 @@ class ApplicationModel < ActiveRecord::Base attr_accessor :history_changes_last_done - @@import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::StateType', 'Ticket::Priority', 'Group', 'User', 'Role' ] - def check_attributes_protected + import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::StateType', 'Ticket::Priority', 'Group', 'User', 'Role' ] + # do noting, use id as it is - return if !Setting.get('system_init_done') || ( Setting.get('import_mode') && @@import_class_list.include?( self.class.to_s ) ) + return if !Setting.get('system_init_done') + return if Setting.get('import_mode') && import_class_list.include?( self.class.to_s ) self[:id] = nil end diff --git a/app/models/history.rb b/app/models/history.rb index b836d06b0..23d499422 100644 --- a/app/models/history.rb +++ b/app/models/history.rb @@ -11,9 +11,11 @@ class History < ApplicationModel # before_validation :check_type, :check_object # attr_writer :history_type, :history_object + # rubocop:disable Style/ClassVars @@cache_type = {} @@cache_object = {} @@cache_attribute = {} +# rubocop:enable Style/ClassVars =begin diff --git a/app/models/object_lookup.rb b/app/models/object_lookup.rb index 0f31baa61..b3e5ccebd 100644 --- a/app/models/object_lookup.rb +++ b/app/models/object_lookup.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class ObjectLookup < ApplicationModel - @@cache_object = {} + @@cache_object = {} # rubocop:disable Style/ClassVars def self.by_id( id ) diff --git a/app/models/package.rb b/app/models/package.rb index 279f80f60..00cde4e6f 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -2,7 +2,7 @@ require 'rexml/document' class Package < ApplicationModel - @@root = Rails.root.to_s + @@root = Rails.root.to_s # rubocop:disable Style/ClassVars # build package based on .szpm # Package.build( @@ -437,7 +437,7 @@ class Package < ApplicationModel end class Migration < ApplicationModel - @@root = Rails.root.to_s + @@root = Rails.root.to_s # rubocop:disable Style/ClassVars def self.migrate( package, direction = 'normal' ) location = @@root + '/db/addon/' + package.underscore diff --git a/app/models/setting.rb b/app/models/setting.rb index 62b112c32..6f5b62e34 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -9,7 +9,7 @@ class Setting < ApplicationModel after_create :delete_cache after_update :delete_cache - @@current = {} + @@current = {} # rubocop:disable Style/ClassVars def self.load diff --git a/app/models/tag.rb b/app/models/tag.rb index 50ecceaec..0efb6a876 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -4,8 +4,10 @@ class Tag < ApplicationModel belongs_to :tag_object, class_name: 'Tag::Object' belongs_to :tag_item, class_name: 'Tag::Item' + # rubocop:disable Style/ClassVars @@cache_item = {} @@cache_object = {} + # rubocop:enable Style/ClassVars def self.tag_add(data) diff --git a/app/models/type_lookup.rb b/app/models/type_lookup.rb index 6b5f57d7c..d10394687 100644 --- a/app/models/type_lookup.rb +++ b/app/models/type_lookup.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class TypeLookup < ApplicationModel - @@cache_object = {} + @@cache_object = {} # rubocop:disable Style/ClassVars def self.by_id( id ) diff --git a/lib/sessions.rb b/lib/sessions.rb index 06b558eed..8d421e70c 100644 --- a/lib/sessions.rb +++ b/lib/sessions.rb @@ -13,7 +13,7 @@ module Sessions @path = "#{@root}/tmp/websocket" # create global vars for threads - @@client_threads = {} + @@client_threads = {} # rubocop:disable Style/ClassVars =begin diff --git a/lib/sessions/cache_in.rb b/lib/sessions/cache_in.rb index 3e4f0ae37..a70ba428f 100644 --- a/lib/sessions/cache_in.rb +++ b/lib/sessions/cache_in.rb @@ -1,8 +1,11 @@ module Sessions::CacheIn + + # rubocop:disable Style/ClassVars @@data = {} @@data_time = {} @@expires_in = {} @@expires_in_ttl = {} + # rubocop:enable Style/ClassVars def self.delete( key ) @@data.delete( key )