diff --git a/.rubocop.yml b/.rubocop.yml index 7c544b31b..c78567413 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,16 @@ -AllCops: - RunRailsCops: true - -# Default enabled +# 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: + - 'bin/rails' + - 'bin/rake' + - 'bin/spring' + - 'db/schema.rb' Metrics/LineLength: Description: 'Limit lines to 80 characters.' @@ -131,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 @@ -141,10 +144,7 @@ Rails/FindEach: Enabled: false - - - - +# TODO Style/Documentation: Description: 'Document classes and non-namespace modules.' @@ -202,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 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/app/models/scheduler.rb b/app/models/scheduler.rb index e2859dcc0..4802a7241 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 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 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') 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 diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 7244b049c..c66024eb8 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -77,8 +77,8 @@ 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" - log('screenshot', {filename: filename}) + 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 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... 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