Avoid assignments in conditions
This commit is contained in:
parent
d3f0fc703a
commit
7489b8d1aa
3 changed files with 7 additions and 3 deletions
|
@ -280,7 +280,7 @@ Lint/AmbiguousRegexpLiteral:
|
|||
Enabled: true
|
||||
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
Enabled: true
|
||||
|
||||
Lint/BigDecimalNew:
|
||||
Enabled: true
|
||||
|
|
|
@ -78,7 +78,9 @@ class Users::SessionsController < Sessions::SessionsController
|
|||
end
|
||||
|
||||
def try_to_authenticate(klass, remember_me = false)
|
||||
if resource = klass.find_for_database_authentication(email: params[:user][:email])
|
||||
resource = klass.find_for_database_authentication(email: params[:user][:email])
|
||||
|
||||
if resource.present?
|
||||
if resource.valid_password?(params[:user][:password])
|
||||
resource.remember_me = remember_me
|
||||
sign_in resource
|
||||
|
|
|
@ -7,7 +7,9 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long]
|
||||
|
||||
def initialize(options)
|
||||
if range = (options.delete(:in) || options.delete(:within))
|
||||
range = options.delete(:in) || options.delete(:within)
|
||||
|
||||
if range.present?
|
||||
raise ArgumentError, ":in and :within must be a Range" if !range.is_a?(Range)
|
||||
options[:minimum], options[:maximum] = range.begin, range.end
|
||||
options[:maximum] -= 1 if range.exclude_end?
|
||||
|
|
Loading…
Reference in a new issue