From 77a6b7419d36151f8feee32ea625ae1013bb9744 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:07:32 +0200 Subject: [PATCH 01/10] Corrected with rubocop cop 'Style/AlignParameters'. --- config/initializers/omniauth.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index e14de3c8a..94c16be9a 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -2,7 +2,7 @@ Rails.application.config.middleware.use OmniAuth::Builder do # twitter database connect provider :twitter_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse', - client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' } + client_options: { authorize_path: '/oauth/authorize', site: 'https://api.twitter.com' } # facebook database connect provider :facebook_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse' @@ -12,6 +12,6 @@ Rails.application.config.middleware.use OmniAuth::Builder do # google database connect provider :google_oauth2_database, 'not_change_will_be_set_by_databse', 'not_change_will_be_set_by_databse', - authorize_options: { access_type: 'online', approval_prompt: '' } + authorize_options: { access_type: 'online', approval_prompt: '' } end From 240a991fd9a05149d826fb0936a13f8112a4db05 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:09:43 +0200 Subject: [PATCH 02/10] Added global excludes. --- .rubocop.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 7c544b31b..f29b8d015 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,10 @@ AllCops: RunRailsCops: true + Exclude: + - 'bin/rails' + - 'bin/rake' + - 'bin/spring' + - 'db/schema.rb' # Default enabled # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml From cfd863a07f98c5a44c9a7a14e6c96b3a22897d9d Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:17:36 +0200 Subject: [PATCH 03/10] Corrected with rubocop cop 'Style/SpaceInsideHashLiteralBraces'. --- test/browser_test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 7244b049c..4dd3f9a34 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -78,7 +78,7 @@ class TestCase < Test::Unit::TestCase instance = params[:browser] || @browser comment = params[:comment] || '' filename = "tmp/#{Time.zone.now.strftime("screenshot_%Y_%m_%d__%H_%M_%S")}_#{comment}_#{instance.hash}.png" - log('screenshot', {filename: filename}) + log('screenshot', { filename: filename }) instance.save_screenshot(filename) end From 09c3d244f086b87d3eeeb99528d846f50e1ace22 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:19:35 +0200 Subject: [PATCH 04/10] Corrected with rubocop cop 'Style/GuardClause'. --- test/test_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index cc205b0a0..5bd0c6865 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -45,12 +45,12 @@ class ActiveSupport::TestCase puts 'teardown' # check if jobs are proccessed - if !Delayed::Job.all.empty? - Delayed::Job.where('failed_at != NULL').each {|job| - assert( false, "not processable job #{jobs.inspect}" ) - } - Delayed::Job.all.destroy_all - end + return if Delayed::Job.all.empty? + + Delayed::Job.where('failed_at != NULL').each {|job| + assert( false, "not processable job #{jobs.inspect}" ) + } + Delayed::Job.all.destroy_all end # Add more helper methods to be used by all tests here... From 459a45e46c16cdfbae1066fa4a181fa5ae34687a Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:21:13 +0200 Subject: [PATCH 05/10] Corrected with rubocop cop 'Lint/DefEndAlignment'. --- lib/import/otrs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/import/otrs.rb b/lib/import/otrs.rb index f28fc0e3b..747bca250 100644 --- a/lib/import/otrs.rb +++ b/lib/import/otrs.rb @@ -167,7 +167,7 @@ module Import::OTRS threads[thread].join } - end + end def self.diff_worker return if !Setting.get('import_mode') From 4b4c7386a27e90c208f207b47221bb6cd5c009f2 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:23:33 +0200 Subject: [PATCH 06/10] Corrected with rubocop cop 'Style/StringLiteralsInInterpolation'. --- test/browser_test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 4dd3f9a34..c66024eb8 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -77,7 +77,7 @@ class TestCase < Test::Unit::TestCase def screenshot(params) instance = params[:browser] || @browser comment = params[:comment] || '' - filename = "tmp/#{Time.zone.now.strftime("screenshot_%Y_%m_%d__%H_%M_%S")}_#{comment}_#{instance.hash}.png" + filename = "tmp/#{Time.zone.now.strftime('screenshot_%Y_%m_%d__%H_%M_%S')}_#{comment}_#{instance.hash}.png" log('screenshot', { filename: filename }) instance.save_screenshot(filename) end From bae19fd9d75078ba7982840353a304429510862b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:28:42 +0200 Subject: [PATCH 07/10] Corrected with rubocop cop 'Style/AccessorMethodName'. --- app/controllers/import_otrs_controller.rb | 2 +- lib/import/otrs2.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/import_otrs_controller.rb b/app/controllers/import_otrs_controller.rb index fdb3d99c5..d55cc57a8 100644 --- a/app/controllers/import_otrs_controller.rb +++ b/app/controllers/import_otrs_controller.rb @@ -93,7 +93,7 @@ class ImportOtrsController < ApplicationController def import_status return if setup_done_response - state = Import::OTRS2.get_current_state + state = Import::OTRS2.current_state render json: { data: state, diff --git a/lib/import/otrs2.rb b/lib/import/otrs2.rb index bd7056f69..8aff3c442 100644 --- a/lib/import/otrs2.rb +++ b/lib/import/otrs2.rb @@ -212,9 +212,9 @@ module Import::OTRS2 =begin - get object statisitic from server ans save it in cache + get object statistic from server ans save it in cache - result = get_statisitic('Subaction=List') + result = statistic('Subaction=List') return @@ -226,7 +226,7 @@ module Import::OTRS2 =end - def self.get_statisitic + def self.statistic # check cache cache = Cache.get('import_otrs_stats') @@ -246,7 +246,7 @@ module Import::OTRS2 return current import state - result = get_current_state + result = current_state return @@ -263,8 +263,8 @@ module Import::OTRS2 =end - def self.get_current_state - data = self.get_statisitic + def self.current_state + data = self.statistic base = Group.count + Ticket::State.count + Ticket::Priority.count base_total = data['Queue'] + data['State'] + data['Priority'] user = User.count From 487a5064236880c110d2465a906fe7706b296749 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:37:53 +0200 Subject: [PATCH 08/10] Corrected with rubocop cop 'Style/FormatString'. --- app/models/scheduler.rb | 2 +- app/models/ticket/number/date.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/scheduler.rb b/app/models/scheduler.rb index beee83d29..61eac2ddb 100644 --- a/app/models/scheduler.rb +++ b/app/models/scheduler.rb @@ -116,7 +116,7 @@ class Scheduler < ApplicationModel sleep(wait) logger.info '*** worker loop' else - printf "*** #{count} jobs processed at %.4f j/s, %d failed ...\n" % [count / realtime, result.last] + format "*** #{count} jobs processed at %.4f j/s, %d failed ...\n", count / realtime, result.last end end end diff --git a/app/models/ticket/number/date.rb b/app/models/ticket/number/date.rb index ea5c1e8b0..da9ef2fc2 100644 --- a/app/models/ticket/number/date.rb +++ b/app/models/ticket/number/date.rb @@ -33,7 +33,7 @@ module Ticket::Number::Date end system_id = Setting.get('system_id') || '' - number = t.strftime('%Y%m%d') + system_id.to_s + sprintf( '%04d', counter_increment) + number = t.strftime('%Y%m%d') + system_id.to_s + format('%04d', counter_increment) # calculate a checksum # The algorithm to calculate the checksum is derived from the one From 4f6b7c1860ddc0beb0012a53ec85de593e5b232e Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:42:00 +0200 Subject: [PATCH 09/10] Corrected with rubocop cop 'Style/TrailingWhitespace'. --- vendor/lib/twitter_database.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/lib/twitter_database.rb b/vendor/lib/twitter_database.rb index 4f58ed12e..4ae2900e4 100644 --- a/vendor/lib/twitter_database.rb +++ b/vendor/lib/twitter_database.rb @@ -6,8 +6,8 @@ class TwitterDatabase < OmniAuth::Strategies::Twitter # database lookup # puts 'TwitterDatabase -> initialize' config = Setting.get('auth_twitter_credentials') || {} - args[0] = config['key'] - args[1] = config['secret'] + args[0] = config['key'] + args[1] = config['secret'] super end From 4e7037f820179823c9520d3f026a300e4fc80f02 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 4 May 2015 16:59:38 +0200 Subject: [PATCH 10/10] - Changed rubocop file layout. - Added ToDo cops. --- .rubocop.yml | 104 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 12 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f29b8d015..c78567413 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,9 @@ +# Default enabled cops +# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml + +# TODO: +# https://github.com/bbatsov/rubocop#includingexcluding-files + AllCops: RunRailsCops: true Exclude: @@ -6,13 +12,6 @@ AllCops: - 'bin/spring' - 'db/schema.rb' -# Default enabled -# https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml - -# TODO: -# https://github.com/bbatsov/rubocop#includingexcluding-files - - Metrics/LineLength: Description: 'Limit lines to 80 characters.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits' @@ -136,7 +135,6 @@ Style/SelfAssignment: StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment' Enabled: false -# [Corrected] Redundant curly braces around a hash parameter. Style/BracesAroundHashParameters: Description: 'Enforce braces style around hash parameters.' Enabled: false @@ -146,10 +144,7 @@ Rails/FindEach: Enabled: false - - - - +# TODO Style/Documentation: Description: 'Document classes and non-namespace modules.' @@ -207,3 +202,88 @@ Metrics/AbcSize: A calculated magnitude based on number of assignments, branches, and conditions. Enabled: false + +Style/RedundantSelf: + Enabled: false +Style/Next: + Enabled: false +Rails/Output: + Enabled: false +Lint/UselessAccessModifier: + Enabled: false +Style/CommentIndentation: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Lint/StringConversionInInterpolation: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Style/FileName: + Enabled: false +Style/GlobalVars: + Enabled: false +Rails/TimeZone: + Enabled: false +Rails/TimeZone: + Enabled: false +Metrics/BlockNesting: + Enabled: false +Lint/RescueException: + Enabled: false +Style/EachWithObject: + Enabled: false +Style/PredicateName: + Enabled: false +Style/ClassVars: + Enabled: false +Lint/LiteralInCondition: + Enabled: false +Style/PredicateName: + Enabled: false +Style/SpaceBeforeComment: + Enabled: false +Lint/UselessAssignment: + Enabled: false +Lint/NonLocalExitFromIterator: + Enabled: false +Style/ColonMethodCall: + Enabled: false +Rails/Date: + Enabled: false +Style/VariableName: + Enabled: false +Lint/UnreachableCode: + Enabled: false +Lint/ShadowingOuterLocalVariable: + Enabled: false +Style/InfiniteLoop: + Enabled: false +Lint/AmbiguousRegexpLiteral: + Enabled: false +Rails/Validation: + Enabled: false +Style/MultilineOperationIndentation: + Enabled: false +Style/OneLineConditional: + Enabled: false +Style/ClassMethods: + Enabled: false +Lint/Eval: + Enabled: false +Rails/HasAndBelongsToMany: + Enabled: false +Style/MethodName: + Enabled: false +Style/ModuleFunction: + Enabled: false +Style/AccessModifierIndentation: + Enabled: false +Lint/Loop: + Enabled: false +Style/For: + Enabled: false +Style/WhileUntilDo: + Enabled: false