diff --git a/Gemfile.lock b/Gemfile.lock index 73ff75db5..cd948864e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -122,7 +122,7 @@ GEM buftok (0.2.0) builder (3.2.4) byebug (11.0.1) - capybara (3.21.0) + capybara (3.32.2) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -247,7 +247,7 @@ GEM http-form_data (2.1.1) http_parser.rb (0.6.0) httpclient (2.8.3) - i18n (1.8.2) + i18n (1.8.3) concurrent-ruby (~> 1.0) icalendar (2.5.3) ice_cube (~> 0.16) @@ -357,7 +357,7 @@ GEM omniauth-oauth2 (>= 1.4.0) openssl (2.1.2) parallel (1.19.1) - parser (2.7.1.2) + parser (2.7.1.3) ast (~> 2.4.0) pg (0.21.0) pluginator (1.5.0) @@ -378,7 +378,7 @@ GEM pry-stack_explorer (0.4.9.3) binding_of_caller (>= 0.7) pry (>= 0.9.11) - public_suffix (3.0.3) + public_suffix (3.1.1) puma (3.12.6) pundit (2.0.1) activesupport (>= 3.0.0) @@ -426,7 +426,7 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) rchardet (1.8.0) - regexp_parser (1.5.1) + regexp_parser (1.7.1) rest-client (2.0.2) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) @@ -451,22 +451,23 @@ GEM rspec-support (~> 3.8.0) rspec-support (3.8.0) rszr (0.5.2) - rubocop (0.84.0) + rubocop (0.85.1) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.7) rexml rubocop-ast (>= 0.0.3) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) rubocop-ast (0.0.3) parser (>= 2.7.0.1) - rubocop-performance (1.6.0) + rubocop-performance (1.6.1) rubocop (>= 0.71.0) - rubocop-rails (2.5.2) - activesupport + rubocop-rails (2.6.0) + activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.72.0) + rubocop (>= 0.82.0) rubocop-rspec (1.39.0) rubocop (>= 0.68.1) ruby-progressbar (1.10.1) diff --git a/app/helpers/knowledge_base_helper.rb b/app/helpers/knowledge_base_helper.rb index f739ea364..f7403ab28 100644 --- a/app/helpers/knowledge_base_helper.rb +++ b/app/helpers/knowledge_base_helper.rb @@ -11,7 +11,7 @@ module KnowledgeBaseHelper custom_address = knowledge_base.custom_address_uri return path unless custom_address - output = path.gsub(%r{^\/help}, custom_address.path || '').presence || '/' + output = path.gsub(%r{^/help}, custom_address.path || '').presence || '/' if full fqdn = request.headers.env['SERVER_NAME'] diff --git a/app/helpers/knowledge_base_rich_text_helper.rb b/app/helpers/knowledge_base_rich_text_helper.rb index d1ed9c0a6..881a87e90 100644 --- a/app/helpers/knowledge_base_rich_text_helper.rb +++ b/app/helpers/knowledge_base_rich_text_helper.rb @@ -28,7 +28,7 @@ module KnowledgeBaseRichTextHelper end def prepare_rich_text_videos(input) - input.gsub(/\(([\s]*)widget:([\s]*)video[\W]([\s\S])+?\)/) do |match| + input.gsub(/\((\s*)widget:(\s*)video\W([\s\S])+?\)/) do |match| settings = match .slice(1...-1) .split(',') diff --git a/app/models/channel/filter/monitoring_base.rb b/app/models/channel/filter/monitoring_base.rb index ea5911ae8..849c96d44 100644 --- a/app/models/channel/filter/monitoring_base.rb +++ b/app/models/channel/filter/monitoring_base.rb @@ -48,7 +48,7 @@ class Channel::Filter::MonitoringBase # icinga - get state by body - new templates if result['state'].blank? - if mail[:body] =~ /.+?\sis\s(.+?)\!/ + if mail[:body] =~ /.+?\sis\s(.+?)!/ result['state'] = $1 end end @@ -57,7 +57,7 @@ class Channel::Filter::MonitoringBase # Subject: [PROBLEM] Ping IPv4 on host1234.dc.example.com is WARNING! # Subject: [PROBLEM] Host host1234.dc.example.com is DOWN! if result['state'].blank? - if mail[:subject] =~ /(on|Host)\s.+?\sis\s(.+?)\!/ + if mail[:subject] =~ /(on|Host)\s.+?\sis\s(.+?)!/ result['state'] = $2 end end diff --git a/app/models/cti/caller_id.rb b/app/models/cti/caller_id.rb index a70c14ac2..83f32b58e 100644 --- a/app/models/cti/caller_id.rb +++ b/app/models/cti/caller_id.rb @@ -226,7 +226,7 @@ returns # see specs for example return [] if !text.is_a?(String) - text.scan(/([\d|\s|\-|\(|\)]{6,26})/).map do |match| + text.scan(/([\d|\s|\-|(|)]{6,26})/).map do |match| normalize_number(match[0]) end end diff --git a/app/models/knowledge_base/category.rb b/app/models/knowledge_base/category.rb index 97795ade5..8397860e9 100644 --- a/app/models/knowledge_base/category.rb +++ b/app/models/knowledge_base/category.rb @@ -9,21 +9,19 @@ class KnowledgeBase::Category < ApplicationModel belongs_to :knowledge_base, inverse_of: :categories - has_many :answers, class_name: 'KnowledgeBase::Answer', - foreign_key: :category_id, - inverse_of: :category, - dependent: :restrict_with_exception + has_many :answers, class_name: 'KnowledgeBase::Answer', + inverse_of: :category, + dependent: :restrict_with_exception has_many :children, class_name: 'KnowledgeBase::Category', foreign_key: :parent_id, inverse_of: :parent, dependent: :restrict_with_exception - belongs_to :parent, class_name: 'KnowledgeBase::Category', - foreign_key: :parent_id, - inverse_of: :children, - touch: true, - optional: true + belongs_to :parent, class_name: 'KnowledgeBase::Category', + inverse_of: :children, + touch: true, + optional: true validates :category_icon, presence: true diff --git a/app/models/knowledge_base/menu_item.rb b/app/models/knowledge_base/menu_item.rb index 8c89867c4..fca2be7b0 100644 --- a/app/models/knowledge_base/menu_item.rb +++ b/app/models/knowledge_base/menu_item.rb @@ -21,7 +21,7 @@ class KnowledgeBase::MenuItem < ApplicationModel url.strip! - return if url.match? %r{^\S+\:\/\/} + return if url.match? %r{^\S+://} return if url[0] == '/' self.url = "http://#{url}" diff --git a/app/models/stats_store.rb b/app/models/stats_store.rb index 4c51f2de7..ca8fc135e 100644 --- a/app/models/stats_store.rb +++ b/app/models/stats_store.rb @@ -3,11 +3,8 @@ class StatsStore < ApplicationModel include HasSearchIndexBackend include StatsStore::SearchIndex - - # rubocop:disable Rails/InverseOf - belongs_to :stats_store_object, class_name: 'ObjectLookup', foreign_key: 'stats_store_object_id', optional: true - belongs_to :related_stats_store_object, class_name: 'ObjectLookup', foreign_key: 'related_stats_store_object_id', optional: true - # rubocop:enable Rails/InverseOf + belongs_to :stats_store_object, class_name: 'ObjectLookup', optional: true + belongs_to :related_stats_store_object, class_name: 'ObjectLookup', optional: true store :data diff --git a/app/models/user.rb b/app/models/user.rb index 9ed492499..c5b3a3e1d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -892,7 +892,7 @@ try to find correct name # -no name- "firstname.lastname@example.com" if string.blank? && email.present? - scan = email.scan(/^(.+?)\.(.+?)\@.+?$/) + scan = email.scan(/^(.+?)\.(.+?)@.+?$/) if scan[0].present? if scan[0][0].present? firstname = scan[0][0].strip diff --git a/lib/core_ext/open-uri.rb b/lib/core_ext/open-uri.rb index 592c96cb9..26457c35d 100644 --- a/lib/core_ext/open-uri.rb +++ b/lib/core_ext/open-uri.rb @@ -8,7 +8,7 @@ if Kernel.respond_to?(:open_uri_original_open) if name.respond_to?(:open) && name.method(:open).parameters.present? name.open(*rest, &block) elsif name.respond_to?(:to_str) && - %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ name && + %r{\A[A-Za-z][A-Za-z0-9+\-.]*://} =~ name && (uri = URI.parse(name)).respond_to?(:open) uri.open(*rest, &block) else diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 494531153..732f67991 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -137,7 +137,7 @@ class String string.gsub!(%r{]*)>(.+?)<[[:space:]]*/a[[:space:]]*>}mxi) do |_placeholder| link = $3 text = $6 - text.gsub!(/\<.+?\>/, '') + text.gsub!(/<.+?>/, '') link_compare = link.dup if link_compare.present? @@ -218,7 +218,7 @@ class String string.gsub!(%r{}i, ' ') # strip all other tags - string.gsub!(/\<.+?\>/, '') + string.gsub!(/<.+?>/, '') # replace multiple spaces with one string.gsub!(/ /, ' ') @@ -348,8 +348,8 @@ class String string.gsub!(/(
[[:space:]]*){3,}/im, '

') string.gsub!(%r\([[:space:]]*){3,}\im, '

') string.gsub!(%r{

[[:space:]]+

}im, '

 

') - string.gsub!(%r{\A([[:space:]]*)*}i, '') - string.gsub!(%r{[[:space:]]*([[:space:]]*)*\Z}i, '') + string.gsub!(%r{\A([[:space:]]*)*}i, '') + string.gsub!(%r{[[:space:]]*([[:space:]]*)*\Z}i, '') string.gsub!(%r{(

){1,10}\Z}i, '') string.signature_identify('html') diff --git a/lib/idoit.rb b/lib/idoit.rb index 1117176fc..42a599379 100644 --- a/lib/idoit.rb +++ b/lib/idoit.rb @@ -124,7 +124,7 @@ or with filter: }, ) - raise "Can't fetch objects from #{url}: Unable to parse response from server. Invalid JSON response." if !result.success? && result.error =~ /JSON::ParserError:.+?\s+unexpected\s+token\s+at\s+'<\!DOCTYPE\s+html/i + raise "Can't fetch objects from #{url}: Unable to parse response from server. Invalid JSON response." if !result.success? && result.error =~ /JSON::ParserError:.+?\s+unexpected\s+token\s+at\s+'[^\(]+)\((?[^\)]+)\)\z/ =~ method + if /\A(?[^(]+)\((?[^)]+)\)\z/ =~ method if parameter != parameter.to_i.to_s value = "\#{#{object_name}.#{object_methods_s} / invalid parameter: #{parameter}}" diff --git a/lib/sequencer/unit/import/common/object_attribute/sanitized_name.rb b/lib/sequencer/unit/import/common/object_attribute/sanitized_name.rb index 9096c001a..33adf8802 100644 --- a/lib/sequencer/unit/import/common/object_attribute/sanitized_name.rb +++ b/lib/sequencer/unit/import/common/object_attribute/sanitized_name.rb @@ -31,7 +31,7 @@ class Sequencer # model___name # model_name # model_name - transliterated.gsub(%r{[\s\/]}, '_').underscore + transliterated.gsub(%r{[\s/]}, '_').underscore end def transliterated diff --git a/lib/zammad/application/initializer/db_preflight_check/mysql2.rb b/lib/zammad/application/initializer/db_preflight_check/mysql2.rb index 7ac4ce356..74169bfd7 100644 --- a/lib/zammad/application/initializer/db_preflight_check/mysql2.rb +++ b/lib/zammad/application/initializer/db_preflight_check/mysql2.rb @@ -41,8 +41,8 @@ module Zammad Please increase this value in your #{vendor} configuration accordingly. MSG end - # Setting.get will fail if 'settings' table does not exist rescue ActiveRecord::StatementInvalid + # Setting.get will fail if 'settings' table does not exist end def self.connection diff --git a/spec/support/capybara/browser_test_helper.rb b/spec/support/capybara/browser_test_helper.rb index 2592ab4c7..6c3af7d17 100644 --- a/spec/support/capybara/browser_test_helper.rb +++ b/spec/support/capybara/browser_test_helper.rb @@ -86,6 +86,7 @@ module BrowserTestHelper yield rescue Capybara::ElementNotFound + # doesn't exist yet end rescue Selenium::WebDriver::Error::TimeOutError => e # cleanup backtrace diff --git a/test/unit/email_build_test.rb b/test/unit/email_build_test.rb index 68817919d..c6894af8a 100644 --- a/test/unit/email_build_test.rb +++ b/test/unit/email_build_test.rb @@ -7,7 +7,7 @@ class EmailBuildTest < ActiveSupport::TestCase result = Channel::EmailBuild.html_complete_check(html) assert(result.start_with?('/, 'test 1') assert(result =~ /font-family/, 'test 1') assert(result =~ %r{test}, 'test 1') @@ -15,8 +15,8 @@ class EmailBuildTest < ActiveSupport::TestCase html = 'invalid test' result = Channel::EmailBuild.html_complete_check(html) - assert(result !~ /^<\!DOCTYPE/, 'test 2') - assert(result =~ /^.+?<\!DOCTYPE/, 'test 2') + assert(result !~ /^/, 'test 2') assert(result !~ /font-family/, 'test 2') assert(result =~ %r{test}, 'test 2')