From f1e2a425ff837deffe29f3717ff58439b519d53b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 12:32:25 +0200 Subject: [PATCH 1/3] Corrected with rubocop cop 'Lint/Loop'. --- .rubocop.yml | 2 -- app/models/token.rb | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 92c0ca43f..438bcb4ad 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -277,5 +277,3 @@ Style/ModuleFunction: Enabled: false Style/AccessModifierIndentation: Enabled: false -Lint/Loop: - Enabled: false diff --git a/app/models/token.rb b/app/models/token.rb index 518dc66d3..084df589c 100644 --- a/app/models/token.rb +++ b/app/models/token.rb @@ -28,8 +28,11 @@ class Token < ActiveRecord::Base private def generate_token - begin + + loop do self.name = SecureRandom.hex(20) - end while Token.exists?( name: self.name ) + + break if !Token.exists?( name: self.name ) + end end end From b1d8fb1434642cb894b3538157ae1426484c7f09 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 12:34:31 +0200 Subject: [PATCH 2/3] Corrected with rubocop cop 'Style/AccessModifierIndentation'. --- .rubocop.yml | 2 -- app/models/application_model/search_index_base.rb | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 438bcb4ad..e3a0b7ace 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -275,5 +275,3 @@ Style/MethodName: Enabled: false Style/ModuleFunction: Enabled: false -Style/AccessModifierIndentation: - Enabled: false diff --git a/app/models/application_model/search_index_base.rb b/app/models/application_model/search_index_base.rb index be0b22ac6..41a253f19 100644 --- a/app/models/application_model/search_index_base.rb +++ b/app/models/application_model/search_index_base.rb @@ -81,7 +81,7 @@ returns attributes end - private + private =begin From abe329591e31984f1dfe911a589aace9b940f131 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 5 May 2015 12:51:19 +0200 Subject: [PATCH 3/3] Corrected with rubocop cop 'Style/MethodName'. --- .rubocop.yml | 2 -- app/controllers/object_manager_attributes_controller.rb | 2 +- app/models/object_manager.rb | 8 ++++---- lib/session_helper.rb | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e3a0b7ace..4914ebed6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -271,7 +271,5 @@ Lint/Eval: Enabled: false Rails/HasAndBelongsToMany: Enabled: false -Style/MethodName: - Enabled: false Style/ModuleFunction: Enabled: false diff --git a/app/controllers/object_manager_attributes_controller.rb b/app/controllers/object_manager_attributes_controller.rb index 60a372b64..7e61985c5 100644 --- a/app/controllers/object_manager_attributes_controller.rb +++ b/app/controllers/object_manager_attributes_controller.rb @@ -7,7 +7,7 @@ class ObjectManagerAttributesController < ApplicationController def list return if deny_if_not_role(Z_ROLENAME_ADMIN) render json: { - objects: ObjectManager.listFrontendObjects, + objects: ObjectManager.list_frontend_objects, } #model_index_render(ObjectManager::Attribute, params) end diff --git a/app/models/object_manager.rb b/app/models/object_manager.rb index 187343c15..5fcfc773c 100644 --- a/app/models/object_manager.rb +++ b/app/models/object_manager.rb @@ -6,11 +6,11 @@ class ObjectManager list all backend managed object - ObjectManager.listObjects() + ObjectManager.list_objects() =end - def self.listObjects + def self.list_objects ['Ticket', 'TicketArticle', 'User', 'Organization', 'Group' ] end @@ -18,11 +18,11 @@ list all backend managed object list all frontend managed object - ObjectManager.listFrontendObjects() + ObjectManager.list_frontend_objects() =end - def self.listFrontendObjects + def self.list_frontend_objects ['Ticket', 'User', 'Organization' ] #, 'Group' ] end diff --git a/lib/session_helper.rb b/lib/session_helper.rb index 6df31f078..c02c794f2 100644 --- a/lib/session_helper.rb +++ b/lib/session_helper.rb @@ -18,7 +18,7 @@ module SessionHelper def self.models(user = nil) models = {} - objects = ObjectManager.listObjects + objects = ObjectManager.list_objects objects.each {|object| attributes = ObjectManager::Attribute.by_object(object, user) models[object] = attributes