rubocop-airbnb 2.0.0 → 4.0.0

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
- SHA1:
3
- metadata.gz: 8e5601cd8ff7b14b19b4bf38c802b4e1d687c322
4
- data.tar.gz: fb2fca2fe9589451f8f7a1f35ba79372b0ee5b9a
2
+ SHA256:
3
+ metadata.gz: 9d15fbaae4390350367ffaf63eb8983bfd6b3f5b20b204a84396b1e52f7f6509
4
+ data.tar.gz: eb4b2cb7e6b3fb6a347c8c8aa1d3c189a5787d14b0d59db5a5993d4fe400a299
5
5
  SHA512:
6
- metadata.gz: 2862c58fce4d1f1048df2b58e28978fcb01a943d67339dd93e4175f019cc40757deb378b86e1c2a1c241844652e6d3fff8f75876246e4153bea1da77a1f018cd
7
- data.tar.gz: 252c1280c4b61671975ff387b2b3ded22e55747b8125860ff3b37728ac6192716eb0c118db22cb34fc9ae046e5aec3d56ea74174339f1ea521f983b4f13cde0b
6
+ metadata.gz: bc207a5af59c1eecfeaba405a3a216fae0afa3b54288b35249de115b9f6c1d5036f9ae3f692823ee0a5a3af64718cd7aef072f0e6402c6c4b305b7f6f13bdd5f
7
+ data.tar.gz: e99bd2c461379d8a13f20a880b2963b0d0241d8affa7028d67cff807573ffe9fe8053bd7d8bbe65174bf0d3021dd9c7a75c4456f9dd1c58e5fe340280554d5d0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,28 @@
1
+ # 4.0.0
2
+ * Add support for Ruby 3.0
3
+ * Run CI against Ruby 2.7
4
+ * Drop support for Ruby 2.3
5
+ * Update rubocop to 0.93.1
6
+ * Update rubocop-performance to 1.10.2
7
+ * Update rubocop-rails to 2.9.1
8
+ * Update rubocop-rspec to 1.44.1
9
+ * Disable Style/BracesAroundHashParameters
10
+ * Set `DisabledByDefault: true` to disable any new rubocop cops that have not yet been evaluated for this style guide
11
+
12
+ # 3.0.2
13
+ * Moves `require`s for `rubocop-performance` and `rubocop-rails` to library code for better transitivity.
14
+
15
+ # 3.0.1
16
+ * Update supported ruby versions in gemspec
17
+
18
+ # 3.0.0
19
+ * Update to rubocop 0.76
20
+ * Enable Rails/IgnoredSkipActionFilterOption
21
+ * Enable Rails/ReflectionClassName
22
+ * Disable and delete Airbnb/ClassName
23
+ * Enable Layout/IndentFirstParameter
24
+ * Drop support for Ruby 2.2
25
+
1
26
  # 2.0.0
2
27
  * Upgrade to rubocop-rspec 1.30.0, use ~> to allow for PATCH version flexibility
3
28
  * Upgrade to rubocop 0.58.0, use ~> to allow for PATCH version flexibility
data/README.md CHANGED
@@ -15,6 +15,11 @@ Just put this in your `Gemfile` it depends on the appropriate version of rubocop
15
15
  gem 'rubocop-airbnb'
16
16
  ```
17
17
 
18
+ Note: If you want to run with Ruby 2.2 you will need to set your version to 2
19
+ ```
20
+ gem 'rubocop-airbnb', '~> 2'
21
+ ```
22
+
18
23
  ## Usage
19
24
 
20
25
  You need to tell RuboCop to load the Airbnb extension. There are three
@@ -29,7 +34,7 @@ require:
29
34
  ```
30
35
 
31
36
  Next add the following to `.rubocop.yml`
32
- or add before `.rubocop_todo.yml` in your existin `inherit_from`
37
+ or add before `.rubocop_todo.yml` in your existing `inherit_from`
33
38
 
34
39
  ```
35
40
  inherit_from:
data/config/default.yml CHANGED
@@ -24,6 +24,15 @@ AllCops:
24
24
  - spec/factories/**/*.rb
25
25
  - features/support/factories/**/*.rb
26
26
 
27
+ # While Rubocop has released a bunch of new cops, not all of these cops have been evaluated as
28
+ # part of this styleguide. To prevent new, unevaluated cops from imposing on this styleguide, we
29
+ # are marking these new cops as disabled. Note that as a consumer of this styleguide, you can
30
+ # always override any choices here by setting `Enabled: true` on any cops that you would like to
31
+ # have be enabled, even if we have explicitly disabled them (or if they are new and we have yet
32
+ # to evaluate them). For more on this configuration parameter, see
33
+ # https://github.com/rubocop/rubocop/blob/1e55b1aa5e4c5eaeccad5d61f08b7930ed6bc341/config/default.yml#L89-L101
34
+ DisabledByDefault: true
35
+
27
36
  inherit_from:
28
37
  - './rubocop-airbnb.yml'
29
38
  - './rubocop-bundler.yml'
@@ -2,11 +2,6 @@
2
2
  # They are custom built for use inside Airbnb and address issues that we have experienced in
3
3
  # testing and production.
4
4
 
5
- Airbnb/ClassName:
6
- Description: Use :class_name => "Model" instead of :class_name => Model.name
7
- to avoid a long cascade of autoloading.
8
- Enabled: true
9
-
10
5
  Airbnb/ClassOrModuleDeclaredInWrongFile:
11
6
  Description: Declare a class or module in the file that matches its namespace and name.
12
7
  Enabled: true
@@ -7,3 +7,6 @@ Gemspec/RequiredRubyVersion:
7
7
  Enabled: false
8
8
  Include:
9
9
  - '**/*.gemspec'
10
+
11
+ Gemspec/RubyVersionGlobalsUsage:
12
+ Enabled: true
@@ -11,13 +11,13 @@ Layout/AccessModifierIndentation:
11
11
  - indent
12
12
 
13
13
  # Supports --auto-correct
14
- Layout/AlignArray:
14
+ Layout/ArrayAlignment:
15
15
  Description: Align the elements of an array literal if they span more than one line.
16
16
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#align-multiline-arrays
17
17
  Enabled: true
18
18
 
19
19
  # Supports --auto-correct
20
- Layout/AlignHash:
20
+ Layout/HashAlignment:
21
21
  Description: Align the elements of a hash literal if they span more than one line.
22
22
  Enabled: true
23
23
  EnforcedHashRocketStyle: key
@@ -30,7 +30,7 @@ Layout/AlignHash:
30
30
  - ignore_explicit
31
31
 
32
32
  # Supports --auto-correct
33
- Layout/AlignParameters:
33
+ Layout/ParameterAlignment:
34
34
  Description: Align the parameters of a method call if they span more than one line.
35
35
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-double-indent
36
36
  Enabled: true
@@ -227,7 +227,7 @@ Layout/FirstMethodParameterLineBreak:
227
227
  Enabled: false
228
228
 
229
229
  # Supports --auto-correct
230
- Layout/FirstParameterIndentation:
230
+ Layout/FirstArgumentIndentation:
231
231
  Description: Checks the indentation of the first parameter in a method call.
232
232
  Enabled: true
233
233
  EnforcedStyle: consistent
@@ -238,20 +238,19 @@ Layout/FirstParameterIndentation:
238
238
  - special_for_inner_method_call_in_parentheses
239
239
 
240
240
  # Supports --auto-correct
241
- Layout/IndentArray:
241
+ Layout/FirstArrayElementIndentation:
242
242
  Description: Checks the indentation of the first element in an array literal.
243
243
  Enabled: true
244
244
  EnforcedStyle: consistent
245
245
 
246
246
  # Supports --auto-correct
247
- Layout/IndentAssignment:
247
+ Layout/AssignmentIndentation:
248
248
  Description: Checks the indentation of the first line of the right-hand-side of a
249
249
  multi-line assignment.
250
250
  Enabled: true
251
- IndentationWidth:
252
251
 
253
252
  # Supports --auto-correct
254
- Layout/IndentHash:
253
+ Layout/FirstHashElementIndentation:
255
254
  Description: Checks the indentation of the first key in a hash literal.
256
255
  Enabled: true
257
256
  EnforcedStyle: consistent
@@ -259,7 +258,7 @@ Layout/IndentHash:
259
258
  - special_inside_parentheses
260
259
  - consistent
261
260
 
262
- Layout/IndentHeredoc:
261
+ Layout/HeredocIndentation:
263
262
  Enabled: false
264
263
 
265
264
  # Supports --auto-correct
@@ -269,7 +268,7 @@ Layout/IndentationConsistency:
269
268
  EnforcedStyle: normal
270
269
  SupportedStyles:
271
270
  - normal
272
- - rails
271
+ - indented_internal_methods
273
272
 
274
273
  # Supports --auto-correct
275
274
  Layout/IndentationWidth:
@@ -283,7 +282,7 @@ Layout/InitialIndentation:
283
282
  Description: Checks the indentation of the first non-blank non-comment line in a file.
284
283
  Enabled: true
285
284
 
286
- Layout/LeadingBlankLines:
285
+ Layout/LeadingEmptyLines:
287
286
  Enabled: true
288
287
 
289
288
  # Supports --auto-correct
@@ -344,7 +343,6 @@ Layout/MultilineMethodCallIndentation:
344
343
  SupportedStyles:
345
344
  - aligned
346
345
  - indented
347
- IndentationWidth:
348
346
 
349
347
  Layout/MultilineMethodDefinitionBraceLayout:
350
348
  Description: >-
@@ -474,11 +472,6 @@ Layout/SpaceInsideBlockBraces:
474
472
  EnforcedStyleForEmptyBraces: no_space
475
473
  SpaceBeforeBlockParameters: true
476
474
 
477
- Layout/SpaceInsideParens:
478
- Description: 'No spaces after ( or before ).'
479
- StyleGuide: '#spaces-braces'
480
- Enabled: true
481
-
482
475
  Layout/SpaceInsideArrayLiteralBrackets:
483
476
  EnforcedStyle: no_space
484
477
  SupportedStyles:
@@ -538,13 +531,13 @@ Layout/SpaceInsideStringInterpolation:
538
531
  - no_space
539
532
 
540
533
  # Supports --auto-correct
541
- Layout/Tab:
534
+ Layout/IndentationStyle:
542
535
  Description: No hard tabs.
543
536
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#spaces-indentation
544
537
  Enabled: true
545
538
 
546
539
  # Supports --auto-correct
547
- Layout/TrailingBlankLines:
540
+ Layout/TrailingEmptyLines:
548
541
  Description: Checks trailing blank lines and final newline.
549
542
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#newline-eof
550
543
  Enabled: true
@@ -558,3 +551,11 @@ Layout/TrailingWhitespace:
558
551
  Description: Avoid trailing whitespace.
559
552
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-trailing-whitespace
560
553
  Enabled: true
554
+
555
+ Layout/FirstParameterIndentation:
556
+ Enabled: true
557
+
558
+ # Supports --auto-correct
559
+ Layout/LineLength:
560
+ Max: 100
561
+ AllowURI: true
@@ -45,7 +45,7 @@ Lint/DuplicateMethods:
45
45
  Description: Check for duplicate methods calls.
46
46
  Enabled: true
47
47
 
48
- Lint/DuplicatedKey:
48
+ Lint/DuplicateHashKey:
49
49
  Description: Check for duplicate keys in hash literals.
50
50
  Enabled: true
51
51
 
@@ -68,10 +68,6 @@ Lint/EmptyInterpolation:
68
68
  Lint/EmptyWhen:
69
69
  Enabled: false
70
70
 
71
- Lint/EndInMethod:
72
- Description: END blocks should not be placed inside method definitions.
73
- Enabled: false
74
-
75
71
  Lint/EnsureReturn:
76
72
  Description: Do not use return in an ensure block.
77
73
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-return-ensure
@@ -80,6 +76,11 @@ Lint/EnsureReturn:
80
76
  Lint/ErbNewArguments:
81
77
  Enabled: false
82
78
 
79
+ Lint/FlipFlop:
80
+ Description: Checks for flip flops
81
+ StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-flip-flops
82
+ Enabled: false
83
+
83
84
  Lint/FloatOutOfRange:
84
85
  Description: Catches floating-point literals too large or small for Ruby to represent.
85
86
  Enabled: false
@@ -88,7 +89,7 @@ Lint/FormatParameterMismatch:
88
89
  Description: The number of parameters to format/sprint must match the fields.
89
90
  Enabled: true
90
91
 
91
- Lint/HandleExceptions:
92
+ Lint/SuppressedException:
92
93
  Description: Don't suppress exception.
93
94
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#dont-hide-exceptions
94
95
  Enabled: false
@@ -139,7 +140,10 @@ Lint/MissingCopEnableDirective:
139
140
  Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`'
140
141
  Enabled: true
141
142
 
142
- Lint/MultipleCompare:
143
+ Lint/MissingSuper:
144
+ Enabled: false
145
+
146
+ Lint/MultipleComparison:
143
147
  Enabled: false
144
148
 
145
149
  Lint/NestedMethodDefinition:
@@ -225,7 +229,7 @@ Lint/ShadowingOuterLocalVariable:
225
229
  Enabled: true
226
230
 
227
231
  # Supports --auto-correct
228
- Lint/StringConversionInInterpolation:
232
+ Lint/RedundantStringCoercion:
229
233
  Description: Checks for Object#to_s usage in string interpolation.
230
234
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-to-s
231
235
  Enabled: true
@@ -237,20 +241,20 @@ Lint/UnderscorePrefixedVariableName:
237
241
  Lint/UnifiedInteger:
238
242
  Enabled: false
239
243
 
240
- Lint/UnneededCopDisableDirective:
244
+ Lint/RedundantCopDisableDirective:
241
245
  Description: >-
242
246
  Checks for rubocop:disable comments that can be removed.
243
247
  Note: this cop is not disabled when disabling all cops. It must be explicitly disabled.
244
248
  Enabled: true
245
249
 
246
- Lint/UnneededCopEnableDirective:
250
+ Lint/RedundantCopEnableDirective:
247
251
  Description: Checks for rubocop:enable comments that can be removed.
248
252
  Enabled: true
249
253
 
250
- Lint/UnneededRequireStatement:
254
+ Lint/RedundantRequireStatement:
251
255
  Enabled: false
252
256
 
253
- Lint/UnneededSplatExpansion:
257
+ Lint/RedundantSplatExpansion:
254
258
  Enabled: false
255
259
 
256
260
  Lint/UnreachableCode:
@@ -284,7 +288,7 @@ Lint/UselessAssignment:
284
288
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#underscore-unused-vars
285
289
  Enabled: true
286
290
 
287
- Lint/UselessComparison:
291
+ Lint/BinaryOperatorWithIdenticalOperands:
288
292
  Description: Checks for comparison of something with itself.
289
293
  Enabled: true
290
294
 
@@ -21,10 +21,6 @@ Metrics/CyclomaticComplexity:
21
21
  Enabled: false
22
22
  Max: 6
23
23
 
24
- Metrics/LineLength:
25
- Max: 100
26
- AllowURI: true
27
-
28
24
  Metrics/MethodLength:
29
25
  Enabled: false
30
26
 
@@ -55,18 +55,18 @@ Naming/PredicateName:
55
55
  - is_
56
56
  - has_
57
57
  - have_
58
- NamePrefixBlacklist:
58
+ ForbiddenPrefixes:
59
59
  - is_
60
60
  - has_
61
61
  - have_
62
62
 
63
- Naming/UncommunicativeBlockParamName:
63
+ Naming/BlockParameterName:
64
64
  Description: >-
65
65
  Checks for block parameter names that contain capital letters,
66
66
  end in numbers, or do not meet a minimal length.
67
67
  Enabled: false
68
68
 
69
- Naming/UncommunicativeMethodParamName:
69
+ Naming/MethodParameterName:
70
70
  Description: >-
71
71
  Checks for method parameter names that contain capital letters,
72
72
  end in numbers, or do not meet a minimal length.
@@ -83,3 +83,6 @@ Naming/VariableName:
83
83
 
84
84
  Naming/VariableNumber:
85
85
  Enabled: false
86
+
87
+ Naming/RescuedExceptionsVariableName:
88
+ Enabled: false
@@ -56,11 +56,6 @@ Performance/FlatMap:
56
56
  Performance/InefficientHashSearch:
57
57
  Enabled: false
58
58
 
59
- # Supports --auto-correct
60
- Performance/LstripRstrip:
61
- Description: Use `strip` instead of `lstrip.rstrip`.
62
- Enabled: false
63
-
64
59
  # Supports --auto-correct
65
60
  Performance/RangeInclude:
66
61
  Description: Use `Range#cover?` instead of `Range#include?`.
@@ -85,11 +80,6 @@ Performance/RedundantMerge:
85
80
  Reference: https://github.com/JuanitoFatas/fast-ruby#hashmerge-vs-hash-code
86
81
  Enabled: false
87
82
 
88
- # Supports --auto-correct
89
- Performance/RedundantSortBy:
90
- Description: Use `sort` instead of `sort_by { |x| x }`.
91
- Enabled: false
92
-
93
83
  Performance/RegexpMatch:
94
84
  Enabled: false
95
85
 
@@ -99,12 +89,6 @@ Performance/ReverseEach:
99
89
  Reference: https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code
100
90
  Enabled: false
101
91
 
102
- # Supports --auto-correct
103
- Performance/Sample:
104
- Description: Use `sample` instead of `shuffle.first`, `shuffle.last`, and `shuffle[Fixnum]`.
105
- Reference: https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code
106
- Enabled: false
107
-
108
92
  # Supports --auto-correct
109
93
  Performance/Size:
110
94
  Description: Use `size` instead of `count` for counting the number of elements in
@@ -133,9 +117,6 @@ Performance/TimesMap:
133
117
  Performance/UnfreezeString:
134
118
  Enabled: false
135
119
 
136
- Performance/UnneededSort:
137
- Enabled: false
138
-
139
120
  Performance/UriDefaultParser:
140
121
  Enabled: false
141
122
 
@@ -206,3 +206,13 @@ Rails/Validation:
206
206
  Enabled: false
207
207
  Include:
208
208
  - app/models/**/*.rb
209
+
210
+ Rails/IgnoredSkipActionFilterOption:
211
+ Enabled: true
212
+
213
+ Rails/ReflectionClassName:
214
+ Enabled: true
215
+
216
+ Rails/RakeEnvironment:
217
+ Description: Ensures that rake tasks depend on :environment
218
+ Enabled: false
@@ -134,16 +134,6 @@ Style/BlockDelimiters:
134
134
  - proc
135
135
  - it
136
136
 
137
- # Supports --auto-correct
138
- Style/BracesAroundHashParameters:
139
- Description: Enforce braces style around hash parameters.
140
- Enabled: false
141
- EnforcedStyle: no_braces
142
- SupportedStyles:
143
- - braces
144
- - no_braces
145
- - context_dependent
146
-
147
137
  Style/CaseEquality:
148
138
  Description: Avoid explicit use of the case equality operator(===).
149
139
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-case-equality
@@ -328,11 +318,6 @@ Style/ExpandPathArguments:
328
318
  Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
329
319
  Enabled: false
330
320
 
331
- Style/FlipFlop:
332
- Description: Checks for flip flops
333
- StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-flip-flops
334
- Enabled: false
335
-
336
321
  Style/For:
337
322
  Description: Checks use of for or each in multiline loops.
338
323
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-for-loops
@@ -360,10 +345,11 @@ Style/FrozenStringLiteralComment:
360
345
  Description: Add the frozen_string_literal comment to the top of files to help transition
361
346
  from Ruby 2.3.0 to Ruby 3.0.
362
347
  Enabled: false
363
- EnforcedStyle: when_needed
364
348
  SupportedStyles:
365
- - when_needed
366
349
  - always
350
+ - always_true
351
+ - never
352
+ EnforcedStyle: always_true
367
353
 
368
354
  Style/GlobalVars:
369
355
  Description: Do not introduce global variables.
@@ -463,9 +449,6 @@ Style/MethodDefParentheses:
463
449
  - require_parentheses
464
450
  - require_no_parentheses
465
451
 
466
- Style/MethodMissingSuper:
467
- Enabled: false
468
-
469
452
  Style/MissingRespondToMissing:
470
453
  Enabled: false
471
454
 
@@ -735,6 +718,11 @@ Style/RedundantSelf:
735
718
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-self-unless-required
736
719
  Enabled: true
737
720
 
721
+ # Supports --auto-correct
722
+ Style/RedundantSortBy:
723
+ Description: Use `sort` instead of `sort_by { |x| x }`.
724
+ Enabled: false
725
+
738
726
  # Supports --auto-correct
739
727
  Style/RegexpLiteral:
740
728
  Description: Use / or %r around regular expressions.
@@ -763,6 +751,12 @@ Style/ReturnNil:
763
751
  Style/SafeNavigation:
764
752
  Enabled: false
765
753
 
754
+ # Supports --auto-correct
755
+ Style/Sample:
756
+ Description: Use `sample` instead of `shuffle.first`, `shuffle.last`, and `shuffle[Fixnum]`.
757
+ Reference: https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code
758
+ Enabled: false
759
+
766
760
  # Supports --auto-correct
767
761
  Style/SelfAssignment:
768
762
  Description: Checks for places where self-assignment shorthand should have been used.
@@ -818,6 +812,21 @@ Style/SpecialGlobalVars:
818
812
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-cryptic-perlisms
819
813
  Enabled: true
820
814
 
815
+ Style/HashEachMethods:
816
+ Description: Enforce use of each_key and each_value Hash methods.
817
+ StyleGuide: https://docs.rubocop.org/en/latest/cops_style/#stylehasheachmethods
818
+ Enabled: false
819
+
820
+ Style/HashTransformKeys:
821
+ Description: Enforce use of transform_keys Hash methods. Not suggested for use below ruby 2.5
822
+ StyleGuide: https://docs.rubocop.org/en/latest/cops_style/#stylehashtransformkeys
823
+ Enabled: false
824
+
825
+ Style/HashTransformValues:
826
+ Description: Enforce use of transform_values Hash methods. Not suggested for use below ruby 2.5
827
+ StyleGuide: https://docs.rubocop.org/en/latest/cops_style/#stylehashtransformvalues
828
+ Enabled: false
829
+
821
830
  Style/StabbyLambdaParentheses:
822
831
  Description: Check for the usage of parentheses around stabby lambda arguments.
823
832
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#stabby-lambda-with-args
@@ -856,6 +865,11 @@ Style/StringMethods:
856
865
  PreferredMethods:
857
866
  intern: to_sym
858
867
 
868
+ # Supports --auto-correct
869
+ Style/Strip:
870
+ Description: Use `strip` instead of `lstrip.rstrip`.
871
+ Enabled: false
872
+
859
873
  Style/StructInheritance:
860
874
  Description: Checks for inheritance from Struct.new.
861
875
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-extend-struct-new
@@ -922,24 +936,27 @@ Style/UnlessElse:
922
936
  Enabled: true
923
937
 
924
938
  # Supports --auto-correct
925
- Style/UnneededCapitalW:
939
+ Style/RedundantCapitalW:
926
940
  Description: Checks for %W when interpolation is not needed.
927
941
  Enabled: false
928
942
 
929
- Style/UnneededCondition:
943
+ Style/RedundantCondition:
930
944
  Enabled: false
931
945
 
932
946
  # Supports --auto-correct
933
- Style/UnneededInterpolation:
947
+ Style/RedundantInterpolation:
934
948
  Description: Checks for strings that are just an interpolated expression.
935
949
  Enabled: false
936
950
 
937
951
  # Supports --auto-correct
938
- Style/UnneededPercentQ:
952
+ Style/RedundantPercentQ:
939
953
  Description: Checks for %q/%Q when single quotes or double quotes would do.
940
954
  StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#percent-q
941
955
  Enabled: false
942
956
 
957
+ Style/RedundantSort:
958
+ Enabled: false
959
+
943
960
  Style/UnpackFirst:
944
961
  Enabled: false
945
962
 
@@ -3,6 +3,6 @@
3
3
  module RuboCop
4
4
  module Airbnb
5
5
  # Version information for the the Airbnb RuboCop plugin.
6
- VERSION = '2.0.0'.freeze
6
+ VERSION = '4.0.0'
7
7
  end
8
8
  end
@@ -14,7 +14,7 @@ module RuboCop
14
14
  alias on_send enforce_violation
15
15
  alias on_if enforce_violation
16
16
 
17
- Util::ASGN_NODES.each do |type|
17
+ ::RuboCop::AST::Node::ASSIGNMENTS.each do |type|
18
18
  define_method("on_#{type}") do |node|
19
19
  enforce_violation(node)
20
20
  end
@@ -4,6 +4,9 @@ require 'yaml'
4
4
  # Load original rubocop gem
5
5
  require 'rubocop'
6
6
 
7
+ require 'rubocop-performance'
8
+ require 'rubocop-rails'
9
+
7
10
  require 'rubocop/airbnb'
8
11
  require 'rubocop/airbnb/inject'
9
12
  require 'rubocop/airbnb/version'
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.license = 'MIT'
16
16
  spec.version = RuboCop::Airbnb::VERSION
17
17
  spec.platform = Gem::Platform::RUBY
18
- spec.required_ruby_version = '>= 2.1'
18
+ spec.required_ruby_version = '>= 2.4'
19
19
 
20
20
  spec.require_paths = ['lib']
21
21
  spec.files = Dir[
@@ -25,7 +25,9 @@ Gem::Specification.new do |spec|
25
25
  'Gemfile',
26
26
  ]
27
27
 
28
- spec.add_dependency('rubocop', '~> 0.58.0')
29
- spec.add_dependency('rubocop-rspec', '~> 1.30.0')
28
+ spec.add_dependency('rubocop', '~> 0.93.1')
29
+ spec.add_dependency('rubocop-performance', '~> 1.10.2')
30
+ spec.add_dependency('rubocop-rails', '~> 2.9.1')
31
+ spec.add_dependency('rubocop-rspec', '~> 1.44.1')
30
32
  spec.add_development_dependency('rspec', '~> 3.5')
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-airbnb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbnb Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2021-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,28 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.58.0
19
+ version: 0.93.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.58.0
26
+ version: 0.93.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-performance
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.10.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.10.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.9.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.9.1
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rubocop-rspec
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: 1.30.0
61
+ version: 1.44.1
34
62
  type: :runtime
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: 1.30.0
68
+ version: 1.44.1
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: rspec
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -85,7 +113,6 @@ files:
85
113
  - lib/rubocop/airbnb/inject.rb
86
114
  - lib/rubocop/airbnb/rails_autoloading.rb
87
115
  - lib/rubocop/airbnb/version.rb
88
- - lib/rubocop/cop/airbnb/class_name.rb
89
116
  - lib/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file.rb
90
117
  - lib/rubocop/cop/airbnb/const_assigned_in_wrong_file.rb
91
118
  - lib/rubocop/cop/airbnb/continuation_slash.rb
@@ -105,7 +132,6 @@ files:
105
132
  - lib/rubocop/cop/airbnb/spec_constant_assignment.rb
106
133
  - lib/rubocop/cop/airbnb/unsafe_yaml_marshal.rb
107
134
  - rubocop-airbnb.gemspec
108
- - spec/rubocop/cop/airbnb/class_name_spec.rb
109
135
  - spec/rubocop/cop/airbnb/class_or_module_declared_in_wrong_file_spec.rb
110
136
  - spec/rubocop/cop/airbnb/const_assigned_in_wrong_file_spec.rb
111
137
  - spec/rubocop/cop/airbnb/continuation_slash_spec.rb
@@ -137,15 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
163
  requirements:
138
164
  - - ">="
139
165
  - !ruby/object:Gem::Version
140
- version: '2.1'
166
+ version: '2.4'
141
167
  required_rubygems_version: !ruby/object:Gem::Requirement
142
168
  requirements:
143
169
  - - ">="
144
170
  - !ruby/object:Gem::Version
145
171
  version: '0'
146
172
  requirements: []
147
- rubyforge_project:
148
- rubygems_version: 2.2.5
173
+ rubygems_version: 3.0.3
149
174
  signing_key:
150
175
  specification_version: 4
151
176
  summary: Custom code style checking for Airbnb.
@@ -1,47 +0,0 @@
1
- module RuboCop
2
- module Cop
3
- module Airbnb
4
- # Cop to prevent cross-model references, which result in a cascade of autoloads. E.g.,
5
- # belongs_to :user, :class_name => User.name
6
- class ClassName < Cop
7
- MSG = 'Use "Model" instead of Model.name at class scope to avoid cross-model references. ' \
8
- 'They cause a long cascade of autoloading, slowing down app startup and slowing down ' \
9
- 'reloading of zeus after changing a model.'.freeze
10
-
11
- # Is this a has_many, has_one, or belongs_to with a :class_name arg? Make sure the
12
- # class name is a hardcoded string. If not, add an offense and return true.
13
- def on_send(node)
14
- association_statement =
15
- node.command?(:has_many) ||
16
- node.command?(:has_one) ||
17
- node.command?(:belongs_to)
18
-
19
- return unless association_statement
20
-
21
- class_pair = class_name_node(node)
22
-
23
- if class_pair && !string_class_name?(class_pair)
24
- add_offense(class_pair)
25
- end
26
- end
27
-
28
- private
29
-
30
- # Return the descendant node that is a hash pair (:key => value) whose key
31
- # is :class_name.
32
- def class_name_node(node)
33
- node.descendants.detect do |e|
34
- e.is_a?(Parser::AST::Node) &&
35
- e.pair_type? &&
36
- e.children[0].children[0] == :class_name
37
- end
38
- end
39
-
40
- # Given a hash pair :class_name => value, is the value a hardcoded string?
41
- def string_class_name?(class_pair)
42
- class_pair.children[1].str_type?
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,78 +0,0 @@
1
- describe RuboCop::Cop::Airbnb::ClassName do
2
- subject(:cop) { described_class.new }
3
-
4
- describe "belongs_to" do
5
- it 'rejects with Model.name' do
6
- source = [
7
- 'class Coupon',
8
- ' belongs_to :user, :class_name => User.name',
9
- 'end',
10
- ].join("\n")
11
- inspect_source(source)
12
-
13
- expect(cop.offenses.size).to eq(1)
14
- expect(cop.offenses.map(&:line).sort).to eq([2])
15
- end
16
-
17
- it 'passes with "Model"' do
18
- source = [
19
- 'class Coupon',
20
- ' belongs_to :user, :class_name => "User"',
21
- 'end',
22
- ].join("\n")
23
- inspect_source(source)
24
-
25
- expect(cop.offenses).to be_empty
26
- end
27
- end
28
-
29
- describe "has_many" do
30
- it 'rejects with Model.name' do
31
- source = [
32
- 'class Coupon',
33
- ' has_many :reservations, :class_name => Reservation2.name',
34
- 'end',
35
- ].join("\n")
36
- inspect_source(source)
37
-
38
- expect(cop.offenses.size).to eq(1)
39
- expect(cop.offenses.map(&:line)).to eq([2])
40
- end
41
-
42
- it 'passes with "Model"' do
43
- source = [
44
- 'class Coupon',
45
- ' has_many :reservations, :class_name => "Reservation2"',
46
- 'end',
47
- ].join("\n")
48
- inspect_source(source)
49
-
50
- expect(cop.offenses).to be_empty
51
- end
52
- end
53
-
54
- describe "has_one" do
55
- it 'rejects with Model.name' do
56
- source = [
57
- 'class Coupon',
58
- ' has_one :loss, :class_name => Payments::Loss.name',
59
- 'end',
60
- ].join("\n")
61
- inspect_source(source)
62
-
63
- expect(cop.offenses.size).to eq(1)
64
- expect(cop.offenses.map(&:line)).to eq([2])
65
- end
66
-
67
- it 'passes with "Model"' do
68
- source = [
69
- 'class Coupon',
70
- ' has_one :loss, :class_name => "Payments::Loss"',
71
- 'end',
72
- ].join("\n")
73
- inspect_source(source)
74
-
75
- expect(cop.offenses).to be_empty
76
- end
77
- end
78
- end