From 562c842c8ae1ad7560433af1e8c4f7108e8bfb58 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Tue, 14 Apr 2020 10:14:14 +0200 Subject: [PATCH] Updated rubocop(-* gems) to latest version (0.81.0). --- .rubocop.yml | 11 +++++++++++ Gemfile.lock | 11 ++++++----- app/models/channel/email_parser.rb | 2 +- db/migrate/20120101000001_create_base.rb | 2 +- lib/import/exchange/folder.rb | 4 +--- test/browser_test_helper.rb | 14 +++++++------- 6 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8f11d4415..5ad97b3e8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -18,7 +18,9 @@ AllCops: - 'bin/spring' - 'db/schema.rb' - 'vendor/**/*' + - 'node_modules/**/*' - 'public/assets/**/*' + - 'public/packs/**/*' RSpec: Patterns: - '_spec.rb$' @@ -242,6 +244,15 @@ Lint/InterpolationCheck: - "test/unit/ticket_trigger_test.rb" - "test/unit/ticket_trigger_recursive_disabled_test.rb" +Lint/RaiseException: + Description: Checks for `raise` or `fail` statements which are raising `Exception` class. + StyleGuide: "#raise-exception" + Enabled: true + +Lint/StructNewOverride: + Description: "Disallow overriding the `Struct` built-in methods via `Struct.new`." + Enabled: true + # RSpec tests Style/NumericPredicate: Description: >- diff --git a/Gemfile.lock b/Gemfile.lock index 5d9dc0c9d..e66d603b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -355,7 +355,7 @@ GEM omniauth (~> 1.5) omniauth-oauth2 (>= 1.4.0) parallel (1.19.1) - parser (2.7.0.2) + parser (2.7.1.0) ast (~> 2.4.0) pg (0.21.0) pluginator (1.5.0) @@ -449,17 +449,18 @@ GEM rspec-support (~> 3.8.0) rspec-support (3.8.0) rszr (0.5.2) - rubocop (0.80.0) + rubocop (0.81.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) rubocop-performance (1.5.2) rubocop (>= 0.71.0) - rubocop-rails (2.4.2) + rubocop-rails (2.5.2) + activesupport rack (>= 1.1) rubocop (>= 0.72.0) rubocop-rspec (1.38.1) @@ -532,7 +533,7 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.5) - unicode-display_width (1.6.1) + unicode-display_width (1.7.0) unicorn (5.5.0) kgio (~> 2.6) raindrops (~> 0.7) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 68a5e4e67..aba9ded3d 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -517,7 +517,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again end.to_h # imported_fields = mail.header.fields.map { |f| [f.name.downcase, f.to_utf8] }.to_h - raw_fields = mail.header.fields.map { |f| ["raw-#{f.name.downcase}", f] }.to_h + raw_fields = mail.header.fields.index_by { |f| "raw-#{f.name.downcase}" } custom_fields = {}.tap do |h| h.replace(imported_fields.slice(*RECIPIENT_FIELDS) .transform_values { |v| v.match?(EMAIL_REGEX) ? v : '' }) diff --git a/db/migrate/20120101000001_create_base.rb b/db/migrate/20120101000001_create_base.rb index 38c09be6f..ed28a8cd5 100644 --- a/db/migrate/20120101000001_create_base.rb +++ b/db/migrate/20120101000001_create_base.rb @@ -207,7 +207,7 @@ class CreateBase < ActiveRecord::Migration[4.2] t.references :user, null: false t.timestamps limit: 3, null: false end - add_index :authorizations, %i[uid provider] + add_index :authorizations, %i[uid provider], unique: true add_index :authorizations, [:user_id] add_index :authorizations, [:username] add_foreign_key :authorizations, :users diff --git a/lib/import/exchange/folder.rb b/lib/import/exchange/folder.rb index 186a40335..505a52d1b 100644 --- a/lib/import/exchange/folder.rb +++ b/lib/import/exchange/folder.rb @@ -13,9 +13,7 @@ module Import end def id_folder_map - @id_folder_map ||= all.collect do |folder| - [folder.id, folder] - end.to_h + @id_folder_map ||= all.index_by(&:id) # duplicate object to avoid errors where keys get # added via #get_folder while iterating over diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index aa285294a..22a731d9b 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -1,5 +1,5 @@ ENV['RAILS_ENV'] = 'test' -# rubocop:disable Lint/SuppressedException, Lint/NonLocalExitFromIterator, Style/GuardClause, Lint/MissingCopEnableDirective +# rubocop:disable Lint/NonLocalExitFromIterator, Style/GuardClause, Lint/MissingCopEnableDirective require File.expand_path('../config/environment', __dir__) require 'selenium-webdriver' require 'json' @@ -1475,7 +1475,7 @@ set type of task (closeTab, closeNextInOverview, stayOnTab) return true end end - rescue # rubocop:disable Lint/SuppressedException + rescue # try again end end @@ -1537,7 +1537,7 @@ wait untill text in selector disabppears sleep 1 return true end - rescue # rubocop:disable Lint/SuppressedException + rescue # try again end end @@ -1700,7 +1700,7 @@ wait untill text in selector disabppears else break end - rescue # rubocop:disable Lint/SuppressedException + rescue # try again end end @@ -2542,7 +2542,7 @@ wait untill text in selector disabppears if text.match?(/(Discard your unsaved changes.|Verwerfen der)/) found = true end - rescue # rubocop:disable Lint/SuppressedException + rescue # try again end sleep 1 @@ -2580,7 +2580,7 @@ wait untill text in selector disabppears sleep 1 return true end - rescue # rubocop:disable Lint/SuppressedException + rescue # try again end sleep 1 @@ -4485,7 +4485,7 @@ wait untill text in selector disabppears puts "#{time}/#{log.level}: #{log.message}" end end - rescue # rubocop:disable Lint/SuppressedException + rescue # failed to get logs end return if !DEBUG