Updated rubocop(-* gems) to latest version (0.84.0).

This commit is contained in:
Thorsten Eckel 2020-05-25 09:05:17 +02:00
parent e037b6015e
commit 8690916936
17 changed files with 29 additions and 26 deletions

View file

@ -448,14 +448,17 @@ GEM
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rszr (0.5.2)
rubocop (0.83.0)
rubocop (0.84.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
rubocop-ast (>= 0.0.3)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-performance (1.5.2)
rubocop-ast (0.0.3)
parser (>= 2.7.0.1)
rubocop-performance (1.6.0)
rubocop (>= 0.71.0)
rubocop-rails (2.5.2)
activesupport

View file

@ -638,8 +638,8 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
# cleanup content id, <> will be added automatically later
if headers_store['Content-ID']
headers_store['Content-ID'].gsub!(/^</, '')
headers_store['Content-ID'].gsub!(/>$/, '')
headers_store['Content-ID'].delete_prefix!('<')
headers_store['Content-ID'].delete_suffix!('>')
end
# get filename from content-disposition

View file

@ -188,8 +188,8 @@ module Channel::Filter::IdentifySender
string.strip
.delete('"')
.gsub(/^'/, '')
.gsub(/'$/, '')
.delete_prefix("'")
.delete_suffix("'")
.gsub(/.+?\s\(.+?\)$/, '')
end
@ -204,7 +204,7 @@ module Channel::Filter::IdentifySender
.sub(/^<|>$/, '') # see https://github.com/zammad/zammad/issues/2254
.sub(/\A'(.*)'\z/, '\1') # see https://github.com/zammad/zammad/issues/2154
.gsub(/\s/, '') # see https://github.com/zammad/zammad/issues/2198
.gsub(/\.\z/, '')
.delete_suffix('.')
end
end

View file

@ -247,8 +247,8 @@ returns
next if value.class == ActiveSupport::HashWithIndifferentAccess
next if value.class == Hash
next if csv_attributes_ignored&.include?(key.to_sym)
next if key.match?(/_id$/)
next if key.match?(/_ids$/)
next if key.end_with?('_id')
next if key.end_with?('_ids')
next if key == 'created_by'
next if key == 'updated_by'
next if key == 'created_at'

View file

@ -54,7 +54,7 @@ class KnowledgeBase < ApplicationModel
data[:KnowledgeBase].each do |_, elem|
elem.delete_if do |k, _|
k.match?(/_ids$/)
k.end_with?('_ids')
end
end

View file

@ -170,7 +170,7 @@ link files + execute migration up
file = file.sub(%r{^/}, '')
# ignore files
if file.match?(/^README/)
if file.start_with?('README')
logger.info "NOTICE: Ignore #{file}"
next
end

View file

@ -37,7 +37,7 @@ class Package::Migration < ApplicationModel
end
migrations_existing.each do |migration|
next if !migration.match?(/\.rb$/)
next if !migration.end_with?('.rb')
version = nil
name = nil

View file

@ -582,7 +582,7 @@ condition example
# validate value / allow blank but only if pre_condition exists and is not specific
if !selector.key?('value') ||
(selector['value'].class == Array && selector['value'].respond_to?(:blank?) && selector['value'].blank?) ||
(selector['operator'] =~ /^contains/ && selector['value'].respond_to?(:blank?) && selector['value'].blank?)
(selector['operator'].start_with?('contains') && selector['value'].respond_to?(:blank?) && selector['value'].blank?)
return nil if selector['pre_condition'].nil?
return nil if selector['pre_condition'].respond_to?(:blank?) && selector['pre_condition'].blank?
return nil if selector['pre_condition'] == 'specific'
@ -938,9 +938,9 @@ perform changes on ticket
# lookup pre_condition
if value['pre_condition']
if value['pre_condition'].match?(/^not_set/)
if value['pre_condition'].start_with?('not_set')
value['value'] = 1
elsif value['pre_condition'].match?(/^current_user\./)
elsif value['pre_condition'].start_with?('current_user.')
raise 'Unable to use current_user, got no current_user_id for ticket.perform_changes' if !current_user_id
value['value'] = current_user_id

View file

@ -422,7 +422,7 @@ returns
def permissions?(key)
Array(key).each do |local_key|
list = []
if local_key.match?(/\.\*$/)
if local_key.end_with?('.*')
local_key = local_key.sub('.*', '.%')
permissions = ::Permission.with_parents(local_key)
list = ::Permission.select('preferences').joins(:roles).where('roles.id IN (?) AND roles.active = ? AND (permissions.name IN (?) OR permissions.name LIKE ?) AND permissions.active = ?', role_ids, true, permissions, local_key, true).pluck(:preferences)

View file

@ -13,7 +13,7 @@ module ActiveRecord
if column_names.class == Array
index_columns_new = []
column_names.each do |i|
if i =~ /^"(name|login|locale|alias)"$/ || i =~ /name"$/
if i =~ /^"(name|login|locale|alias)"$/ || i.end_with?('name"')
index_columns_new.push "LOWER(#{i})"
else
index_columns_new.push i

View file

@ -78,7 +78,7 @@ class String
def to_classname
camel_cased_word = dup
camel_cased_word.gsub!(/\.rb$/, '')
camel_cased_word.delete_suffix!('.rb')
camel_cased_word.split('/').map(&:camelize).join('::')
end

View file

@ -421,8 +421,8 @@ cleanup html string:
end
def self.url_same?(url_new, url_old)
url_new = CGI.unescape(url_new.to_s).utf8_encode(fallback: :read_as_sanitized_binary).downcase.gsub(%r{/$}, '').gsub(/[[:space:]]|\t|\n|\r/, '').strip
url_old = CGI.unescape(url_old.to_s).utf8_encode(fallback: :read_as_sanitized_binary).downcase.gsub(%r{/$}, '').gsub(/[[:space:]]|\t|\n|\r/, '').strip
url_new = CGI.unescape(url_new.to_s).utf8_encode(fallback: :read_as_sanitized_binary).downcase.delete_suffix('/').gsub(/[[:space:]]|\t|\n|\r/, '').strip
url_old = CGI.unescape(url_old.to_s).utf8_encode(fallback: :read_as_sanitized_binary).downcase.delete_suffix('/').gsub(/[[:space:]]|\t|\n|\r/, '').strip
url_new = html_decode(url_new).sub('/?', '?')
url_old = html_decode(url_old).sub('/?', '?')
return true if url_new == url_old

View file

@ -440,7 +440,7 @@ returns
files.push entry
end
files.sort.each do |entry|
next if !entry.match?(/^send/)
next if !entry.start_with?('send')
message = Sessions.queue_file_read(path, entry)
next if !message

View file

@ -721,12 +721,12 @@ returns
# send welcome message and don't create ticket
text = params[:message][:text]
if text.present? && text =~ %r{^/start}
if text.present? && text.start_with?('/start')
message(params[:message][:chat][:id], channel.options[:welcome] || 'You are welcome! Just ask me something!', params[:message][:from][:language_code])
return
# find ticket and close it
elsif text.present? && text =~ %r{^/end}
elsif text.present? && text.start_with?('/end')
user = to_user(params)
# get the last ticket of customer which is not closed yet, and close it

View file

@ -42,7 +42,7 @@ module Zammad
MSG
end
# Setting.get will fail if 'settings' table does not exist
rescue ActiveRecord::StatementInvalid # rubocop:disable Lint/SuppressedException
rescue ActiveRecord::StatementInvalid
end
def self.connection

View file

@ -71,7 +71,7 @@ module BrowserTestHelper
self.until do
yield
rescue Capybara::ElementNotFound # rubocop:disable Lint/SuppressedException
rescue Capybara::ElementNotFound
end
rescue Selenium::WebDriver::Error::TimeOutError => e

View file

@ -6,7 +6,7 @@ class EmailBuildTest < ActiveSupport::TestCase
html = '<b>test</b>'
result = Channel::EmailBuild.html_complete_check(html)
assert(result =~ /^<\!DOCTYPE/, 'test 1')
assert(result.start_with?('<!DOCTYPE'), 'test 1')
assert(result !~ /^.+?<\!DOCTYPE/, 'test 1')
assert(result =~ /<html>/, 'test 1')
assert(result =~ /font-family/, 'test 1')