lifen-ruby-style 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef1c5acb2037988874bbfa359309ee7a01f69c8d019721de6e10919435847183
4
- data.tar.gz: d116d8b202a31cc741e90cd836db6e63e44e71456c749529e6f1503c881dc71e
3
+ metadata.gz: 3ba4f3fcaadd0b6ea5f61d708e5bf6f0ac0dff645c5f2b729aa422bc58d7b947
4
+ data.tar.gz: 1062c0a1956bfa990498899485f45039061820d9745cac2fccdc472fdd58bddf
5
5
  SHA512:
6
- metadata.gz: d4fea74c0236cacdc3524b907410c0560dcd260d226c233474dd2658364efecf236d04b44d3c3ef8b7973451ed66b7a7d4f89dd61ebb2ebeae0e1ad3b63fbaff
7
- data.tar.gz: 833a05da049395af63154429876af4ec214cb845010fdc6029adda20a1b5649867effaeb0db162aaa2f174182a8bddd77a9c203e72814092756c58e02ba2e3d7
6
+ metadata.gz: 65b5aca85d57b98f4761e8c7c766a388d2ab55a4e1ecce7b3c8e985e0e2534ad6a9836e3ad03512e177c7bdc9aa15aa9d9d40f6f5369d8f3915e23f53300318c
7
+ data.tar.gz: c4101f3c3f72b29b935fd6c93f75d4d96af7825dc92cb7ee9e9a83f75d04be6dec57c4bba42db592d01727b4e2921a1bd67b722b0df98aa538f6b872bf089078
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @EtienneDepaulis @rouaneta
1
+ * @EtienneDepaulis @rouaneta @r3trofitted
data/README.md CHANGED
@@ -376,9 +376,9 @@ Suivre les instructions du [guide de release](RELEASING.md).
376
376
 
377
377
  ## TODO
378
378
 
379
- - [ ] Ajouter rubocop-daemon (arriver à faire une bonne intégration aux IDE)
380
- - [ ] Ajouter le hook de pre-commit au CI
381
- - [ ] Ajouter un hook de pre-push ?
379
+ - [ ] Prendre ce qu'il y a de pertinent dans le style_guide pour le mettre dans le guide de contribution Rails (Notion)
380
+ - [ ] Dans le style_guide, mettre un lien vers le guide de contribution Rails (Notion).
381
+ - [ ] Ajouter lien vers la config rubocop-daemon pour les utilisateurs de VSCode
382
382
  - [ ] Ajouter `fasterer` si pertinent
383
383
  - [ ] Ajouter `reek` si pertinent
384
384
  - [ ] Ajouter `slim_lint` si pertinent
data/default_rubocop.yml CHANGED
@@ -1617,7 +1617,7 @@ Rails/EnumUniqueness:
1617
1617
  Enabled: true
1618
1618
 
1619
1619
  Rails/EnvironmentComparison:
1620
- Enabled: true
1620
+ Enabled: false
1621
1621
 
1622
1622
  Rails/Exit:
1623
1623
  Enabled: true
@@ -1782,6 +1782,7 @@ Rails/UnknownEnv:
1782
1782
  Enabled: true
1783
1783
  Environments:
1784
1784
  - development
1785
+ - post-prod
1785
1786
  - production
1786
1787
  - review
1787
1788
  - staging
@@ -2120,7 +2121,7 @@ RSpec/VariableName:
2120
2121
  Enabled: true
2121
2122
 
2122
2123
  RSpec/VerifiedDoubles:
2123
- Enabled: true
2124
+ Enabled: false
2124
2125
 
2125
2126
  RSpec/VoidExpect:
2126
2127
  Enabled: true
@@ -2131,9 +2132,6 @@ RSpec/Yield:
2131
2132
  RSpec/Capybara/CurrentPathExpectation:
2132
2133
  Enabled: true
2133
2134
 
2134
- RSpec/Capybara/FeatureMethods:
2135
- Enabled: true
2136
-
2137
2135
  RSpec/Capybara/VisibilityMatcher:
2138
2136
  Enabled: true
2139
2137
 
@@ -3,7 +3,7 @@
3
3
  module Lifen
4
4
  module RubyStyle
5
5
 
6
- VERSION = '1.1.4'
6
+ VERSION = '1.1.5'
7
7
 
8
8
  end
9
9
  end
data/style_guide.md CHANGED
@@ -18,678 +18,3 @@ In this guide, we present the Lifen guidelines, the most important rules and the
18
18
  - Prefer using [ActiveRecord Bang (!) Methods](https://riptutorial.com/ruby-on-rails/example/9285/activerecord-bang-----methods), such as `#save!`, `#update!`, `.create!`. Careful, you must not use a Bang Method and then rescue an exception. You should prevent the app to get invalid inputs beforehand.
19
19
  - Always use `destroy!` or `destroy`. Never use `delete`, unless you know exactly why. Basically `destroy` runs any callbacks on the model while `delete` doesn't. More [info](https://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-delete).
20
20
  - Prefer `Time` over `DateTime` since it supports proper time zones instead of UTC offsets. [More info](https://gist.github.com/pixeltrix/e2298822dd89d854444b).
21
-
22
- ## RuboCop rules
23
-
24
- **All RuboCop rules are enforced by the linter: you don't have to memorize them all. This section is for documentation purposes only.**
25
-
26
- ### Custom rules
27
-
28
- All the RuboCop rules overrided by Lifen are detailed below:
29
-
30
- <details><summary>Layout</summary>
31
-
32
- #### ArgumentAlignment
33
-
34
- ```ruby
35
- # bad
36
- foo :bar,
37
- :baz
38
-
39
- # good
40
- foo :bar,
41
- :baz
42
- ```
43
-
44
- #### CaseIndentation
45
-
46
- ```ruby
47
- # bad
48
- case n
49
- when 0
50
- x * 2
51
- else
52
- y / 3
53
- end
54
-
55
- # good
56
- case n
57
- when 0
58
- x * 2
59
- else
60
- y / 3
61
- end
62
-
63
- # bad
64
- a = case n
65
- when 0
66
- x * 2
67
- else
68
- y / 3
69
- end
70
-
71
- # good
72
- a = case n
73
- when 0
74
- x * 2
75
- else
76
- y / 3
77
- end
78
- ```
79
-
80
- #### EmptyLinesAroundClassBody
81
-
82
- ```ruby
83
- # bad
84
- class Foo
85
- def bar
86
- # ...
87
- end
88
- end
89
-
90
- # good
91
- class Foo
92
-
93
- def bar
94
- # ...
95
- end
96
-
97
- end
98
- ```
99
-
100
- #### EmptyLinesAroundModuleBody
101
-
102
- ```ruby
103
- # bad
104
- module Foo
105
- def bar
106
- # ...
107
- end
108
- end
109
-
110
- # good
111
- module Foo
112
-
113
- def bar
114
- # ...
115
- end
116
-
117
- end
118
- ```
119
-
120
- #### EndAlignment
121
-
122
- ```ruby
123
- # bad
124
- variable = if true
125
- end
126
-
127
- # good
128
- variable = if true
129
- end
130
-
131
- variable =
132
- if true
133
- end
134
- ```
135
-
136
- #### FirstArgumentIndentation
137
-
138
- ```ruby
139
- # bad
140
- some_method(
141
- first_param,
142
- second_param)
143
- # good
144
- some_method(
145
- first_param,
146
- second_param
147
- )
148
-
149
- # bad
150
- foo = some_method(
151
- first_param,
152
- second_param)
153
- # good
154
- foo = some_method(
155
- first_param,
156
- second_param
157
- )
158
-
159
- # bad
160
- foo = some_method(nested_call(
161
- nested_first_param),
162
- second_param)
163
- # good
164
- foo = some_method(nested_call(
165
- nested_first_param
166
- ),
167
- second_param)
168
-
169
- # bad
170
- foo = some_method(
171
- nested_call(
172
- nested_first_param),
173
- second_param)
174
- # good
175
- foo = some_method(
176
- nested_call(
177
- nested_first_param
178
- ),
179
- second_param
180
- )
181
-
182
- # bad
183
- some_method nested_call(
184
- nested_first_param),
185
- second_param
186
- # good
187
- some_method nested_call(
188
- nested_first_param
189
- ),
190
- second_param
191
- ```
192
-
193
- #### FirstArrayElementIndentation
194
-
195
- ```ruby
196
- #bad
197
- # consistent
198
- array = [
199
- :value
200
- ]
201
- but_in_a_method_call([
202
- :its_like_this
203
- ])
204
-
205
- #good
206
- array = [
207
- :value
208
- ]
209
- and_in_a_method_call([
210
- :no_difference
211
- ])
212
- ```
213
-
214
- #### FirstHashElementIndentation
215
-
216
- ```ruby
217
- # bad
218
- hash = {
219
- key: :value
220
- }
221
- but_in_a_method_call(
222
- its_like: :this
223
- )
224
-
225
- # good
226
- hash = {
227
- key: :value
228
- }
229
- and_in_a_method_call(
230
- no: :difference
231
- )
232
- ```
233
-
234
- #### IndentationConsistency
235
-
236
- ```ruby
237
- # bad
238
- class A
239
-
240
- def test
241
- puts 'hello'
242
- puts 'world'
243
- end
244
-
245
- private
246
-
247
- def bar
248
- puts 'world'
249
- end
250
-
251
- end
252
-
253
- # good
254
- class A
255
-
256
- def test
257
- puts 'hello'
258
- puts 'world'
259
- end
260
-
261
- private
262
-
263
- def bar
264
- puts 'hello'
265
- end
266
-
267
- end
268
- ```
269
-
270
- #### LineLength
271
-
272
- Maximum of 120 characters
273
-
274
- #### MultilineMethodCallIndentation
275
-
276
- ```ruby
277
- # bad
278
- while myvariable
279
- .b
280
- # do something
281
- end
282
-
283
- # good
284
- while myvariables
285
- .b
286
- # do something
287
- end
288
-
289
- # bad
290
- def my_method
291
- my_variable
292
- .method_1
293
- .method_2
294
- end
295
-
296
- # good
297
- def my_method
298
- my_variable
299
- .method_1
300
- .method_2
301
- end
302
- ```
303
-
304
- #### ParameterAlignment
305
-
306
- ```ruby
307
- # bad
308
- def foo(bar,
309
- baz)
310
- puts bar + baz
311
- end
312
-
313
- # good
314
- def foo(bar,
315
- baz)
316
- puts bar + baz
317
- end
318
-
319
- # bad
320
- def foo(
321
- bar,
322
- baz)
323
- puts bar + baz
324
- end
325
-
326
- # good
327
- def foo(
328
- bar,
329
- baz
330
- )
331
- puts bar + baz
332
- end
333
- ```
334
-
335
- </details>
336
-
337
- <details><summary>Linting</summary>
338
-
339
- #### RescueException
340
-
341
- ```yaml
342
- Enabled: false // does not check for rescue blocks targeting the Exception class.
343
- ```
344
-
345
- ```ruby
346
- # NOT bad
347
- begin
348
- do_something
349
- rescue Exception
350
- handle_exception
351
- end
352
-
353
- # good
354
- begin
355
- do_something
356
- rescue ArgumentError
357
- handle_exception
358
- end
359
- ```
360
-
361
- </details>
362
-
363
- <details><summary>Metrics</summary>
364
-
365
- #### AbcSize
366
-
367
- ```yaml
368
- Enabled: false // does not check ABC size of methods
369
- ```
370
-
371
- #### BlockLength
372
-
373
- ```yaml
374
- Enabled: false // does not check if the length of a block exceeds some maximum value.
375
- ```
376
-
377
- #### ClassLength
378
-
379
- ```yaml
380
- Max: 250 // checks if the length of a class exceeds 250
381
- ```
382
-
383
- #### CyclomaticComplexity
384
-
385
- ```yaml
386
- Enabled: false // does not check the cyclomatic complexity
387
- ```
388
-
389
- #### MethodLength
390
-
391
- ```yaml
392
- Max: 40 // checks if the length of a method exceeds 40
393
- ```
394
-
395
- #### ModuleLength
396
-
397
- ```yaml
398
- Max: 250 // checks if the length of a module exceeds 250
399
- ```
400
-
401
- #### PerceivedComplexity
402
-
403
- ```yaml
404
- Enabled: false // does not check the perceived complexity
405
- ```
406
-
407
- </details>
408
-
409
- <details><summary>Naming</summary>
410
-
411
- #### MemoizedInstanceVariableName
412
-
413
- ```ruby
414
- # bad
415
- def foo
416
- @something ||= calculate_expensive_thing
417
- end
418
-
419
- # bad
420
- def foo
421
- @foo ||= calculate_expensive_thing
422
- end
423
-
424
- # good
425
- def foo
426
- @_foo ||= calculate_expensive_thing
427
- end
428
- ```
429
-
430
- </details>
431
-
432
- <details><summary>Style</summary>
433
-
434
- #### ClassAndModuleChildren
435
-
436
- ```yaml
437
- Enabled: false // does not check the style of children definitions at classes and modules
438
- ```
439
-
440
- ```ruby
441
- # good
442
- class Foo
443
- class Bar
444
- end
445
- end
446
- # good
447
- class Foo::Bar
448
- end
449
- ```
450
-
451
- #### Documentation
452
-
453
- ```yaml
454
- Enabled: false // does not check for missing top-level documentation of classes and modules
455
- ```
456
-
457
- ```ruby
458
- # good
459
- class Person
460
- # ...
461
- end
462
-
463
- # good
464
- # Description/Explanation of Person class
465
- class Person
466
- # ...
467
- end
468
- ```
469
-
470
- #### NumericLiterals
471
-
472
- ```ruby
473
- # bad
474
- 1000000
475
- 1_00_000
476
- 1_0000
477
- 10_000_00 # typical representation of $10,000 in cents
478
-
479
- # good
480
- 1_000_000
481
- 1000
482
- ```
483
-
484
- #### RegexpLiteral
485
-
486
- ```ruby
487
- # bad
488
- snake_case = %r{^[\dA-Z_]+$}
489
- # good
490
- snake_case = /^[\dA-Z_]+$/
491
-
492
- # bad
493
- regex = %r{
494
- foo
495
- (bar)
496
- (baz)
497
- }x
498
- # good
499
- regex = /
500
- foo
501
- (bar)
502
- (baz)
503
- /x
504
-
505
- #bad
506
- x =~ %r{home/}
507
- # good
508
- x =~ /home\//
509
- ```
510
-
511
- #### StructInheritance
512
-
513
- ```yaml
514
- Enabled: false // does not check for inheritance from Struct.new.
515
- ```
516
-
517
- ```ruby
518
- # good
519
- class Person < Struct.new(:first_name, :last_name)
520
-
521
- def age
522
- 42
523
- end
524
-
525
- end
526
-
527
- # good
528
- Person = Struct.new(:first_name, :last_name) do
529
- def age
530
- 42
531
- end
532
- end
533
- ```
534
-
535
- #### SymbolArray
536
-
537
- ```ruby
538
- # bad
539
- %i[foo bar baz]
540
-
541
- # good
542
- [:foo, :bar, :baz]
543
- ```
544
-
545
- #### WordArray
546
-
547
- ```ruby
548
- # bad
549
- %w[foo bar baz]
550
-
551
- # good
552
- ['foo', 'bar', 'baz']
553
- ```
554
-
555
- </details>
556
-
557
- <details><summary>RSpec</summary>
558
-
559
- #### AnyInstance
560
-
561
- ```yaml
562
- Enabled: false // instances can be stubbed globally.
563
- ```
564
-
565
- ```ruby
566
- # NOT bad
567
- describe MyClass do
568
- before(:each) { allow_any_instance_of(MyClass).to receive(:foo) }
569
- end
570
-
571
- # good
572
- describe MyClass do
573
- let(:my_instance) { instance_double(MyClass) }
574
-
575
- before(:each) do
576
- allow(MyClass).to receive(:new).and_return(my_instance)
577
- allow(my_instance).to receive(:foo)
578
- end
579
- end
580
-
581
- ```
582
-
583
- #### DescribedClass
584
-
585
- ```ruby
586
- # bad
587
- describe MyClass do
588
- subject { described_class.do_something }
589
- end
590
-
591
- # good
592
- describe MyClass do
593
- subject { MyClass.do_something }
594
- end
595
- ```
596
-
597
- #### ExampleLength
598
-
599
- ```yaml
600
- Enabled: false // does not check for long examples.
601
- ```
602
-
603
- #### HookArgument
604
-
605
- ```ruby
606
- # bad
607
- before(:example) do
608
- # ...
609
- end
610
-
611
- # good
612
- before do
613
- # ...
614
- end
615
-
616
- # good
617
- before(:each) do
618
- # ...
619
- end
620
- ```
621
-
622
- #### LetSetup
623
-
624
- ```yaml
625
- Enabled: false // does not check unreferenced let! calls being used for test setup
626
- ```
627
-
628
- #### MultipleExpectations
629
-
630
- ```yaml
631
- Enabled: false // does not check if examples contain too many expect calls.
632
- ```
633
-
634
- #### NestedGroups
635
-
636
- ```yaml
637
- Max: 4 // checks if nested groups does not exceed 4 levels
638
- ```
639
-
640
- #### NotToNot
641
-
642
- ```ruby
643
- # bad
644
- it '...' do
645
- expect(false).not_to be_true
646
- end
647
-
648
- # good
649
- it '...' do
650
- expect(false).to_not be_true
651
- end
652
- ```
653
-
654
- #### RepeatedDescription
655
-
656
- ```yaml
657
- Enabled: false // example groups can have the same description string.
658
- ```
659
-
660
- #### Block Delimiters
661
-
662
- ##### EnforcedStyle: braces_for_chaining
663
-
664
- ```ruby
665
- # bad
666
- words.each do |word|
667
- word.flip.flop
668
- end.join("-")
669
-
670
- # good
671
- words.each { |word|
672
- word.flip.flop
673
- }.join("-")
674
- ```
675
-
676
- </details>
677
-
678
- ### Default rules
679
-
680
- All other rules have the default configuration. They are detailed in the [RuboCop official documentation](https://docs.rubocop.org/en/stable/), in the [RSpec Extension official documentation](https://docs.rubocop.org/projects/rspec/en/stable/),in the [Performance Extension official documentation](https://docs.rubocop.org/projects/performance/en/stable/), and in the [Rails Extension official documentation](https://docs.rubocop.org/projects/rails/en/stable/).
681
-
682
- Below are documented the default RuboCop rules considered as particularly important. **They are also enforced by RuboCop!**
683
-
684
- #### Style/FrozenStringLiteralComment
685
-
686
- Freezing Strings feature improves apps performance by freezing Strings. So, Matz - Ruby’s creator - decided to make all String literals frozen (immutable) by default in Ruby 3.0.
687
-
688
- In order to have a transition path to this coming big change, we add a magic comment at the beginning of each file, which freezes strings by default:
689
-
690
- ```ruby
691
- # frozen_string_literal: true
692
- class YourClass
693
- # ...
694
- end
695
- ```
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifen-ruby-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Lifen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-10 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: overcommit
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '10.0'
125
- description:
125
+ description:
126
126
  email:
127
127
  - contact@lifen.fr
128
128
  executables: []
@@ -149,7 +149,7 @@ homepage: https://github.com/honestica/lifen-ruby-style
149
149
  licenses: []
150
150
  metadata:
151
151
  allowed_push_host: https://rubygems.org
152
- post_install_message:
152
+ post_install_message:
153
153
  rdoc_options: []
154
154
  require_paths:
155
155
  - lib
@@ -164,8 +164,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  - !ruby/object:Gem::Version
165
165
  version: '0'
166
166
  requirements: []
167
- rubygems_version: 3.1.3
168
- signing_key:
167
+ rubygems_version: 3.2.28
168
+ signing_key:
169
169
  specification_version: 4
170
170
  summary: Lifen style guides and shared style configs.
171
171
  test_files: []