Skip to content

Commit

Permalink
Fix Performance/RegexpMatch Rubocop warning
Browse files Browse the repository at this point in the history
Rubocop warns to use `match?` instead of `=~` for performance.
  • Loading branch information
JDutil committed Oct 26, 2019
1 parent 483ba1c commit 11a93af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/lib/spree/validators/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EmailValidator < ActiveModel::EachValidator
EMAIL_REGEXP = /\A([^@\.]|[^@\.]([^@\s]*)[^@\.])@([^@\s]+\.)+[^@\s]+\z/

def validate_each(record, attribute, value)
unless value =~ EMAIL_REGEXP
unless EMAIL_REGEXP.match? value
record.errors.add(attribute, :invalid, { value: value }.merge!(options))
end
end
Expand Down

0 comments on commit 11a93af

Please sign in to comment.