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

View file

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

View file

@ -220,21 +220,7 @@ class FirstStepsController < ApplicationController
end end
def check_availability(result) def check_availability(result)
test_ticket_active = true return result if test_ticket_active?
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
result.each do |item| result.each do |item|
items = [] items = []
@ -248,4 +234,14 @@ class FirstStepsController < ApplicationController
result result
end 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 end

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,7 +19,7 @@ class EmailAddressValidation
# @return [true] if email address has valid format # @return [true] if email address has valid format
# @return [false] if email address has no valid format # @return [false] if email address has no valid format
def 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. # email address to have a dot in its domain.
@valid_format ||= email_address.match?(URI::MailTo::EMAIL_REGEXP) @valid_format ||= email_address.match?(URI::MailTo::EMAIL_REGEXP)
end end

View file

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

View file

@ -137,19 +137,6 @@ result
} }
if auth if auth
user = User.find(auth.user_id) 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) user.update!(user_data)
else else
user_data[:login] = item_user['id'] user_data[:login] = item_user['id']

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -37,9 +37,7 @@ returns
case params[:interval] case params[:interval]
when 'month' when 'month'
params[:range_end] = params[:range_start].next_month params[:range_end] = params[:range_start].next_month
when 'week' when 'week', 'day'
params[:range_end] = params[:range_start].next_day
when 'day'
params[:range_end] = params[:range_start].next_day params[:range_end] = params[:range_start].next_day
when 'hour' when 'hour'
params[:range_end] = params[:range_start] + 1.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 end

View file

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

View file

@ -605,7 +605,7 @@ returns
if params[:channel_post] 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. 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. # need delete_if to remove any empty hashes, .compact only removes keys with nil values.
params[:message] = { params[:message] = {
document: { document: {

View file

@ -472,19 +472,7 @@ returns
url = response['location'] url = response['location']
return get(url, params, options, count - 1) return get(url, params, options, count - 1)
when Net::HTTPOK when Net::HTTPOK, Net::HTTPCreated
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
data = nil data = nil
if options[:json] && !options[:jsonParseDisable] && response.body if options[:json] && !options[:jsonParseDisable] && response.body
data = JSON.parse(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') items = browser2.find_elements(css: '.js-notificationsContainer .js-item.is-inactive')
assert_equal(3, items.count) 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( ticket_update(
data: { data: {
title: 'online notification #5/5', title: 'online notification #5/5',