From: Tom Hughes Date: Tue, 7 Jul 2020 09:44:52 +0000 (+0100) Subject: Fix new rubocop warnings X-Git-Tag: live~2146 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/9f993fe8c8be4664f975df426d69ded1dca77ae3 Fix new rubocop warnings --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 045e93eb7..a2211ea69 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -235,7 +235,7 @@ class ApplicationController < ActionController::Base e = e.cause if e.is_a?(Timeout::Error) || - (e.is_a?(ActiveRecord::StatementInvalid) && e.message =~ /execution expired/) + (e.is_a?(ActiveRecord::StatementInvalid) && e.message.include?("execution expired")) render :action => "timeout" else raise diff --git a/app/models/trace.rb b/app/models/trace.rb index 5496bec45..97800a868 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -120,10 +120,10 @@ class Trace < ApplicationRecord def mime_type filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp - gzipped = filetype =~ /gzip compressed/ - bzipped = filetype =~ /bzip2 compressed/ - zipped = filetype =~ /Zip archive/ - tarred = filetype =~ /tar archive/ + gzipped = filetype.include?("gzip compressed") + bzipped = filetype.include?("bzip2 compressed") + zipped = filetype.include?("Zip archive") + tarred = filetype.include?("tar archive") mimetype = if gzipped "application/x-gzip" @@ -142,10 +142,10 @@ class Trace < ApplicationRecord def extension_name filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp - gzipped = filetype =~ /gzip compressed/ - bzipped = filetype =~ /bzip2 compressed/ - zipped = filetype =~ /Zip archive/ - tarred = filetype =~ /tar archive/ + gzipped = filetype.include?("gzip compressed") + bzipped = filetype.include?("bzip2 compressed") + zipped = filetype.include?("Zip archive") + tarred = filetype.include?("tar archive") extension = if tarred && gzipped ".tar.gz" @@ -211,10 +211,10 @@ class Trace < ApplicationRecord def xml_file filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp - gzipped = filetype =~ /gzip compressed/ - bzipped = filetype =~ /bzip2 compressed/ - zipped = filetype =~ /Zip archive/ - tarred = filetype =~ /tar archive/ + gzipped = filetype.include?("gzip compressed") + bzipped = filetype.include?("bzip2 compressed") + zipped = filetype.include?("Zip archive") + tarred = filetype.include?("tar archive") if gzipped || bzipped || zipped || tarred file = Tempfile.new("trace.#{id}") diff --git a/config/initializers/eslint.rb b/config/initializers/eslint.rb index 9d805eafb..9ddf4916e 100644 --- a/config/initializers/eslint.rb +++ b/config/initializers/eslint.rb @@ -3,7 +3,7 @@ if defined?(ESLintRails::Runner) module ESLintRails module ExcludeI18n def assets - super.reject { |a| a.to_s =~ %r{/i18n/} } + super.reject { |a| a.to_s.include?("/i18n/") } end end end diff --git a/lib/password_hash.rb b/lib/password_hash.rb index 9f77fdc0d..afea82c11 100644 --- a/lib/password_hash.rb +++ b/lib/password_hash.rb @@ -18,7 +18,7 @@ module PasswordHash def self.check(hash, salt, candidate) if salt.nil? candidate = Digest::MD5.hexdigest(candidate) - elsif salt.match?(/!/) + elsif salt.include?("!") algorithm, iterations, salt = salt.split("!") size = Base64.strict_decode64(hash).length candidate = self.hash(candidate, salt, iterations.to_i, size, algorithm) @@ -32,7 +32,7 @@ module PasswordHash def self.upgrade?(hash, salt) if salt.nil? return true - elsif salt.match?(/!/) + elsif salt.include?("!") algorithm, iterations, salt = salt.split("!") return true if Base64.strict_decode64(salt).length != SALT_BYTE_SIZE return true if Base64.strict_decode64(hash).length != HASH_BYTE_SIZE