diff --git a/Gemfile.lock b/Gemfile.lock index ea8e8f632..9bf7b7ffc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/controllers/application_controller/handles_errors.rb b/app/controllers/application_controller/handles_errors.rb index 65e213194..fd558bdc7 100644 --- a/app/controllers/application_controller/handles_errors.rb +++ b/app/controllers/application_controller/handles_errors.rb @@ -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' diff --git a/app/controllers/first_steps_controller.rb b/app/controllers/first_steps_controller.rb index ede641098..fe5f91120 100644 --- a/app/controllers/first_steps_controller.rb +++ b/app/controllers/first_steps_controller.rb @@ -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 diff --git a/app/models/channel/driver.rb b/app/models/channel/driver.rb index fe4f9321e..55f2cbe6e 100644 --- a/app/models/channel/driver.rb +++ b/app/models/channel/driver.rb @@ -1,4 +1,4 @@ class Channel - class Driver + class Driver # rubocop:disable Lint/EmptyClass end end diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index acfc93623..5616b088e 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -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 diff --git a/app/models/channel/filter/monitoring_base.rb b/app/models/channel/filter/monitoring_base.rb index 20be1d1cf..cc3ec66cc 100644 --- a/app/models/channel/filter/monitoring_base.rb +++ b/app/models/channel/filter/monitoring_base.rb @@ -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' diff --git a/app/models/cti/log.rb b/app/models/cti/log.rb index 14cfa51d7..d537550da 100644 --- a/app/models/cti/log.rb +++ b/app/models/cti/log.rb @@ -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 diff --git a/app/models/object_manager/attribute.rb b/app/models/object_manager/attribute.rb index 315af7aa4..962796ca1 100644 --- a/app/models/object_manager/attribute.rb +++ b/app/models/object_manager/attribute.rb @@ -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, diff --git a/app/models/ticket/escalation.rb b/app/models/ticket/escalation.rb index c52ce7031..681993e67 100644 --- a/app/models/ticket/escalation.rb +++ b/app/models/ticket/escalation.rb @@ -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] || {} diff --git a/app/models/transaction/notification.rb b/app/models/transaction/notification.rb index 672db04c6..4b4a813cb 100644 --- a/app/models/transaction/notification.rb +++ b/app/models/transaction/notification.rb @@ -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 diff --git a/app/models/transaction/slack.rb b/app/models/transaction/slack.rb index 072d0da41..9225247a1 100644 --- a/app/models/transaction/slack.rb +++ b/app/models/transaction/slack.rb @@ -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 diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index b66bab2ba..f8f9d6a6e 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -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}######" diff --git a/lib/email_address_validation.rb b/lib/email_address_validation.rb index a9d6f8960..0980f8590 100644 --- a/lib/email_address_validation.rb +++ b/lib/email_address_validation.rb @@ -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 diff --git a/lib/excel_sheet.rb b/lib/excel_sheet.rb index 6a0fd54ec..8fe50c831 100644 --- a/lib/excel_sheet.rb +++ b/lib/excel_sheet.rb @@ -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' }) diff --git a/lib/facebook.rb b/lib/facebook.rb index 8fb2dbab4..794072270 100644 --- a/lib/facebook.rb +++ b/lib/facebook.rb @@ -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'] diff --git a/lib/import/otrs/helper.rb b/lib/import/otrs/helper.rb index 687ba770e..52a7cb04f 100644 --- a/lib/import/otrs/helper.rb +++ b/lib/import/otrs/helper.rb @@ -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 diff --git a/lib/notification_factory/mailer.rb b/lib/notification_factory/mailer.rb index 1e9cdad02..1d6787265 100644 --- a/lib/notification_factory/mailer.rb +++ b/lib/notification_factory/mailer.rb @@ -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 diff --git a/lib/report/article_by_type_sender.rb b/lib/report/article_by_type_sender.rb index 0d2afca23..2ff319a7b 100644 --- a/lib/report/article_by_type_sender.rb +++ b/lib/report/article_by_type_sender.rb @@ -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 diff --git a/lib/report/ticket_first_solution.rb b/lib/report/ticket_first_solution.rb index f26fa6a2d..ea45f548a 100644 --- a/lib/report/ticket_first_solution.rb +++ b/lib/report/ticket_first_solution.rb @@ -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 diff --git a/lib/report/ticket_generic_time.rb b/lib/report/ticket_generic_time.rb index 8aa208321..e508f00a8 100644 --- a/lib/report/ticket_generic_time.rb +++ b/lib/report/ticket_generic_time.rb @@ -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 diff --git a/lib/report/ticket_moved.rb b/lib/report/ticket_moved.rb index 4494b25ff..c6dcf5e75 100644 --- a/lib/report/ticket_moved.rb +++ b/lib/report/ticket_moved.rb @@ -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 diff --git a/lib/report/ticket_reopened.rb b/lib/report/ticket_reopened.rb index ff38c55e2..5d3a781ba 100644 --- a/lib/report/ticket_reopened.rb +++ b/lib/report/ticket_reopened.rb @@ -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 diff --git a/lib/secure_mailing/backend.rb b/lib/secure_mailing/backend.rb index f09c96143..7a5b3c17c 100644 --- a/lib/secure_mailing/backend.rb +++ b/lib/secure_mailing/backend.rb @@ -1,2 +1,2 @@ -class SecureMailing::Backend +class SecureMailing::Backend # rubocop:disable Lint/EmptyClass end diff --git a/lib/tasks/search_index_es.rake b/lib/tasks/search_index_es.rake index ef722b7ab..9c56fd4e1 100644 --- a/lib/tasks/search_index_es.rake +++ b/lib/tasks/search_index_es.rake @@ -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 diff --git a/lib/telegram.rb b/lib/telegram.rb index 04fa6f971..7f9646af1 100644 --- a/lib/telegram.rb +++ b/lib/telegram.rb @@ -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: { diff --git a/lib/user_agent.rb b/lib/user_agent.rb index 5a7c09181..b2479fc5b 100644 --- a/lib/user_agent.rb +++ b/lib/user_agent.rb @@ -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) diff --git a/test/browser/agent_ticket_online_notification_test.rb b/test/browser/agent_ticket_online_notification_test.rb index 1bcfbfacc..63ab52659 100644 --- a/test/browser/agent_ticket_online_notification_test.rb +++ b/test/browser/agent_ticket_online_notification_test.rb @@ -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',