Parcourir la Source

Class methods, colon method call

Maarten van den Berg il y a 6 ans
Parent
commit
1a877f7a67
4 fichiers modifiés avec 6 ajouts et 19 suppressions
  1. 0 13
      .rubocop.yml
  2. 3 3
      app/controllers/authentication_controller.rb
  3. 2 2
      app/models/session.rb
  4. 1 1
      app/models/token.rb

+ 0 - 13
.rubocop.yml

@@ -45,19 +45,6 @@ Metrics/ModuleLength:
45 45
 Metrics/PerceivedComplexity:
46 46
   Max: 13
47 47
 
48
-# Offense count: 2
49
-# Cop supports --auto-correct.
50
-Style/ClassMethods:
51
-  Exclude:
52
-    - 'app/models/session.rb'
53
-
54
-# Offense count: 4
55
-# Cop supports --auto-correct.
56
-Style/ColonMethodCall:
57
-  Exclude:
58
-    - 'app/controllers/authentication_controller.rb'
59
-    - 'app/models/token.rb'
60
-
61 48
 # Offense count: 55
62 49
 Style/Documentation:
63 50
   Enabled: false

+ 3 - 3
app/controllers/authentication_controller.rb

@@ -63,12 +63,12 @@ class AuthenticationController < ApplicationController
63 63
       user = User.new
64 64
       user.person = person
65 65
       user.email = person.email
66
-      user.password = user.password_confirmation = SecureRandom::urlsafe_base64 32
66
+      user.password = user.password_confirmation = SecureRandom.urlsafe_base64 32
67 67
       user.confirmed = false
68 68
       user.save!
69 69
     end
70 70
 
71
-    AuthenticationMailer::password_confirm_email(user).deliver_now
71
+    AuthenticationMailer.password_confirm_email(user).deliver_now
72 72
     flash_message(:success, I18n.t('authentication.emails.sent'))
73 73
     redirect_to action: 'login'
74 74
   end
@@ -84,7 +84,7 @@ class AuthenticationController < ApplicationController
84 84
       redirect_to action: 'forgotten_password_form'
85 85
       return
86 86
     end
87
-    AuthenticationMailer::password_reset_email(user).deliver_later
87
+    AuthenticationMailer.password_reset_email(user).deliver_later
88 88
     flash_message(:success, I18n.t('authentication.emails.sent'))
89 89
     redirect_to action: 'login'
90 90
   end

+ 2 - 2
app/models/session.rb

@@ -22,12 +22,12 @@ class Session < ApplicationRecord
22 22
   belongs_to :user
23 23
 
24 24
   # @return [String] a new random token.
25
-  def Session.new_token
25
+  def self.new_token
26 26
     SecureRandom.urlsafe_base64
27 27
   end
28 28
 
29 29
   # @return [String] a BCrypt digest of the given string.
30
-  def Session.digest(string)
30
+  def self.digest(string)
31 31
     cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
32 32
                                                   BCrypt::Engine.cost
33 33
     BCrypt::Password.create(string, cost: cost)

+ 1 - 1
app/models/token.rb

@@ -45,7 +45,7 @@ class Token < ApplicationRecord
45 45
   def generate_token
46 46
     candidate = nil
47 47
     loop do
48
-      candidate = SecureRandom::urlsafe_base64 32
48
+      candidate = SecureRandom.urlsafe_base64 32
49 49
       break candidate unless Token.exists?(token: candidate)
50 50
     end
51 51
     self.token = candidate