Browse Source

Updated to latest rubocop version.

Thorsten Eckel 7 years ago
parent
commit
fbeccbc85c

+ 38 - 65
.rubocop.yml

@@ -1,7 +1,10 @@
 # Default enabled cops
 # https://github.com/bbatsov/rubocop/blob/master/config/enabled.yml
 
+inherit_from: .rubocop_todo.yml
+
 AllCops:
+  DisplayCopNames: true
   Exclude:
     - 'bin/rails'
     - 'bin/rake'
@@ -35,9 +38,13 @@ Style/IfUnlessModifier:
   StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
   Enabled: false
 
-Style/TrailingCommaInLiteral:
-  Description: 'Checks for trailing comma in array and hash literals.'
-  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
+Style/TrailingCommaInArrayLiteral:
+  Description: 'Checks for trailing comma in array literals.'
+  StyleGuide: '#no-trailing-array-commas'
+  Enabled: false
+
+Style/TrailingCommaInHashLiteral:
+  Description: 'Checks for trailing comma in hash literals.'
   Enabled: false
 
 Style/TrailingCommaInArguments:
@@ -67,9 +74,12 @@ Style/MethodCallWithoutArgsParentheses:
   StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
   Enabled: false
 
-Layout/SpaceInsideBrackets:
-  Description: 'No spaces after [ or before ].'
-  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces'
+Layout/SpaceInsideReferenceBrackets:
+  Description: 'Checks the spacing inside referential brackets.'
+  Enabled: false
+
+Layout/SpaceInsideArrayLiteralBrackets:
+  Description: 'Checks the spacing inside array literal brackets.'
   Enabled: false
 
 Style/DefWithParentheses:
@@ -167,68 +177,31 @@ Naming/VariableNumber:
   Description: 'Use the configured style when numbering variables.'
   Enabled: false
 
-# 2.0
-
-Metrics/PerceivedComplexity:
-  Description: >-
-                 A complexity metric geared towards measuring complexity for a
-                 human reader.
-  Enabled: false
-
-Metrics/AbcSize:
+Naming/UncommunicativeMethodParamName:
   Description: >-
-                 A calculated magnitude based on number of assignments,
-                 branches, and conditions.
-  Enabled: false
-
-Metrics/CyclomaticComplexity:
-  Description: >-
-                 A complexity metric that is strongly correlated to the number
-                 of test cases needed to validate a method.
-  Enabled: false
-
-Metrics/BlockNesting:
-  Description: 'Avoid excessive block nesting'
-  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
-  Enabled: false
-
-Metrics/ModuleLength:
-  Description: 'Avoid modules longer than 100 lines of code.'
-  Enabled: false
-
-Metrics/BlockLength:
-  Enabled: false
-
-Lint/RescueWithoutErrorClass:
-  Enabled: false
-
-Rails/ApplicationRecord:
-  Enabled: false
-
-# TODO
-
-Rails/HasManyOrHasOneDependent:
-  Enabled: false
-
-Style/DateTime:
-  Enabled: false
-
-Style/Documentation:
-  Description: 'Document classes and non-namespace modules.'
-  Enabled: false
-
-Lint/UselessAssignment:
-  Enabled: false
+                Checks for method parameter names that contain capital letters,
+                end in numbers, or do not meet a minimal length.
+  Enabled: true
+  AllowedNames: e, id, _, ip
 
-Layout/ExtraSpacing:
-  Description: 'Do not use unnecessary spacing.'
-  Enabled: false
+Lint/BooleanSymbol:
+  Description: 'Check for `:true` and `:false` symbols.'
+  Enabled: true
+  Exclude:
+    - "db/seeds/object_manager_attributes.rb"
+    - "test/integration/object_manager_attributes_controller_test.rb"
+    - "test/integration/object_manager_test.rb"
 
-# Broken!!!! Generates broken code since "String".downcase == "strinG".downcase is not equals "String".casecmp("strinG") but "String".casecmp("strinG") == 0 !!!
-Performance/Casecmp:
-  Description: 'Use `casecmp` rather than `downcase ==`.'
-  Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
-  Enabled: false
+Lint/InterpolationCheck:
+  Description: 'Raise warning for interpolation in single q strs'
+  Enabled: true
+  Exclude:
+    - "test/unit/email_process_auto_response_test.rb"
+    - "test/unit/email_process_bounce_delivery_permanent_failed_test.rb"
+    - "test/unit/email_process_bounce_follow_test.rb"
+    - "test/unit/notification_factory_renderer_test.rb"
+    - "test/unit/notification_factory_template_test.rb"
+    - "test/unit/ticket_trigger_test.rb"
 
 # RSpec tests
 Style/NumericPredicate:

+ 80 - 0
.rubocop_todo.yml

@@ -0,0 +1,80 @@
+# 10.0
+
+Metrics/PerceivedComplexity:
+  Description: >-
+                 A complexity metric geared towards measuring complexity for a
+                 human reader.
+  Enabled: false
+
+Metrics/AbcSize:
+  Description: >-
+                 A calculated magnitude based on number of assignments,
+                 branches, and conditions.
+  Enabled: false
+
+Metrics/CyclomaticComplexity:
+  Description: >-
+                 A complexity metric that is strongly correlated to the number
+                 of test cases needed to validate a method.
+  Enabled: false
+
+Metrics/BlockNesting:
+  Description: 'Avoid excessive block nesting'
+  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
+  Enabled: false
+
+Metrics/ModuleLength:
+  Description: 'Avoid modules longer than 100 lines of code.'
+  Enabled: false
+
+Metrics/BlockLength:
+  Enabled: false
+
+Style/RescueStandardError:
+  Description: 'Avoid rescuing without specifying an error class.'
+  Enabled: false
+
+# TODO
+
+Rails/ApplicationRecord:
+  Description: 'Check that models subclass ApplicationRecord.'
+  Enabled: false
+
+Rails/CreateTableWithTimestamps:
+  Description: >-
+                  Checks the migration for which timestamps are not included
+                  when creating a new table.
+  Enabled: false
+
+Rails/HasManyOrHasOneDependent:
+  Description: 'Define the dependent option to the has_many and has_one associations.'
+  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has_many-has_one-dependent-option'
+  Enabled: false
+
+Style/DateTime:
+  Description: 'Use Date or Time over DateTime.'
+  StyleGuide: '#date--time'
+  Enabled: false
+
+Style/Documentation:
+  Description: 'Document classes and non-namespace modules.'
+  Enabled: false
+
+Lint/UselessAssignment:
+  Enabled: false
+
+Layout/ExtraSpacing:
+  Description: 'Do not use unnecessary spacing.'
+  Enabled: false
+
+# Broken!!!! Generates broken code since "String".downcase == "strinG".downcase is not equals "String".casecmp("strinG") but "String".casecmp("strinG") == 0 !!!
+Performance/Casecmp:
+  Description: 'Use `casecmp` rather than `downcase ==`.'
+  Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringcasecmp-vs-stringdowncase---code'
+  Enabled: false
+
+# Can be removed after introduction of Sequencer for OTRS migration
+Lint/MissingCopEnableDirective:
+  Enabled: true
+  Exclude:
+    - "lib/import/**/*"

+ 8 - 9
Gemfile.lock

@@ -68,7 +68,7 @@ GEM
     argon2 (1.1.4)
       ffi (~> 1.9)
       ffi-compiler (~> 0.1)
-    ast (2.3.0)
+    ast (2.4.0)
     autoprefixer-rails (7.1.6)
       execjs
     biz (1.7.0)
@@ -284,9 +284,9 @@ GEM
     omniauth-weibo-oauth2 (0.4.5)
       omniauth (~> 1.5)
       omniauth-oauth2 (>= 1.4.0)
-    parallel (1.12.0)
-    parser (2.4.0.2)
-      ast (~> 2.3)
+    parallel (1.12.1)
+    parser (2.5.0.5)
+      ast (~> 2.4.0)
     pg (0.21.0)
     pluginator (1.5.0)
     power_assert (1.1.1)
@@ -328,8 +328,7 @@ GEM
       method_source
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
-    rainbow (2.2.2)
-      rake
+    rainbow (3.0.0)
     raindrops (0.19.0)
     rake (12.3.1)
     rb-fsevent (0.10.2)
@@ -358,11 +357,11 @@ GEM
       rspec-mocks (~> 3.7.0)
       rspec-support (~> 3.7.0)
     rspec-support (3.7.0)
-    rubocop (0.51.0)
+    rubocop (0.54.0)
       parallel (~> 1.10)
-      parser (>= 2.3.3.1, < 3.0)
+      parser (>= 2.5)
       powerpack (~> 0.1)
-      rainbow (>= 2.2.2, < 3.0)
+      rainbow (>= 2.2.2, < 4.0)
       ruby-progressbar (~> 1.7)
       unicode-display_width (~> 1.0, >= 1.0.1)
     ruby-progressbar (1.9.0)

+ 1 - 1
Rakefile

@@ -2,6 +2,6 @@
 # Add your own tasks in files placed in lib/tasks ending in .rake,
 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
-require File.expand_path('../config/application', __FILE__)
+require File.expand_path('config/application', __dir__)
 
 Zammad::Application.load_tasks

+ 0 - 1
app/controllers/external_credentials_controller.rb

@@ -26,7 +26,6 @@ class ExternalCredentialsController < ApplicationController
   def app_verify
     attributes = ExternalCredential.app_verify(params)
     render json: { attributes: attributes }, status: :ok
-    return
   rescue => e
     render json: { error: e.message }, status: :ok
   end

+ 9 - 1
app/models/activity_stream.rb

@@ -5,8 +5,16 @@ class ActivityStream < ApplicationModel
   include ActivityStream::Assets
 
   self.table_name = 'activity_streams'
+
+  # rubocop:disable Rails/InverseOf
   belongs_to :object, class_name: 'ObjectLookup', foreign_key: 'activity_stream_object_id'
-  belongs_to :type,   class_name: 'TypeLookup', foreign_key: 'activity_stream_type_id'
+  belongs_to :type,   class_name: 'TypeLookup',   foreign_key: 'activity_stream_type_id'
+  # rubocop:enable Rails/InverseOf
+
+  # the noop is needed since Layout/EmptyLines detects
+  # the block commend below wrongly as the measurement of
+  # the wanted indentation of the rubocop re-enabling above
+  def noop; end
 
 =begin
 

+ 2 - 2
app/models/application_model/has_cache.rb

@@ -11,9 +11,9 @@ module ApplicationModel::HasCache
     after_destroy :cache_delete
   end
 
-  def cache_update(o)
+  def cache_update(other)
     cache_delete if respond_to?('cache_delete')
-    o.cache_delete if o.respond_to?('cache_delete')
+    other.cache_delete if other.respond_to?('cache_delete')
     true
   end
 

+ 1 - 1
app/models/avatar.rb

@@ -1,7 +1,7 @@
 # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
 
 class Avatar < ApplicationModel
-  belongs_to :object_lookup,   class_name: 'ObjectLookup'
+  belongs_to :object_lookup
 
 =begin
 

+ 1 - 1
app/models/channel.rb

@@ -4,7 +4,7 @@ class Channel < ApplicationModel
   load 'channel/assets.rb'
   include Channel::Assets
 
-  belongs_to :group,  class_name: 'Group'
+  belongs_to :group
 
   store :options
   store :preferences

+ 5 - 2
app/models/chat/session.rb

@@ -8,10 +8,13 @@ class Chat::Session < ApplicationModel
   load 'chat/session/assets.rb'
   include Chat::Session::Assets
 
-  has_many :messages,  class_name: 'Chat::Message', foreign_key: 'chat_session_id'
+  # rubocop:disable Rails/InverseOf
+  has_many :messages, class_name: 'Chat::Message', foreign_key: 'chat_session_id'
+  # rubocop:enable Rails/InverseOf
 
   before_create :generate_session_id
-  store         :preferences
+
+  store :preferences
 
   def generate_session_id
     self.session_id = Digest::MD5.hexdigest(Time.zone.now.to_s + rand(99_999_999_999_999).to_s)

Some files were not shown because too many files changed in this diff