Maarten van den Berg 6 anni fa
parent
commit
14b7c18c47

+ 0 - 10
.rubocop.yml

@@ -67,16 +67,6 @@ Performance/Casecmp:
67 67
   Exclude:
68 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 70
 # Offense count: 9
81 71
 # Cop supports --auto-correct.
82 72
 # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.

+ 3 - 3
app/controllers/authentication_controller.rb

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

+ 1 - 1
app/models/activity.rb

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

+ 1 - 1
app/models/user.rb

@@ -30,7 +30,7 @@ class User < ApplicationRecord
30 30
   # Assert that the user's email address is the same as the email address of
31 31
   # the associated Person.
32 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 34
       errors.add(:email, I18n.t('authentication.user_person_mail_mismatch'))
35 35
     end
36 36
   end