Browse Source

Maintenance: Updated rubocop(-* gems) to latest version (0.92.0).

Thorsten Eckel 4 years ago
parent
commit
623b17be6b

+ 14 - 0
.rubocop/default.yml

@@ -206,6 +206,13 @@ Rails/HasAndBelongsToMany:
 #  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
   Enabled: false
 
+Rails/MatchRoute:
+  Description: >-
+                  Don't use `match` to define any routes unless there is a need to map multiple request types
+                  among [:get, :post, :patch, :put, :delete] to a single action using the `:via` option.
+  StyleGuide: 'https://rails.rubystyle.guide/#no-match-routes'
+  Enabled: false
+
 Rails/SkipsModelValidations:
   Description: >-
                  Use methods that skips model validations with caution.
@@ -259,6 +266,13 @@ Lint/InterpolationCheck:
     - "test/unit/ticket_trigger_test.rb"
     - "test/unit/ticket_trigger_recursive_disabled_test.rb"
 
+Style/StringConcatenation:
+  Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
+  StyleGuide: '#string-interpolation'
+  Enabled: true
+  Exclude:
+    - "config/routes/**/*"
+
 # RSpec tests
 Style/NumericPredicate:
   Description: >-

+ 9 - 0
.rubocop/todo.rspec.yml

@@ -628,12 +628,16 @@ RSpec/NestedGroups:
     - 'spec/lib/signature_detection_spec.rb'
     - 'spec/lib/stats/ticket_waiting_time_spec.rb'
     - 'spec/lib/twitter_sync_spec.rb'
+    - 'spec/models/application_model/can_lookup_examples.rb'
     - 'spec/models/calendar_spec.rb'
     - 'spec/models/channel/driver/twitter_spec.rb'
     - 'spec/models/channel/email_parser_spec.rb'
     - 'spec/models/channel/filter/match/email_regex_spec.rb'
     - 'spec/models/channel/filter/out_of_office_check_spec.rb'
     - 'spec/models/concerns/has_collection_update_examples.rb'
+    - 'spec/models/concerns/has_groups_examples.rb'
+    - 'spec/models/concerns/has_history_examples.rb'
+    - 'spec/models/concerns/has_roles_examples.rb'
     - 'spec/models/concerns/has_ticket_create_screen_impact_examples.rb'
     - 'spec/models/cti/caller_id_spec.rb'
     - 'spec/models/cti/log_spec.rb'
@@ -737,3 +741,8 @@ RSpec/VerifiedDoubles:
     - 'spec/lib/sequencer/unit/import/zendesk/ticket/comment/source_based_spec.rb'
     - 'spec/models/observer/ticket/article/communicate_twitter/background_job_spec.rb'
     - 'spec/models/ticket/number_spec.rb'
+
+RSpec/MultipleMemoizedHelpers:
+  Description: Checks if example groups contain too many `let` and `subject` calls.
+  Enabled: false
+  StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleMemoizedHelpers

+ 68 - 0
.rubocop/todo.yml

@@ -44,10 +44,12 @@ Metrics/AbcSize:
     - 'app/controllers/integration/sipgate_controller.rb'
     - 'app/controllers/integration/smime_controller.rb'
     - 'app/controllers/knowledge_base/answers_controller.rb'
+    - 'app/controllers/knowledge_base/categories_controller.rb'
     - 'app/controllers/knowledge_base/manage_controller.rb'
     - 'app/controllers/knowledge_base/public/answers_controller.rb'
     - 'app/controllers/knowledge_base/public/categories_controller.rb'
     - 'app/controllers/knowledge_base/search_controller.rb'
+    - 'app/controllers/knowledge_bases_controller.rb'
     - 'app/controllers/links_controller.rb'
     - 'app/controllers/long_polling_controller.rb'
     - 'app/controllers/monitoring_controller.rb'
@@ -234,12 +236,14 @@ Metrics/AbcSize:
     - 'db/migrate/20170113000001_object_manager_attribute_create_middle.rb'
     - 'db/migrate/20170113000002_slack_group_config_issue_587.rb'
     - 'db/migrate/20170116000001_add_ticket_time_accounting_373.rb'
+    - 'db/migrate/20170116000002_fixed_typos_622.rb'
     - 'db/migrate/20170207081400_ticket_state_priority_defaults.rb'
     - 'db/migrate/20170403000001_fixed_admin_user_permission_920.rb'
     - 'db/migrate/20170419000001_ldap_support.rb'
     - 'db/migrate/20170419000002_overview_role_ids.rb'
     - 'db/migrate/20170516000001_trigger_recipient_update.rb'
     - 'db/migrate/20170608151442_enhanced_permissions.rb'
+    - 'db/migrate/20170713000002_ticket_zoom_setting2.rb'
     - 'db/migrate/20170905140038_cti_log_preferences_migration.rb'
     - 'db/migrate/20170910000002_out_of_office2.rb'
     - 'db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb'
@@ -266,6 +270,7 @@ Metrics/AbcSize:
     - 'lib/email_helper/verify.rb'
     - 'lib/enrichment/clearbit/user.rb'
     - 'lib/excel_sheet.rb'
+    - 'lib/excel_sheet/ticket.rb'
     - 'lib/external_credential/facebook.rb'
     - 'lib/external_credential/google.rb'
     - 'lib/external_credential/twitter.rb'
@@ -687,6 +692,7 @@ Metrics/PerceivedComplexity:
     - 'app/controllers/application_controller/handles_errors.rb'
     - 'app/controllers/application_controller/logs_http_access.rb'
     - 'app/controllers/channels_email_controller.rb'
+    - 'app/controllers/channels_google_controller.rb'
     - 'app/controllers/concerns/creates_ticket_articles.rb'
     - 'app/controllers/first_steps_controller.rb'
     - 'app/controllers/form_controller.rb'
@@ -694,17 +700,21 @@ Metrics/PerceivedComplexity:
     - 'app/controllers/import_otrs_controller.rb'
     - 'app/controllers/integration/check_mk_controller.rb'
     - 'app/controllers/integration/smime_controller.rb'
+    - 'app/controllers/knowledge_base/search_controller.rb'
     - 'app/controllers/long_polling_controller.rb'
     - 'app/controllers/monitoring_controller.rb'
     - 'app/controllers/object_manager_attributes_controller.rb'
     - 'app/controllers/organizations_controller.rb'
     - 'app/controllers/reports_controller.rb'
     - 'app/controllers/search_controller.rb'
+    - 'app/controllers/sessions/collection_base.rb'
+    - 'app/controllers/sessions/collection_ticket.rb'
     - 'app/controllers/sessions_controller.rb'
     - 'app/controllers/ticket_articles_controller.rb'
     - 'app/controllers/tickets_controller.rb'
     - 'app/controllers/time_accountings_controller.rb'
     - 'app/controllers/users_controller.rb'
+    - 'app/jobs/collection_update_job.rb'
     - 'app/jobs/ticket_article_communicate_email_job.rb'
     - 'app/models/activity_stream/assets.rb'
     - 'app/models/application_model/can_assets.rb'
@@ -719,6 +729,7 @@ Metrics/PerceivedComplexity:
     - 'app/models/calendar.rb'
     - 'app/models/channel.rb'
     - 'app/models/channel/assets.rb'
+    - 'app/models/channel/driver/facebook.rb'
     - 'app/models/channel/driver/imap.rb'
     - 'app/models/channel/driver/pop3.rb'
     - 'app/models/channel/driver/sms/twilio.rb'
@@ -741,6 +752,7 @@ Metrics/PerceivedComplexity:
     - 'app/models/concerns/can_clone_attachments.rb'
     - 'app/models/concerns/can_csv_import.rb'
     - 'app/models/concerns/has_history.rb'
+    - 'app/models/concerns/has_rich_text.rb'
     - 'app/models/concerns/has_search_index_backend.rb'
     - 'app/models/concerns/has_search_sortable.rb'
     - 'app/models/cti/caller_id.rb'
@@ -751,7 +763,9 @@ Metrics/PerceivedComplexity:
     - 'app/models/external_sync.rb'
     - 'app/models/history.rb'
     - 'app/models/job.rb'
+    - 'app/models/job/assets.rb'
     - 'app/models/karma/activity_log.rb'
+    - 'app/models/knowledge_base.rb'
     - 'app/models/object_manager/attribute.rb'
     - 'app/models/observer/sla/ticket_rebuild_escalation.rb'
     - 'app/models/observer/ticket/article/communicate_email.rb'
@@ -777,6 +791,7 @@ Metrics/PerceivedComplexity:
     - 'app/models/package.rb'
     - 'app/models/package/migration.rb'
     - 'app/models/recent_view/assets.rb'
+    - 'app/models/role.rb'
     - 'app/models/role/assets.rb'
     - 'app/models/scheduler.rb'
     - 'app/models/setting.rb'
@@ -798,6 +813,7 @@ Metrics/PerceivedComplexity:
     - 'app/models/transaction/signature_detection.rb'
     - 'app/models/transaction/slack.rb'
     - 'app/models/translation.rb'
+    - 'app/models/trigger/assets.rb'
     - 'app/models/user.rb'
     - 'app/models/user/assets.rb'
     - 'app/models/user/search.rb'
@@ -805,9 +821,15 @@ Metrics/PerceivedComplexity:
     - 'app/models/user_device.rb'
     - 'app/policies/ticket/article_policy.rb'
     - 'db/migrate/20170207081400_ticket_state_priority_defaults.rb'
+    - 'db/migrate/20170403000001_fixed_admin_user_permission_920.rb'
     - 'db/migrate/20170516000001_trigger_recipient_update.rb'
+    - 'db/migrate/20171023000001_fixed_store_upgrade_ror_45.rb'
+    - 'db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb'
+    - 'db/migrate/20180502015927_issue_1219_zhtw_locale_typo.rb'
     - 'db/migrate/20180806000001_fixed_twitter_ticket_article_preferences7.rb'
     - 'db/migrate/20181017000001_cti_generic_api2.rb'
+    - 'db/migrate/20190408000001_issue_2541_fix_notification_email_without_body.rb'
+    - 'db/migrate/20190724000001_rename_reserved_words.rb'
     - 'lib/auto_wizard.rb'
     - 'lib/core_ext/string.rb'
     - 'lib/email_helper/probe.rb'
@@ -821,6 +843,7 @@ Metrics/PerceivedComplexity:
     - 'lib/html_sanitizer.rb'
     - 'lib/import/exchange/item_attributes.rb'
     - 'lib/import/otrs/user.rb'
+    - 'lib/ldap/user.rb'
     - 'lib/models.rb'
     - 'lib/notification_factory/mailer.rb'
     - 'lib/notification_factory/renderer.rb'
@@ -834,12 +857,14 @@ Metrics/PerceivedComplexity:
     - 'lib/secure_mailing/smime/incoming.rb'
     - 'lib/service/geo_ip/zammad.rb'
     - 'lib/sessions.rb'
+    - 'lib/sessions/backend/activity_stream.rb'
     - 'lib/sessions/backend/ticket_overview_list.rb'
     - 'lib/sessions/client.rb'
     - 'lib/sessions/event/broadcast.rb'
     - 'lib/sessions/event/chat_session_close.rb'
     - 'lib/sessions/event/chat_session_update.rb'
     - 'lib/sessions/event/chat_status_customer.rb'
+    - 'lib/signature_detection.rb'
     - 'lib/stats.rb'
     - 'lib/stats/ticket_channel_distribution.rb'
     - 'lib/stats/ticket_in_process.rb'
@@ -851,7 +876,10 @@ Metrics/PerceivedComplexity:
     - 'lib/telegram.rb'
     - 'lib/twitter_sync.rb'
     - 'lib/user_agent.rb'
+    - 'test/browser/admin_object_manager_test.rb'
+    - 'test/browser/keyboard_shortcuts_test.rb'
     - 'test/browser_test_helper.rb'
+    - 'test/integration/slack_test.rb'
 
 Rails/AssertNot:
   Exclude:
@@ -873,3 +901,43 @@ Rails/HasManyOrHasOneDependent:
     - 'app/models/signature.rb'
     - 'app/models/ticket/state_type.rb'
     - 'app/models/user.rb'
+
+Style/OptionalBooleanParameter:
+  Exclude:
+    - 'app/models/application_model/can_activity_stream_log.rb'
+    - 'app/models/application_model/can_cleanup_param.rb'
+    - 'app/models/avatar.rb'
+    - 'app/models/channel.rb'
+    - 'app/models/channel/driver/facebook.rb'
+    - 'app/models/channel/driver/sendmail.rb'
+    - 'app/models/channel/driver/sms/massenversand.rb'
+    - 'app/models/channel/driver/sms/twilio.rb'
+    - 'app/models/channel/driver/smtp.rb'
+    - 'app/models/channel/driver/telegram.rb'
+    - 'app/models/channel/driver/twitter.rb'
+    - 'app/models/channel/email_build.rb'
+    - 'app/models/channel/email_parser.rb'
+    - 'app/models/chat/session.rb'
+    - 'app/models/concerns/has_history.rb'
+    - 'app/models/job.rb'
+    - 'app/models/karma/activity_log.rb'
+    - 'app/models/object_manager/attribute.rb'
+    - 'app/models/package.rb'
+    - 'app/models/scheduler.rb'
+    - 'app/models/setting.rb'
+    - 'app/models/store/file.rb'
+    - 'app/models/text_module.rb'
+    - 'app/models/ticket/escalation.rb'
+    - 'app/models/translation.rb'
+    - 'app/models/user.rb'
+    - 'lib/app_version.rb'
+    - 'lib/core_ext/string.rb'
+    - 'lib/external_credential/facebook.rb'
+    - 'lib/external_credential/google.rb'
+    - 'lib/external_credential/twitter.rb'
+    - 'lib/html_sanitizer.rb'
+    - 'lib/models.rb'
+    - 'lib/sessions/backend/ticket_overview_list.rb'
+    - 'lib/sessions/node.rb'
+    - 'spec/support/system_init_done.rb'
+    - 'test/browser_test_helper.rb'

+ 16 - 15
Gemfile.lock

@@ -150,7 +150,7 @@ GEM
       json
     composite_primary_keys (11.2.0)
       activerecord (~> 5.2.1)
-    concurrent-ruby (1.1.6)
+    concurrent-ruby (1.1.7)
     coveralls (0.8.23)
       json (>= 1.8, < 3)
       simplecov (~> 0.16.1)
@@ -248,7 +248,7 @@ GEM
     http-form_data (2.1.1)
     http_parser.rb (0.6.0)
     httpclient (2.8.3)
-    i18n (1.8.3)
+    i18n (1.8.5)
       concurrent-ruby (~> 1.0)
     icalendar (2.5.3)
       ice_cube (~> 0.16)
@@ -291,7 +291,7 @@ GEM
     mini_portile2 (2.4.0)
     mini_racer (0.2.9)
       libv8 (>= 6.9.411)
-    minitest (5.14.1)
+    minitest (5.14.2)
     msgpack (1.2.4)
     multi_json (1.14.1)
     multi_xml (0.6.0)
@@ -358,7 +358,7 @@ GEM
       omniauth-oauth2 (>= 1.4.0)
     openssl (2.1.2)
     parallel (1.19.2)
-    parser (2.7.1.4)
+    parser (2.7.1.5)
       ast (~> 2.4.1)
     pg (0.21.0)
     pluginator (1.5.0)
@@ -427,7 +427,7 @@ GEM
     rb-inotify (0.10.0)
       ffi (~> 1.0)
     rchardet (1.8.0)
-    regexp_parser (1.7.1)
+    regexp_parser (1.8.0)
     rest-client (2.0.2)
       http-cookie (>= 1.0.2, < 2.0)
       mime-types (>= 1.16, < 4.0)
@@ -452,25 +452,26 @@ GEM
       rspec-support (~> 3.9.0)
     rspec-support (3.9.3)
     rszr (0.5.2)
-    rubocop (0.88.0)
+    rubocop (0.92.0)
       parallel (~> 1.10)
-      parser (>= 2.7.1.1)
+      parser (>= 2.7.1.5)
       rainbow (>= 2.2.2, < 4.0)
       regexp_parser (>= 1.7)
       rexml
-      rubocop-ast (>= 0.1.0, < 1.0)
+      rubocop-ast (>= 0.5.0)
       ruby-progressbar (~> 1.7)
       unicode-display_width (>= 1.4.0, < 2.0)
-    rubocop-ast (0.1.0)
-      parser (>= 2.7.0.1)
-    rubocop-performance (1.7.0)
-      rubocop (>= 0.82.0)
-    rubocop-rails (2.6.0)
+    rubocop-ast (0.5.0)
+      parser (>= 2.7.1.5)
+    rubocop-performance (1.8.1)
+      rubocop (>= 0.87.0)
+      rubocop-ast (>= 0.4.0)
+    rubocop-rails (2.8.1)
       activesupport (>= 4.2.0)
       rack (>= 1.1)
-      rubocop (>= 0.82.0)
-    rubocop-rspec (1.42.0)
       rubocop (>= 0.87.0)
+    rubocop-rspec (1.43.2)
+      rubocop (~> 0.87)
     ruby-progressbar (1.10.1)
     ruby-saml (1.10.2)
       nokogiri (>= 1.5.10)

+ 1 - 1
app/controllers/application_controller/handles_errors.rb

@@ -62,7 +62,7 @@ module ApplicationController::HandlesErrors
         @message = errors[:error_human] || errors[:error] || param[:message]
         @traceback = !Rails.env.production?
         file = File.open(Rails.root.join('public', "#{status_code}.html"), 'r')
-        render inline: file.read, status: status
+        render inline: file.read, status: status # rubocop:disable Rails/RenderInline
       end
     end
   end

+ 1 - 1
app/controllers/application_controller/has_user.rb

@@ -84,7 +84,7 @@ module ApplicationController::HasUser
 
     # check if remote ip need to be updated
     if session[:user_id]
-      if !session[:remote_ip] || session[:remote_ip] != request.remote_ip
+      if !session[:remote_ip] || session[:remote_ip] != request.remote_ip # rubocop:disable Style/SoleNestedConditional
         session[:remote_ip] = request.remote_ip
         session[:geo]       = Service::GeoIp.location(request.remote_ip)
       end

+ 2 - 2
app/controllers/application_controller/logs_http_access.rb

@@ -33,7 +33,7 @@ module ApplicationController::LogsHttpAccess
     end
     body = request.body.read
     if body
-      request_data[:content] += "\n" + body
+      request_data[:content] += "\n#{body}"
     end
     request_data[:content] = request_data[:content].slice(0, 8000)
 
@@ -50,7 +50,7 @@ module ApplicationController::LogsHttpAccess
     end
     body = response.body
     if body
-      response_data[:content] += "\n" + body
+      response_data[:content] += "\n#{body}"
     end
     response_data[:content] = response_data[:content].slice(0, 8000)
     record = {

+ 1 - 3
app/controllers/channels_email_controller.rb

@@ -61,9 +61,7 @@ class ChannelsEmailController < ApplicationController
     )
 
     # verify if user+host already exists
-    if result[:result] == 'ok'
-      return if account_duplicate?(result)
-    end
+    return if result[:result] == 'ok' && account_duplicate?(result)
 
     render json: result
   end

+ 2 - 1
app/controllers/concerns/checks_user_attributes_by_current_user_permission.rb

@@ -10,9 +10,10 @@ module ChecksUserAttributesByCurrentUserPermission
     return true if current_user.permissions?('admin.user')
 
     # regular agents are not allowed to set Groups and Roles
+    suffixes = %w[_ids s]
     %w[Role Group].each do |model|
 
-      %w[_ids s].each do |suffix|
+      suffixes.each do |suffix|
         attribute = "#{model.downcase}#{suffix}"
         values    = params[attribute]
 

+ 4 - 2
app/controllers/concerns/creates_ticket_articles.rb

@@ -76,17 +76,19 @@ module CreatesTicketArticles
 
     # add attachments as param
     if params[:attachments].present?
+      required_keys    = %w[mime-type filename data]
+      preferences_keys = %w[charset mime-type]
       params[:attachments].each_with_index do |attachment, index|
 
         # validation
-        %w[mime-type filename data].each do |key|
+        required_keys.each do |key|
           next if attachment[key]
 
           raise Exceptions::UnprocessableEntity, "Attachment needs '#{key}' param for attachment with index '#{index}'"
         end
 
         preferences = {}
-        %w[charset mime-type].each do |key|
+        preferences_keys.each do |key|
           next if !attachment[key]
 
           store_key = key.tr('-', '_').camelize.gsub(/(.+)([A-Z])/, '\1_\2').tr('_', '-')

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