Browse Source

and/or -> &&/||

Maarten van den Berg 6 years ago
parent
commit
14b7c18c47
4 changed files with 5 additions and 15 deletions
  1. 0 10
      .rubocop.yml
  2. 3 3
      app/controllers/authentication_controller.rb
  3. 1 1
      app/models/activity.rb
  4. 1 1
      app/models/user.rb

+ 0 - 10
.rubocop.yml

67
   Exclude:
67
   Exclude:
68
     - 'app/models/activity.rb'
68
     - 'app/models/activity.rb'
69
 
69
 
70
-# Offense count: 7
71
-# Cop supports --auto-correct.
72
-# Configuration parameters: EnforcedStyle.
73
-# SupportedStyles: always, conditionals
74
-Style/AndOr:
75
-  Exclude:
76
-    - 'app/controllers/authentication_controller.rb'
77
-    - 'app/models/activity.rb'
78
-    - 'app/models/user.rb'
79
-
80
 # Offense count: 9
70
 # Offense count: 9
81
 # Cop supports --auto-correct.
71
 # Cop supports --auto-correct.
82
 # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
72
 # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.

+ 3 - 3
app/controllers/authentication_controller.rb

16
 
16
 
17
         flash_message(:success, I18n.t(:greeting, name: u.person.first_name))
17
         flash_message(:success, I18n.t(:greeting, name: u.person.first_name))
18
         redirect_to root_path
18
         redirect_to root_path
19
-      elsif u and not u.confirmed
19
+      elsif u && (not u.confirmed)
20
         flash_message(:warning, I18n.t('authentication.activation_required'))
20
         flash_message(:warning, I18n.t('authentication.activation_required'))
21
         redirect_to action: 'login_form'
21
         redirect_to action: 'login_form'
22
       else
22
       else
53
     end
53
     end
54
 
54
 
55
     user = User.find_by(person: person)
55
     user = User.find_by(person: person)
56
-    if user and user.confirmed
56
+    if user && user.confirmed
57
       flash_message(:warning, I18n.t('authentication.already_activated'))
57
       flash_message(:warning, I18n.t('authentication.already_activated'))
58
       redirect_to action: 'login'
58
       redirect_to action: 'login'
59
       return
59
       return
161
       redirect_to action: 'login'
161
       redirect_to action: 'login'
162
       return false
162
       return false
163
     end
163
     end
164
-    if token.expires and token.expires < DateTime.now
164
+    if token.expires && (token.expires < DateTime.now)
165
       flash_message(:warning, I18n.t('authentication.token_expired'))
165
       flash_message(:warning, I18n.t('authentication.token_expired'))
166
       redirect_to action: 'login'
166
       redirect_to action: 'login'
167
       return false
167
       return false

+ 1 - 1
app/models/activity.rb

122
     p = c[true]
122
     p = c[true]
123
     a = c[false]
123
     a = c[false]
124
     u = c[nil]
124
     u = c[nil]
125
-    return "#{p or 0}, #{a or 0}, #{u or 0}"
125
+    return "#{p || 0}, #{a || 0}, #{u || 0}"
126
   end
126
   end
127
 
127
 
128
   # Determine whether the passed Person may change this activity.
128
   # Determine whether the passed Person may change this activity.

+ 1 - 1
app/models/user.rb

30
   # Assert that the user's email address is the same as the email address of
30
   # Assert that the user's email address is the same as the email address of
31
   # the associated Person.
31
   # the associated Person.
32
   def email_same_as_person
32
   def email_same_as_person
33
-    if self.person and self.email != self.person.email
33
+    if self.person && (self.email != self.person.email)
34
       errors.add(:email, I18n.t('authentication.user_person_mail_mismatch'))
34
       errors.add(:email, I18n.t('authentication.user_person_mail_mismatch'))
35
     end
35
     end
36
   end
36
   end