From 51933e3b76a6b7bfd716ae73cb0274adaf6126c8 Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 30 Sep 2021 09:18:16 +0200 Subject: [PATCH] Maintenance: Bump rubocop from 1.21.0 to 1.22.0 --- Gemfile.lock | 4 ++-- app/models/channel/email_parser.rb | 2 +- lib/html_sanitizer.rb | 4 ++-- test/integration/email_postmaster_to_sender.rb | 8 ++------ test/test_helper.rb | 2 +- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index f41562771..b9dbee417 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -498,13 +498,13 @@ GEM rspec-support (~> 3.10) rspec-support (3.10.2) rszr (0.5.2) - rubocop (1.21.0) + rubocop (1.22.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.9.1, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.12.0) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 9c132dc48..57ed916ff 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -502,7 +502,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again path = Rails.root.join('tmp/unprocessable_mail') files = [] Dir.glob("#{path}/*.eml") do |entry| - ticket, _article, _user, _mail = Channel::EmailParser.new.process(params, IO.binread(entry)) + ticket, _article, _user, _mail = Channel::EmailParser.new.process(params, File.binread(entry)) next if ticket.blank? files.push entry diff --git a/lib/html_sanitizer.rb b/lib/html_sanitizer.rb index 2ca0819b9..440f3b94e 100644 --- a/lib/html_sanitizer.rb +++ b/lib/html_sanitizer.rb @@ -161,8 +161,8 @@ satinize html string based on whiltelist # wrap plain-text URLs in tags if node.is_a?(Nokogiri::XML::Text) && node.content.present? && node.content.include?(':') && node.ancestors.map(&:name).exclude?('a') urls = URI.extract(node.content, LINKABLE_URL_SCHEMES) - .map { |u| u.sub(%r{[,.]$}, '') } # URI::extract captures trailing dots/commas - .reject { |u| u.match?(%r{^[^:]+:$}) } # URI::extract will match, e.g., 'tel:' + .map { |u| u.sub(%r{[,.]$}, '') } # URI::extract captures trailing dots/commas + .grep_v(%r{^[^:]+:$}) # URI::extract will match, e.g., 'tel:' next if urls.blank? diff --git a/test/integration/email_postmaster_to_sender.rb b/test/integration/email_postmaster_to_sender.rb index b66625921..af10ad22d 100644 --- a/test/integration/email_postmaster_to_sender.rb +++ b/test/integration/email_postmaster_to_sender.rb @@ -104,9 +104,7 @@ Oversized Email Message Body #{'#' * 120_000} # 1. verify that the oversized email has been saved locally to: # /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml path = Rails.root.join('tmp/oversized_mail') - target_files = Dir.entries(path).select do |filename| - filename =~ %r{^#{large_message_md5}\.eml$} - end + target_files = Dir.entries(path).grep(%r{^#{large_message_md5}\.eml$}) assert(target_files.present?, 'Large message .eml log file must be present.') # pick the latest file that matches the criteria @@ -193,9 +191,7 @@ Oversized Email Message Body #{'#' * 120_000} # 1. verify that the oversized email has been saved locally to: # /tmp/oversized_mail/yyyy-mm-ddThh:mm:ss-:md5.eml path = Rails.root.join('tmp/oversized_mail') - target_files = Dir.entries(path).select do |filename| - filename =~ %r{^.+?\.eml$} - end + target_files = Dir.entries(path).grep(%r{^.+?\.eml$}) assert_not(target_files.blank?, 'Large message .eml log file must be blank.') # 2. verify that a postmaster response email has been sent to the sender diff --git a/test/test_helper.rb b/test/test_helper.rb index ad9295bfe..fe893a130 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -62,7 +62,7 @@ class ActiveSupport::TestCase # read config file and count type & recipients file = Rails.root.join('log', "#{Rails.env}.log") lines = [] - IO.foreach(file) do |line| + File.foreach(file) do |line| lines.push line end count = 0