Browse Source

Proper skip iteration

Maarten van den Berg 6 years ago
parent
commit
91e850c0b2
2 changed files with 22 additions and 30 deletions
  1. 0 8
      .rubocop.yml
  2. 22 22
      db/seeds.rb

+ 0 - 8
.rubocop.yml

@@ -223,14 +223,6 @@ Style/MutableConstant:
223 223
 
224 224
 # Offense count: 1
225 225
 # Cop supports --auto-correct.
226
-# Configuration parameters: EnforcedStyle, MinBodyLength.
227
-# SupportedStyles: skip_modifier_ifs, always
228
-Style/Next:
229
-  Exclude:
230
-    - 'db/seeds.rb'
231
-
232
-# Offense count: 1
233
-# Cop supports --auto-correct.
234 226
 # Configuration parameters: Strict.
235 227
 Style/NumericLiterals:
236 228
   MinDigits: 15

+ 22 - 22
db/seeds.rb

@@ -83,30 +83,30 @@ end
83 83
 
84 84
 Person.all.each do |p|
85 85
   Group.all.each do |g|
86
-    if Faker::Boolean.boolean(0.75)
87
-      Member.create!(
88
-        person: p,
89
-        group: g,
90
-        is_leader: Faker::Boolean.boolean(0.1)
91
-      )
92
-      g.activities.each do |a|
93
-        if Faker::Boolean.boolean(0.15)
94
-          notes = Faker::Hipster.sentence
95
-        else
96
-          notes = nil
97
-        end
86
+    next unless Faker::Boolean.boolean(0.75)
98 87
 
99
-        # Participants are created on adding to group, no need to create
100
-        part = Participant.find_by(
101
-          activity: a,
102
-          person: p
103
-        )
104
-        part.update!(
105
-          is_organizer: Faker::Boolean.boolean(0.1),
106
-          attending: [true, false, nil].sample,
107
-          notes: notes
108
-        )
88
+    Member.create!(
89
+      person: p,
90
+      group: g,
91
+      is_leader: Faker::Boolean.boolean(0.1)
92
+    )
93
+    g.activities.each do |a|
94
+      if Faker::Boolean.boolean(0.15)
95
+        notes = Faker::Hipster.sentence
96
+      else
97
+        notes = nil
109 98
       end
99
+
100
+      # Participants are created on adding to group, no need to create
101
+      part = Participant.find_by(
102
+        activity: a,
103
+        person: p
104
+      )
105
+      part.update!(
106
+        is_organizer: Faker::Boolean.boolean(0.1),
107
+        attending: [true, false, nil].sample,
108
+        notes: notes
109
+      )
110 110
     end
111 111
   end
112 112
 end