Apply Style/AndOr and Style/Not rubocop rules

The `and` and `or` keywords are not equivalent to `&&` and `||` and its
use is counterintuitive. Here's an example

```
good = true && false # good if false
bad = true and false # bad is true
```

The reason is `and` and `or` are control flow operators. So the code:

```
bad = true and false
```

Is equivalent to:


```
if bad = true
  false
end
```
This commit is contained in:
Javi Martín
2019-10-26 00:07:30 +02:00
parent f07c422f21
commit a5def0cdb5
2 changed files with 7 additions and 1 deletions

View File

@@ -367,9 +367,15 @@ Security/JSONLoad:
Security/YAMLLoad:
Enabled: true
Style/AndOr:
Enabled: true
Style/BlockDelimiters:
Enabled: true
Style/Not:
Enabled: true
Style/PercentLiteralDelimiters:
Enabled: true

View File

@@ -62,7 +62,7 @@ module Devise
if !self.new_record? && !self.encrypted_password_change.nil? && !self.erased?
dummy = self.class.new
dummy.encrypted_password = self.encrypted_password_change.first
dummy.password_salt = self.password_salt_change.first if self.respond_to? :password_salt_change and not self.password_salt_change.nil?
dummy.password_salt = self.password_salt_change.first if self.respond_to?(:password_salt_change) && !self.password_salt_change.nil?
self.errors.add(:password, :equal_to_current_password) if dummy.valid_password?(self.password)
end
end