Updated rubocop to latest version (0.74).

This commit is contained in:
Thorsten Eckel 2019-09-02 13:52:11 +02:00
parent 366a0b32e3
commit 40dcb0e132
19 changed files with 47 additions and 31 deletions

View file

@ -3,6 +3,7 @@
require: require:
- rubocop-performance - rubocop-performance
- rubocop-rails
- rubocop-rspec - rubocop-rspec
inherit_from: inherit_from:
@ -17,6 +18,7 @@ AllCops:
- 'bin/spring' - 'bin/spring'
- 'db/schema.rb' - 'db/schema.rb'
- 'vendor/**/*' - 'vendor/**/*'
- 'public/assets/**/*'
RSpec: RSpec:
Patterns: Patterns:
- '_spec.rb$' - '_spec.rb$'

View file

@ -1,12 +1,12 @@
# This configuration was generated by # This configuration was generated by
# `rubocop --auto-gen-config` # `rubocop --auto-gen-config`
# on 2019-04-12 18:08:21 +0800 using RuboCop version 0.67.2. # on 2019-09-02 13:20:31 +0200 using RuboCop version 0.74.0.
# The point is for the user to remove these configuration records # The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base. # one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new # Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again. # versions of RuboCop, may require this file to be generated again.
# Offense count: 97 # Offense count: 163
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing: Layout/ExtraSpacing:
@ -25,25 +25,25 @@ Lint/MissingCopEnableDirective:
- 'lib/import/otrs/user_factory.rb' - 'lib/import/otrs/user_factory.rb'
- 'lib/import/transaction_factory.rb' - 'lib/import/transaction_factory.rb'
# Offense count: 469 # Offense count: 833
Metrics/AbcSize: Metrics/AbcSize:
Max: 637 Max: 637
# Offense count: 28 # Offense count: 29
# Configuration parameters: CountBlocks. # Configuration parameters: CountBlocks.
Metrics/BlockNesting: Metrics/BlockNesting:
Max: 5 Max: 5
# Offense count: 336 # Offense count: 340
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Max: 97 Max: 97
# Offense count: 23 # Offense count: 27
# Configuration parameters: CountComments. # Configuration parameters: CountComments.
Metrics/ModuleLength: Metrics/ModuleLength:
Max: 559 Max: 559
# Offense count: 272 # Offense count: 274
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Max: 115 Max: 115
@ -94,11 +94,18 @@ Rails/HasManyOrHasOneDependent:
- 'app/models/ticket/state_type.rb' - 'app/models/ticket/state_type.rb'
- 'app/models/user.rb' - 'app/models/user.rb'
# Offense count: 759 # Offense count: 15
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/knowledge_base_helper.rb'
# Offense count: 808
Style/Documentation: Style/Documentation:
Enabled: false Enabled: false
# Offense count: 170 # Offense count: 172
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit # SupportedStyles: implicit, explicit

View file

@ -176,6 +176,7 @@ group :development, :test do
gem 'pre-commit' gem 'pre-commit'
gem 'rubocop' gem 'rubocop'
gem 'rubocop-performance' gem 'rubocop-performance'
gem 'rubocop-rails'
gem 'rubocop-rspec' gem 'rubocop-rspec'
# changelog generation # changelog generation

View file

@ -255,7 +255,7 @@ GEM
ice_cube (0.16.3) ice_cube (0.16.3)
inflection (1.0.0) inflection (1.0.0)
interception (0.5) interception (0.5)
jaro_winkler (1.5.2) jaro_winkler (1.5.3)
json (2.2.0) json (2.2.0)
jwt (2.1.0) jwt (2.1.0)
kgio (2.11.2) kgio (2.11.2)
@ -352,7 +352,7 @@ GEM
omniauth (~> 1.5) omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0) omniauth-oauth2 (>= 1.4.0)
parallel (1.17.0) parallel (1.17.0)
parser (2.6.3.0) parser (2.6.4.0)
ast (~> 2.4.0) ast (~> 2.4.0)
pg (0.21.0) pg (0.21.0)
pluginator (1.5.0) pluginator (1.5.0)
@ -373,7 +373,6 @@ GEM
pry-stack_explorer (0.4.9.3) pry-stack_explorer (0.4.9.3)
binding_of_caller (>= 0.7) binding_of_caller (>= 0.7)
pry (>= 0.9.11) pry (>= 0.9.11)
psych (3.1.0)
public_suffix (3.0.3) public_suffix (3.0.3)
puma (3.12.1) puma (3.12.1)
rack (2.0.7) rack (2.0.7)
@ -442,19 +441,21 @@ GEM
rspec-support (~> 3.8.0) rspec-support (~> 3.8.0)
rspec-support (3.8.0) rspec-support (3.8.0)
rszr (0.5.2) rszr (0.5.2)
rubocop (0.67.2) rubocop (0.74.0)
jaro_winkler (~> 1.5.1) jaro_winkler (~> 1.5.1)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1) parser (>= 2.6)
psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.6) unicode-display_width (>= 1.4.0, < 1.7)
rubocop-performance (1.1.0) rubocop-performance (1.1.0)
rubocop (>= 0.67.0) rubocop (>= 0.67.0)
rubocop-rails (2.3.2)
rack (>= 1.1)
rubocop (>= 0.72.0)
rubocop-rspec (1.33.0) rubocop-rspec (1.33.0)
rubocop (>= 0.60.0) rubocop (>= 0.60.0)
ruby-progressbar (1.10.0) ruby-progressbar (1.10.1)
ruby_dep (1.5.0) ruby_dep (1.5.0)
rubyzip (1.2.2) rubyzip (1.2.2)
safe_yaml (1.0.5) safe_yaml (1.0.5)
@ -521,7 +522,7 @@ GEM
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.7.5) unf_ext (0.0.7.5)
unicode-display_width (1.5.0) unicode-display_width (1.6.0)
unicorn (5.5.0) unicorn (5.5.0)
kgio (~> 2.6) kgio (~> 2.6)
raindrops (~> 0.7) raindrops (~> 0.7)
@ -629,6 +630,7 @@ DEPENDENCIES
rszr (= 0.5.2) rszr (= 0.5.2)
rubocop rubocop
rubocop-performance rubocop-performance
rubocop-rails
rubocop-rspec rubocop-rspec
rubyntlm! rubyntlm!
sassc-rails sassc-rails

View file

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

View file

@ -154,6 +154,7 @@ class TicketArticleCommunicateEmailJob < ApplicationJob
notification: true, notification: true,
}, },
) )
ticket = Ticket.find(local_record.ticket_id) ticket = Ticket.find(local_record.ticket_id)
ticket.state = Ticket::State.find_by(default_follow_up: true) ticket.state = Ticket::State.find_by(default_follow_up: true)
ticket.save! ticket.save!

View file

@ -724,7 +724,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
# e. g. Content-Type: video/quicktime # e. g. Content-Type: video/quicktime
if filename.blank? if filename.blank?
map = { map = {
'message/delivery-status': ['txt', 'delivery-status'], 'message/delivery-status': %w[txt delivery-status],
'text/plain': %w[txt document], 'text/plain': %w[txt document],
'text/html': %w[html document], 'text/html': %w[html document],
'video/quicktime': %w[mov video], 'video/quicktime': %w[mov video],

View file

@ -94,7 +94,7 @@ module Channel::Filter::IdentifySender
def self.create_recipients(mail) def self.create_recipients(mail)
max_count = 40 max_count = 40
current_count = 0 current_count = 0
['raw-to', 'raw-cc'].each do |item| %w[raw-to raw-cc].each do |item|
next if mail[item.to_sym].blank? next if mail[item.to_sym].blank?
begin begin

View file

@ -22,7 +22,7 @@ returns
def self.to_sync def self.to_sync
locales = Locale.where(active: true) locales = Locale.where(active: true)
if Rails.env.test? if Rails.env.test?
locales = Locale.where(active: true, locale: ['en-us', 'de-de']) locales = Locale.where(active: true, locale: %w[en-us de-de])
end end
# read used locales based on env, e. g. export Z_LOCALES='en-us:de-de' # read used locales based on env, e. g. export Z_LOCALES='en-us:de-de'

View file

@ -133,7 +133,7 @@ execute migration down + unlink files
Dir.glob(package_base_dir + '/**/*') do |entry| Dir.glob(package_base_dir + '/**/*') do |entry|
entry = entry.sub('//', '/') entry = entry.sub('//', '/')
file = entry file = entry
file = file.sub(/#{package_base_dir.to_s}/, '') file = file.sub(/#{package_base_dir}/, '')
dest = @@root + '/' + file dest = @@root + '/' + file
if File.symlink?(dest.to_s) if File.symlink?(dest.to_s)
@ -166,7 +166,7 @@ link files + execute migration up
Dir.glob(package_base_dir + '/**/*') do |entry| Dir.glob(package_base_dir + '/**/*') do |entry|
entry = entry.sub('//', '/') entry = entry.sub('//', '/')
file = entry file = entry
file = file.sub(/#{package_base_dir.to_s}/, '') file = file.sub(/#{package_base_dir}/, '')
file = file.sub(%r{^/}, '') file = file.sub(%r{^/}, '')
# ignore files # ignore files

View file

@ -100,6 +100,7 @@ class Store::Provider::File
parts.push sha[last_position, length3] parts.push sha[last_position, length3]
last_position = end_position last_position = end_position
end end
path = parts[ 0..6 ].join('/') + '/' path = parts[ 0..6 ].join('/') + '/'
file = sha[last_position, sha.length] file = sha[last_position, sha.length]
location = "#{base}/#{path}" location = "#{base}/#{path}"

View file

@ -25,7 +25,7 @@ satinize html string based on whiltelist
# We whitelist yahoo_quoted because Yahoo Mail marks quoted email content using # We whitelist yahoo_quoted because Yahoo Mail marks quoted email content using
# <div class='yahoo_quoted'> and we rely on this class to identify quoted messages # <div class='yahoo_quoted'> and we rely on this class to identify quoted messages
classes_whitelist = ['js-signatureMarker', 'yahoo_quoted'] classes_whitelist = %w[js-signatureMarker yahoo_quoted]
attributes_2_css = %w[width height] attributes_2_css = %w[width height]
# remove html comments # remove html comments

View file

@ -24,7 +24,7 @@ class Sequencer
total = folder.total_count total = folder.total_count
per_page = 1000 per_page = 1000
pages = (total.to_f / per_page.to_f).ceil pages = (total.to_f / per_page).ceil
display_path = ews_folder.display_path(folder) display_path = ews_folder.display_path(folder)
(1..pages).each do |page| (1..pages).each do |page|

View file

@ -519,6 +519,7 @@ get spool messages
def self.spool_list(timestamp, current_user_id) def self.spool_list(timestamp, current_user_id)
path = "#{@path}/spool/" path = "#{@path}/spool/"
FileUtils.mkpath path FileUtils.mkpath path
data = [] data = []
to_delete = [] to_delete = []
files = [] files = []

View file

@ -63,7 +63,7 @@ returns
# generate average param and icon state # generate average param and icon state
backend_average_sum.each do |backend_model_average, result| backend_average_sum.each do |backend_model_average, result|
average = ( result.to_f / agent_count.to_f ).round(1) average = ( result.to_f / agent_count ).round(1)
user_result.each do |user_id, data| user_result.each do |user_id, data|
next if !data[backend_model_average] next if !data[backend_model_average]
next if !data[backend_model_average].key?(:used_for_average) next if !data[backend_model_average].key?(:used_for_average)

View file

@ -218,6 +218,7 @@ class AgentTicketAttachmentTest < TestCase
tasks_close_all( tasks_close_all(
browser: browser2, browser: browser2,
) )
random = 'ticket-actions-6-test-' + rand(999_999).to_s random = 'ticket-actions-6-test-' + rand(999_999).to_s
user_email = random + '@example.com' user_email = random + '@example.com'
user_create( user_create(