From: J Guthrie Date: Sun, 4 Nov 2018 18:52:45 +0000 (+0000) Subject: Fix rubocop errors X-Git-Tag: live~3374^2~8 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3b68061e8760448a80cd501e429b9901944fdf1d Fix rubocop errors --- diff --git a/app/validators/invalid_chars_validator.rb b/app/validators/invalid_chars_validator.rb index c324fd394..3860c95a3 100644 --- a/app/validators/invalid_chars_validator.rb +++ b/app/validators/invalid_chars_validator.rb @@ -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 diff --git a/app/validators/invalid_url_chars_validator.rb b/app/validators/invalid_url_chars_validator.rb index 77a2fc58c..38c4006b7 100644 --- a/app/validators/invalid_url_chars_validator.rb +++ b/app/validators/invalid_url_chars_validator.rb @@ -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 diff --git a/app/validators/leading_whitespace_validator.rb b/app/validators/leading_whitespace_validator.rb index fcefb0a19..e33d3c01b 100644 --- a/app/validators/leading_whitespace_validator.rb +++ b/app/validators/leading_whitespace_validator.rb @@ -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 diff --git a/app/validators/trailing_whitespace_validator.rb b/app/validators/trailing_whitespace_validator.rb index bb34ef463..03d6ef4db 100644 --- a/app/validators/trailing_whitespace_validator.rb +++ b/app/validators/trailing_whitespace_validator.rb @@ -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