Browse Source

Useless assignment, fix bug in log_out

Maarten van den Berg 6 years ago
parent
commit
3aaca27cb2
3 changed files with 17 additions and 28 deletions
  1. 0 11
      .rubocop.yml
  2. 2 2
      app/helpers/authentication_helper.rb
  3. 15 15
      db/seeds.rb

+ 0 - 11
.rubocop.yml

@@ -23,11 +23,6 @@ Lint/SafeNavigationChain:
23 23
   Exclude:
24 24
     - 'app/controllers/api_controller.rb'
25 25
 
26
-# Offense count: 4
27
-Lint/ShadowingOuterLocalVariable:
28
-  Exclude:
29
-    - 'db/seeds.rb'
30
-
31 26
 # Offense count: 2
32 27
 # Cop supports --auto-correct.
33 28
 # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
@@ -42,12 +37,6 @@ Lint/UnusedMethodArgument:
42 37
   Exclude:
43 38
     - 'app/helpers/application_helper.rb'
44 39
 
45
-# Offense count: 8
46
-Lint/UselessAssignment:
47
-  Exclude:
48
-    - 'app/helpers/authentication_helper.rb'
49
-    - 'db/seeds.rb'
50
-
51 40
 # Offense count: 30
52 41
 Metrics/AbcSize:
53 42
   Max: 71

+ 2 - 2
app/helpers/authentication_helper.rb

@@ -40,7 +40,7 @@ module AuthenticationHelper
40 40
   end
41 41
 
42 42
   # Determine whether the user is logged in, and if so, disable the Session, then flush session cookies.
43
-  def log_out(session_broken = false)
43
+  def log_out(session_broken: false)
44 44
     if !session_broken && is_logged_in? && @user_session
45 45
       get_user_session
46 46
 
@@ -104,7 +104,7 @@ module AuthenticationHelper
104 104
 
105 105
     # Edge case if a session no longer exists in the database
106 106
     if not @user_session
107
-      log_out(session_broken = true)
107
+      log_out(session_broken: true)
108 108
     end
109 109
   end
110 110
 

+ 15 - 15
db/seeds.rb

@@ -9,7 +9,7 @@ require 'byebug'
9 9
 
10 10
 exit if Rails.env.production?
11 11
 
12
-p = Person.create!(
12
+its_me = Person.create!(
13 13
   first_name: 'Maarten',
14 14
   infix: 'van den',
15 15
   last_name: 'Berg',
@@ -18,33 +18,33 @@ p = Person.create!(
18 18
   is_admin: true
19 19
 )
20 20
 
21
-u = User.create!(
21
+User.create!(
22 22
   email: 'maarten@maartenberg.nl',
23
-  person: p,
23
+  person: its_me,
24 24
   password: 'aardbei123',
25 25
   password_confirmation: 'aardbei123',
26 26
   confirmed: true
27 27
 )
28 28
 
29
-p2 = Person.create!(
29
+Person.create!(
30 30
   first_name: 'Henkie',
31 31
   last_name: 'Gekke',
32 32
   birth_date: (Faker::Date.between(21.years.ago, Date.today)),
33 33
   email: 'gekkehenkie@maartenberg.nl'
34 34
 )
35 35
 
36
-g = Group.create!(
36
+default_test_group = Group.create!(
37 37
   name: 'Teststam'
38 38
 )
39 39
 
40
-2.times do |i|
41
-  gr = Group.create!(
40
+2.times do
41
+  Group.create!(
42 42
     name: Faker::Team.name
43 43
   )
44 44
 end
45 45
 
46
-15.times do |i|
47
-  person = Person.create!(
46
+15.times do
47
+  Person.create!(
48 48
     first_name: (Faker::Name.first_name),
49 49
     last_name: (Faker::Name.last_name),
50 50
     birth_date: (Faker::Date.between(21.years.ago, Date.today)),
@@ -52,23 +52,23 @@ end
52 52
   )
53 53
 end
54 54
 
55
-a = Activity.create!(
55
+Activity.create!(
56 56
   name: 'Fikkie stoken ofzo',
57 57
   description: 'Een scout trekt er samen met anderen op uit',
58 58
   location: 'In het bos in het bos',
59 59
   start: 4.weeks.since,
60 60
   end: 4.weeks.since + 2.hours,
61 61
   deadline: 3.weeks.since,
62
-  group: g
62
+  group: default_test_group
63 63
 )
64 64
 
65 65
 Group.all.each do |g|
66
-  10.times do |i|
66
+  10.times do
67 67
     starttime = Faker::Time.between(DateTime.now, 1.years.since, :morning)
68 68
     endtime   = Faker::Time.between(1.hours.since(starttime), 1.days.since(starttime), :afternoon)
69 69
     deadline  = 5.days.ago(starttime)
70 70
 
71
-    act = Activity.create!(
71
+    Activity.create!(
72 72
       name: Faker::Hacker.ingverb,
73 73
       description: Faker::Hipster.sentence,
74 74
       location: Faker::Address.city,
@@ -84,7 +84,7 @@ end
84 84
 Person.all.each do |p|
85 85
   Group.all.each do |g|
86 86
     if Faker::Boolean.boolean(0.75)
87
-      mem = Member.create!(
87
+      Member.create!(
88 88
         person: p,
89 89
         group: g,
90 90
         is_leader: Faker::Boolean.boolean(0.1)
@@ -96,7 +96,7 @@ Person.all.each do |p|
96 96
           notes = nil
97 97
         end
98 98
 
99
-        # Participants are created on adding to group!
99
+        # Participants are created on adding to group, no need to create
100 100
         part = Participant.find_by(
101 101
           activity: a,
102 102
           person: p