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

This commit is contained in:
Thorsten Eckel 2020-11-12 12:42:44 +01:00
parent acd98bd214
commit b72a15a017
27 changed files with 45 additions and 146 deletions

View file

@ -357,7 +357,7 @@ GEM
omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0)
openssl (2.1.2)
parallel (1.19.2)
parallel (1.20.0)
parser (2.7.2.0)
ast (~> 2.4.1)
pg (0.21.0)
@ -452,13 +452,13 @@ GEM
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
rszr (0.5.2)
rubocop (1.2.0)
rubocop (1.3.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 1.0.1)
rubocop-ast (>= 1.1.1)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.1.1)
@ -533,7 +533,7 @@ GEM
faraday (~> 0.9)
jwt (>= 1.5, <= 2.5)
nokogiri (>= 1.6, < 2.0)
tzinfo (1.2.7)
tzinfo (1.2.8)
thread_safe (~> 0.1)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)

View file

@ -77,9 +77,7 @@ module ApplicationController::HandlesErrors
data[:error_human] = $1
elsif e.message.match?(/(already exists|duplicate key|duplicate entry)/i)
data[:error_human] = 'Object already exists!'
elsif e.message =~ /null value in column "(.+?)" violates not-null constraint/i
data[:error_human] = "Attribute '#{$1}' required!"
elsif e.message =~ /Field '(.+?)' doesn't have a default value/i
elsif e.message =~ /null value in column "(.+?)" violates not-null constraint/i || e.message =~ /Field '(.+?)' doesn't have a default value/i
data[:error_human] = "Attribute '#{$1}' required!"
elsif e.message == 'Exceptions::NotAuthorized'
data[:error] = 'Not authorized'

View file

@ -220,21 +220,7 @@ class FirstStepsController < ApplicationController
end
def check_availability(result)
test_ticket_active = true
overview = test_overview
if !overview
test_ticket_active = false
elsif overview.updated_by_id != 1
test_ticket_active = false
end
if !test_customer
test_ticket_active = false
end
if Group.where(active: true, name: 'Users').count.zero?
test_ticket_active = false
end
return result if test_ticket_active
return result if test_ticket_active?
result.each do |item|
items = []
@ -248,4 +234,14 @@ class FirstStepsController < ApplicationController
result
end
def test_ticket_active?
overview = test_overview
return false if !overview
return false if overview.updated_by_id != 1
return false if !test_customer
return false if Group.where(active: true, name: 'Users').count.zero?
true
end
end

View file

@ -1,4 +1,4 @@
class Channel
class Driver
class Driver # rubocop:disable Lint/EmptyClass
end
end

View file

@ -700,11 +700,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
rescue
begin
case file.header[:content_disposition].to_s
when /(filename|name)(\*{0,1})="(.+?)"/i
filename = $3
when /(filename|name)(\*{0,1})='(.+?)'/i
filename = $3
when /(filename|name)(\*{0,1})=(.+?);/i
when /(filename|name)(\*{0,1})="(.+?)"/i, /(filename|name)(\*{0,1})='(.+?)'/i, /(filename|name)(\*{0,1})=(.+?);/i
filename = $3
end
rescue
@ -714,11 +710,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
begin
case file.header[:content_disposition].to_s
when /(filename|name)(\*{0,1})="(.+?)"/i
filename = $3
when /(filename|name)(\*{0,1})='(.+?)'/i
filename = $3
when /(filename|name)(\*{0,1})=(.+?);/i
when /(filename|name)(\*{0,1})="(.+?)"/i, /(filename|name)(\*{0,1})='(.+?)'/i, /(filename|name)(\*{0,1})=(.+?);/i
filename = $3
end
rescue
@ -728,11 +720,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
# as fallback, use raw values
if filename.blank?
case headers_store['Content-Disposition'].to_s
when /(filename|name)(\*{0,1})="(.+?)"/i
filename = $3
when /(filename|name)(\*{0,1})='(.+?)'/i
filename = $3
when /(filename|name)(\*{0,1})=(.+?);/i
when /(filename|name)(\*{0,1})="(.+?)"/i, /(filename|name)(\*{0,1})='(.+?)'/i, /(filename|name)(\*{0,1})=(.+?);/i
filename = $3
end
end

View file

@ -66,9 +66,7 @@ class Channel::Filter::MonitoringBase
# possible event types https://mmonit.com/monit/documentation/#Setting-an-event-filter
if result['state'].blank?
result['state'] = case mail[:body]
when /\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/
'OK'
when /(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/
when /\s(done|recovery|succeeded|bytes\sok|packets\sok)\s/, /(instance\schanged\snot|Link\sup|Exists|Saturation\sok|Speed\sok)/
'OK'
else
'CRITICAL'

View file

@ -426,9 +426,7 @@ Cti::Log.process(
log.with_lock do
log.done = done
if params['direction'] == 'in'
if log.state == 'newCall' && cause != 'forwarded'
log.done = false
elsif log.to_comment == 'voicemail'
if (log.state == 'newCall' && cause != 'forwarded') || log.to_comment == 'voicemail' # rubocop:disable Style/SoleNestedConditional
log.done = false
end
end

View file

@ -591,15 +591,7 @@ to send no browser reload event, pass false
limit: attribute.data_option[:maxlength],
null: true
)
when /^integer|user_autocompletion|datetime|date$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
when /^boolean|active$/
when /^integer|user_autocompletion|datetime|date$/, /^boolean|active$/
ActiveRecord::Migration.change_column(
model.table_name,
attribute.name,
@ -631,23 +623,7 @@ to send no browser reload event, pass false
limit: attribute.data_option[:maxlength],
null: true
)
when /^integer|user_autocompletion$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
when /^boolean|active$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,
data_type,
default: attribute.data_option[:default],
null: true
)
when /^datetime|date$/
when /^integer|user_autocompletion$/, /^boolean|active$/, /^datetime|date$/
ActiveRecord::Migration.add_column(
model.table_name,
attribute.name,

View file

@ -98,6 +98,7 @@ returns
end
# get last_update_at
# rubocop:disable Lint/DuplicateBranch
if !last_contact_customer_at && !last_contact_agent_at
last_update_at = created_at
elsif !last_contact_customer_at && last_contact_agent_at
@ -109,6 +110,7 @@ returns
elsif last_contact_agent_at < last_contact_customer_at
last_update_at = last_contact_customer_at
end
# rubocop:enable Lint/DuplicateBranch
# check if calculation need be done
escalation_calculation = preferences[:escalation_calculation] || {}

View file

@ -245,11 +245,8 @@ class Transaction::Notification
@item[:changes].each do |key, value|
# if no config exists, use all attributes
if attribute_list.blank?
user_related_changes[key] = value
# if config exists, just use existing attributes for user
elsif attribute_list[key.to_s]
# or if config exists, just use existing attributes for user
if attribute_list.blank? || attribute_list[key.to_s]
user_related_changes[key] = value
end
end

View file

@ -214,11 +214,8 @@ class Transaction::Slack
@item[:changes].each do |key, value|
# if no config exists, use all attributes
if attribute_list.blank?
user_related_changes[key] = value
# if config exists, just use existing attributes for user
elsif attribute_list[key.to_s]
# or if config exists, just use existing attributes for user
if attribute_list.blank? || attribute_list[key.to_s]
user_related_changes[key] = value
end
end

View file

@ -147,9 +147,7 @@ class String
if link_compare.present? && text_compare.blank?
link
elsif link_compare.blank? && text_compare.present?
text
elsif link_compare && link_compare =~ /^mailto/i
elsif (link_compare.blank? && text_compare.present?) || (link_compare && link_compare =~ /^mailto/i)
text
elsif link_compare.present? && text_compare.present? && (link_compare == text_compare || link_compare == "mailto:#{text}".downcase || link_compare == "http://#{text}".downcase)
"######LINKEXT:#{link}/TEXT:#{text}######"

View file

@ -19,7 +19,7 @@ class EmailAddressValidation
# @return [true] if email address has valid format
# @return [false] if email address has no valid format
def valid_format?
# Note: Don't use ValidEmail2::Address.valid? here because it requires the
# NOTE: Don't use ValidEmail2::Address.valid? here because it requires the
# email address to have a dot in its domain.
@valid_format ||= email_address.match?(URI::MailTo::EMAIL_REGEXP)
end

View file

@ -74,9 +74,7 @@ class ExcelSheet
@current_column = 0
record.each do |item|
begin
if item.acts_like?(:time)
value_convert(item, nil, { data_type: 'datetime' })
elsif item.acts_like?(:date)
if item.acts_like?(:time) || item.acts_like?(:date)
value_convert(item, nil, { data_type: 'datetime' })
elsif item.is_a?(Integer) || item.is_a?(Float)
value_convert(item, nil, { data_type: 'integer' })

View file

@ -137,19 +137,6 @@ result
}
if auth
user = User.find(auth.user_id)
map = {
#note: 'description',
}
# ignore if value is already set
map.each do |target, source|
next if user[target].present?
new_value = tweet_user.send(source).to_s
next if new_value.blank?
user_data[target] = new_value
end
user.update!(user_data)
else
user_data[:login] = item_user['id']

View file

@ -20,13 +20,7 @@ module Import
def active?(record)
case record['ValidID'].to_s
when '3'
false
when '2'
false
when '1'
true
when '0'
when '3', '2', '0'
false
else
true

View file

@ -74,9 +74,7 @@ returns
selected_group_ids = user_preferences['notification_config']['group_ids']
if selected_group_ids.is_a?(Array)
hit = nil
if selected_group_ids.blank?
hit = true
elsif selected_group_ids[0] == '-' && selected_group_ids.count == 1
if selected_group_ids.blank? || (selected_group_ids[0] == '-' && selected_group_ids.count == 1)
hit = true
else
hit = false

View file

@ -44,9 +44,7 @@ returns
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
when 'week'
params[:range_end] = params[:range_start].next_day
when 'day'
when 'week', 'day'
params[:range_end] = params[:range_start].next_day
when 'hour'
params[:range_end] = params[:range_start] + 1.hour

View file

@ -35,9 +35,7 @@ returns
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
when 'week'
params[:range_end] = params[:range_start].next_day
when 'day'
when 'week', 'day'
params[:range_end] = params[:range_start].next_day
when 'hour'
params[:range_end] = params[:range_start] + 1.hour

View file

@ -96,9 +96,7 @@ returns
case params[:interval]
when 'month'
params[:range_start] = params[:range_start].next_month
when 'week'
params[:range_start] = params[:range_start].next_day
when 'day'
when 'week', 'day'
params[:range_start] = params[:range_start].next_day
when 'hour'
params[:range_start] = params[:range_start] + 1.hour

View file

@ -43,9 +43,7 @@ returns
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
when 'week'
params[:range_end] = params[:range_start].next_day
when 'day'
when 'week', 'day'
params[:range_end] = params[:range_start].next_day
when 'hour'
params[:range_end] = params[:range_start] + 1.hour

View file

@ -37,9 +37,7 @@ returns
case params[:interval]
when 'month'
params[:range_end] = params[:range_start].next_month
when 'week'
params[:range_end] = params[:range_start].next_day
when 'day'
when 'week', 'day'
params[:range_end] = params[:range_start].next_day
when 'hour'
params[:range_end] = params[:range_start] + 1.hour

View file

@ -1,2 +1,2 @@
class SecureMailing::Backend
class SecureMailing::Backend # rubocop:disable Lint/EmptyClass
end

View file

@ -250,7 +250,7 @@ def get_mapping_properties_object(object)
result[name][:properties][key] = {
type: 'integer',
}
elsif value.type == :datetime
elsif value.type == :datetime || value.type == :date
result[name][:properties][key] = {
type: 'date',
}
@ -273,10 +273,6 @@ def get_mapping_properties_object(object)
result[name][:properties][key] = {
type: 'float',
}
elsif value.type == :date
result[name][:properties][key] = {
type: 'date',
}
end
end

View file

@ -605,7 +605,7 @@ returns
if params[:channel_post]
return if params[:channel_post][:new_chat_title] # happens when channel title is renamed, we use [:chat][:title] already, safely ignore this.
# note: used .blank? which is a rails method. empty? does not work on integers (values like date, width, height) to check.
# NOTE: used .blank? which is a rails method. empty? does not work on integers (values like date, width, height) to check.
# need delete_if to remove any empty hashes, .compact only removes keys with nil values.
params[:message] = {
document: {

View file

@ -472,19 +472,7 @@ returns
url = response['location']
return get(url, params, options, count - 1)
when Net::HTTPOK
data = nil
if options[:json] && !options[:jsonParseDisable] && response.body
data = JSON.parse(response.body)
end
return Result.new(
data: data,
body: response.body,
content_type: response['Content-Type'],
success: true,
code: response.code,
)
when Net::HTTPCreated
when Net::HTTPOK, Net::HTTPCreated
data = nil
if options[:json] && !options[:jsonParseDisable] && response.body
data = JSON.parse(response.body)

View file

@ -200,7 +200,7 @@ class AgentTicketOnlineNotificationTest < TestCase
items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
assert_equal(3, items.count)
# Note: title update will generate extra notification - so we will have 5
# NOTE: title update will generate extra notification - so we will have 5
ticket_update(
data: {
title: 'online notification #5/5',