]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Tue, 7 Jul 2020 09:44:52 +0000 (10:44 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 7 Jul 2020 09:44:52 +0000 (10:44 +0100)
app/controllers/application_controller.rb
app/models/trace.rb
config/initializers/eslint.rb
lib/password_hash.rb

index 045e93eb7a1f4f073c280e79738f007a546910d8..a2211ea69b4fde7a7ba1c81e696b102762a4e2cd 100644 (file)
@@ -235,7 +235,7 @@ class ApplicationController < ActionController::Base
     e = e.cause
 
     if e.is_a?(Timeout::Error) ||
     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
       render :action => "timeout"
     else
       raise
index 5496bec45977f71e9d0d83aad5a3198b71f50ac0..97800a86822f804f1dba741092a27feeb580dfb3 100644 (file)
@@ -120,10 +120,10 @@ class Trace < ApplicationRecord
 
   def mime_type
     filetype = Open3.capture2("/usr/bin/file", "-Lbz", trace_name).first.chomp
 
   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"
 
     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
 
   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"
 
     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
 
   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}")
 
     if gzipped || bzipped || zipped || tarred
       file = Tempfile.new("trace.#{id}")
index 9d805eafb518c8d10eed8e4d60ed3aaee9278bc1..9ddf4916e6193d140f34c547ca84c5788d7f7ff3 100644 (file)
@@ -3,7 +3,7 @@ if defined?(ESLintRails::Runner)
     module ESLintRails
       module ExcludeI18n
         def assets
     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
         end
       end
     end
index 9f77fdc0ddd9fd6825ce68dc504cd1e96f9c3500..afea82c111d018d9262b41a3f8b7e8520e0db4c4 100644 (file)
@@ -18,7 +18,7 @@ module PasswordHash
   def self.check(hash, salt, candidate)
     if salt.nil?
       candidate = Digest::MD5.hexdigest(candidate)
   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)
       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
   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
       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