]> git.openstreetmap.org Git - rails.git/commitdiff
Fix rubocop errors
authorJ Guthrie <jamie.guthrie@gmail.com>
Sun, 4 Nov 2018 18:52:45 +0000 (18:52 +0000)
committerJ Guthrie <jamie.guthrie@gmail.com>
Mon, 5 Nov 2018 14:27:06 +0000 (14:27 +0000)
app/validators/invalid_chars_validator.rb
app/validators/invalid_url_chars_validator.rb
app/validators/leading_whitespace_validator.rb
app/validators/trailing_whitespace_validator.rb

index c324fd39457bf0b7460b1e8173f395ad51d9eacd..3860c95a3661192daadda41339f3306e48fc7709 100644 (file)
@@ -2,8 +2,6 @@ class InvalidCharsValidator < ActiveModel::EachValidator
   INVALID_CHARS = "\x00-\x08\x0b-\x0c\x0e-\x1f\x7f\ufffe\uffff".freeze
 
   def validate_each(record, attribute, value)
-    if value =~ /[#{INVALID_CHARS}]/
-      record.errors[attribute] << (options[:message] || "contains invalid chars")
-    end
+    record.errors[attribute] << (options[:message] || "contains invalid chars") if value =~ /[#{INVALID_CHARS}]/
   end
-end
\ No newline at end of file
+end
index 77a2fc58c0eb65f87fa69edb53583b3a34e7a443..38c4006b72701b25be12a64371f79cff3d818836 100644 (file)
@@ -2,8 +2,6 @@ class InvalidUrlCharsValidator < ActiveModel::EachValidator
   INVALID_URL_CHARS = "/;.,?%#".freeze
 
   def validate_each(record, attribute, value)
-    if value =~ /[#{INVALID_URL_CHARS}]/
-      record.errors[attribute] << (options[:message] || I18n.t("validations.invalid chars", :invalid_chars => INVALID_URL_CHARS))
-    end
+    record.errors[attribute] << (options[:message] || I18n.t("validations.invalid chars", :invalid_chars => INVALID_URL_CHARS)) if value =~ /[#{INVALID_URL_CHARS}]/
   end
-end
\ No newline at end of file
+end
index fcefb0a196eeccc05a16a85a0659b7df9970bcda..e33d3c01b1624ba1cef6be2c7cf613ceae7e565e 100644 (file)
@@ -1,7 +1,5 @@
 class LeadingWhitespaceValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
-    if value =~ /\A\s/
-      record.errors[attribute] << (options[:message] || I18n.t("validations.leading whitespace"))
-    end
+    record.errors[attribute] << (options[:message] || I18n.t("validations.leading whitespace")) if value =~ /\A\s/
   end
-end
\ No newline at end of file
+end
index bb34ef463088e7af104f70caf4415d81a9d5adfe..03d6ef4db3bc88924ab370548d30faab2d97e650 100644 (file)
@@ -1,7 +1,5 @@
 class TrailingWhitespaceValidator < ActiveModel::EachValidator
   def validate_each(record, attribute, value)
-    if value =~ /\s\z/
-      record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace"))
-    end
+    record.errors[attribute] << (options[:message] || I18n.t("validations.trailing whitespace")) if value =~ /\s\z/
   end
-end
\ No newline at end of file
+end