Merge pull request #1118 from Br3nda/bw/assignment-in-condition

Don't use assignments in conditions
This commit is contained in:
Mackenzie
2016-12-06 12:40:00 -05:00
committed by GitHub
2 changed files with 3 additions and 11 deletions

View File

@@ -26,12 +26,6 @@ Lint/AmbiguousRegexpLiteral:
- 'spec/views/members/show.rss.haml_spec.rb'
- 'spec/views/posts/show.html.haml_spec.rb'
# Offense count: 1
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'app/models/member.rb'
# Offense count: 1
Lint/HandleExceptions:
Exclude:

View File

@@ -91,11 +91,9 @@ class Member < ActiveRecord::Base
# allow login via either login_name or email address
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).login_name_or_email(login).first
else
find_by(conditions)
end
login = conditions.delete(:login)
return where(conditions).login_name_or_email(login).first if login
find_by(conditions)
end
def to_s