rubocop 0.77.0 → 0.79.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/config/default.yml +39 -26
  4. data/lib/rubocop.rb +11 -2
  5. data/lib/rubocop/ast/builder.rb +43 -42
  6. data/lib/rubocop/ast/node/def_node.rb +11 -0
  7. data/lib/rubocop/ast/node/forward_args_node.rb +18 -0
  8. data/lib/rubocop/ast/traversal.rb +11 -3
  9. data/lib/rubocop/cli/command/auto_genenerate_config.rb +7 -7
  10. data/lib/rubocop/cli/command/show_cops.rb +11 -4
  11. data/lib/rubocop/config.rb +1 -1
  12. data/lib/rubocop/config_loader.rb +19 -19
  13. data/lib/rubocop/config_obsoletion.rb +3 -3
  14. data/lib/rubocop/config_validator.rb +55 -95
  15. data/lib/rubocop/cop/autocorrect_logic.rb +7 -4
  16. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +2 -2
  17. data/lib/rubocop/cop/cop.rb +3 -1
  18. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  19. data/lib/rubocop/cop/generator.rb +3 -4
  20. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  21. data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
  22. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -4
  23. data/lib/rubocop/cop/layout/heredoc_indentation.rb +4 -4
  24. data/lib/rubocop/cop/{metrics → layout}/line_length.rb +5 -78
  25. data/lib/rubocop/cop/layout/multiline_block_layout.rb +14 -5
  26. data/lib/rubocop/cop/layout/space_around_operators.rb +31 -6
  27. data/lib/rubocop/cop/layout/space_before_block_braces.rb +17 -0
  28. data/lib/rubocop/cop/lint/debugger.rb +2 -2
  29. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
  30. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +89 -0
  31. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -3
  32. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +4 -4
  33. data/lib/rubocop/cop/migration/department_name.rb +16 -1
  34. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  35. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -7
  36. data/lib/rubocop/cop/mixin/line_length_help.rb +88 -0
  37. data/lib/rubocop/cop/mixin/rational_literal.rb +18 -0
  38. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
  39. data/lib/rubocop/cop/mixin/trailing_comma.rb +6 -3
  40. data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
  41. data/lib/rubocop/cop/offense.rb +11 -0
  42. data/lib/rubocop/cop/registry.rb +7 -2
  43. data/lib/rubocop/cop/style/attr.rb +8 -0
  44. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
  45. data/lib/rubocop/cop/style/guard_clause.rb +3 -2
  46. data/lib/rubocop/cop/style/if_unless_modifier.rb +38 -3
  47. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  48. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +4 -207
  49. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +168 -0
  50. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
  51. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
  52. data/lib/rubocop/cop/style/multiline_when_then.rb +5 -1
  53. data/lib/rubocop/cop/style/numeric_predicate.rb +4 -3
  54. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +7 -7
  55. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +7 -1
  56. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  57. data/lib/rubocop/cop/style/yoda_condition.rb +16 -1
  58. data/lib/rubocop/formatter/base_formatter.rb +2 -2
  59. data/lib/rubocop/formatter/json_formatter.rb +6 -5
  60. data/lib/rubocop/node_pattern.rb +1 -1
  61. data/lib/rubocop/options.rb +8 -8
  62. data/lib/rubocop/result_cache.rb +2 -0
  63. data/lib/rubocop/rspec/shared_contexts.rb +5 -0
  64. data/lib/rubocop/runner.rb +5 -1
  65. data/lib/rubocop/target_ruby.rb +151 -0
  66. data/lib/rubocop/version.rb +1 -1
  67. metadata +12 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8789393bf78c1ae637e196f15a3b312a261b8239996ce92bcd99670ab358bea0
4
- data.tar.gz: 6b1e83fe89bcd3e003ea5f95307d212b3e5adce496ddc26dfe6ff92ea4dc3356
3
+ metadata.gz: 3bdc80758a1e3604ccf4fc91cedac86412bea6d234b27c9b7ae064fb364076ce
4
+ data.tar.gz: 2890ef6acaede12b528cf963cdbb8a90f64ecbcef6c5da6b3684fcf90c7d4c07
5
5
  SHA512:
6
- metadata.gz: d0a92b3b466939337e7d100d255a9c08ff7db25c235c3645ad65e878151899000749a5e20b01eda2be3ec7e4384272cfed2dce12053dd87df4b01be83453c3d9
7
- data.tar.gz: d646dad7e86dcacd75a286f70c2843934acb9a7416a40edec51fa373d9f0b3da05f74eac21ad869c24b92b550e2efb66cdf0229dc6ef2fb772edc7a7a6ee5107
6
+ metadata.gz: 8eb332a372b879708bedba857c21532665ad9b459b18977180fdc5d5ec0cb0f035968a907adfe70bd6e5688a97d9c321503d97d37e87cbf77b04168d1e071c1d
7
+ data.tar.gz: 98d0a07c70c4dca7c63cc96fb473a0079eee449d045b3543b55b90da3f1700c564d0f2ab7ccd909f63fefff7956680fd862710fabe2ccb0e9969b424b943216d
data/README.md CHANGED
@@ -53,7 +53,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
53
53
  might want to use a conservative version lock in your `Gemfile`:
54
54
 
55
55
  ```rb
56
- gem 'rubocop', '~> 0.77.0', require: false
56
+ gem 'rubocop', '~> 0.79.0', require: false
57
57
  ```
58
58
 
59
59
  ## Quickstart
@@ -59,6 +59,7 @@ AllCops:
59
59
  - '**/Vagrantfile'
60
60
  Exclude:
61
61
  - 'node_modules/**/*'
62
+ - 'tmp/**/*'
62
63
  - 'vendor/**/*'
63
64
  - '.git/**/*'
64
65
  # Default formatter will be used if no `-f/--format` option is given.
@@ -196,9 +197,10 @@ Gemspec/RequiredRubyVersion:
196
197
  VersionAdded: '0.52'
197
198
  Include:
198
199
  - '**/*.gemspec'
199
- -
200
+
200
201
  Gemspec/RubyVersionGlobalsUsage:
201
202
  Description: Checks usage of RUBY_VERSION in gemspec.
203
+ StyleGuide: '#no-ruby-version-in-the-gemspec'
202
204
  Enabled: true
203
205
  VersionAdded: '0.72'
204
206
  Include:
@@ -799,6 +801,29 @@ Layout/LeadingEmptyLines:
799
801
  VersionAdded: '0.57'
800
802
  VersionChanged: '0.77'
801
803
 
804
+ Layout/LineLength:
805
+ Description: 'Limit lines to 80 characters.'
806
+ StyleGuide: '#80-character-limits'
807
+ Enabled: true
808
+ VersionAdded: '0.25'
809
+ VersionChanged: '0.78'
810
+ AutoCorrect: false
811
+ Max: 80
812
+ # To make it possible to copy or click on URIs in the code, we allow lines
813
+ # containing a URI to be longer than Max.
814
+ AllowHeredoc: true
815
+ AllowURI: true
816
+ URISchemes:
817
+ - http
818
+ - https
819
+ # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
820
+ # directives like '# rubocop: enable ...' when calculating a line's length.
821
+ IgnoreCopDirectives: true
822
+ # The IgnoredPatterns option is a list of !ruby/regexp and/or string
823
+ # elements. Strings will be converted to Regexp objects. A line that matches
824
+ # any regular expression listed in this option will be ignored by LineLength.
825
+ IgnoredPatterns: []
826
+
802
827
  Layout/MultilineArrayBraceLayout:
803
828
  Description: >-
804
829
  Checks that the closing brace in an array literal is
@@ -1042,6 +1067,10 @@ Layout/SpaceAroundOperators:
1042
1067
  # with an operator on the previous or next line, not counting empty lines
1043
1068
  # or comment lines.
1044
1069
  AllowForAlignment: true
1070
+ EnforcedStyleForExponentOperator: no_space
1071
+ SupportedStylesForExponentOperator:
1072
+ - space
1073
+ - no_space
1045
1074
 
1046
1075
  Layout/SpaceBeforeBlockBraces:
1047
1076
  Description: >-
@@ -1471,6 +1500,12 @@ Lint/NextWithoutAccumulator:
1471
1500
  Enabled: true
1472
1501
  VersionAdded: '0.36'
1473
1502
 
1503
+ Lint/NonDeterministicRequireOrder:
1504
+ Description: 'Always sort arrays returned by Dir.glob when requiring files.'
1505
+ Enabled: true
1506
+ VersionAdded: '0.78'
1507
+ Safe: false
1508
+
1474
1509
  Lint/NonLocalExitFromIterator:
1475
1510
  Description: 'Do not use return in iterator to cause non-local exit.'
1476
1511
  Enabled: true
@@ -1809,29 +1844,6 @@ Metrics/CyclomaticComplexity:
1809
1844
  VersionAdded: '0.25'
1810
1845
  Max: 6
1811
1846
 
1812
- Metrics/LineLength:
1813
- Description: 'Limit lines to 80 characters.'
1814
- StyleGuide: '#80-character-limits'
1815
- Enabled: true
1816
- VersionAdded: '0.25'
1817
- VersionChanged: '0.68'
1818
- AutoCorrect: false
1819
- Max: 80
1820
- # To make it possible to copy or click on URIs in the code, we allow lines
1821
- # containing a URI to be longer than Max.
1822
- AllowHeredoc: true
1823
- AllowURI: true
1824
- URISchemes:
1825
- - http
1826
- - https
1827
- # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
1828
- # directives like '# rubocop: enable ...' when calculating a line's length.
1829
- IgnoreCopDirectives: true
1830
- # The IgnoredPatterns option is a list of !ruby/regexp and/or string
1831
- # elements. Strings will be converted to Regexp objects. A line that matches
1832
- # any regular expression listed in this option will be ignored by LineLength.
1833
- IgnoredPatterns: []
1834
-
1835
1847
  Metrics/MethodLength:
1836
1848
  Description: 'Avoid methods longer than 10 lines of code.'
1837
1849
  StyleGuide: '#short-methods'
@@ -2746,7 +2758,7 @@ Style/FrozenStringLiteralComment:
2746
2758
  to help transition to frozen string literals by default.
2747
2759
  Enabled: true
2748
2760
  VersionAdded: '0.36'
2749
- VersionChanged: '0.69'
2761
+ VersionChanged: '0.79'
2750
2762
  EnforcedStyle: always
2751
2763
  SupportedStyles:
2752
2764
  # `always` will always add the frozen string literal comment to a file
@@ -2757,6 +2769,7 @@ Style/FrozenStringLiteralComment:
2757
2769
  # `never` will enforce that the frozen string literal comment does not
2758
2770
  # exist in a file.
2759
2771
  - never
2772
+ Safe: false
2760
2773
 
2761
2774
  Style/GlobalVars:
2762
2775
  Description: 'Do not introduce global variables.'
@@ -3842,7 +3855,7 @@ Style/TrivialAccessors:
3842
3855
  # Commonly used in DSLs
3843
3856
  AllowDSLWriters: false
3844
3857
  IgnoreClassMethods: false
3845
- AllowedMethod:
3858
+ AllowedMethods:
3846
3859
  - to_ary
3847
3860
  - to_a
3848
3861
  - to_c
@@ -43,6 +43,7 @@ require_relative 'rubocop/ast/node/def_node'
43
43
  require_relative 'rubocop/ast/node/defined_node'
44
44
  require_relative 'rubocop/ast/node/ensure_node'
45
45
  require_relative 'rubocop/ast/node/for_node'
46
+ require_relative 'rubocop/ast/node/forward_args_node'
46
47
  require_relative 'rubocop/ast/node/float_node'
47
48
  require_relative 'rubocop/ast/node/hash_node'
48
49
  require_relative 'rubocop/ast/node/if_node'
@@ -123,6 +124,7 @@ require_relative 'rubocop/cop/mixin/ignored_pattern'
123
124
  require_relative 'rubocop/cop/mixin/ignored_methods'
124
125
  require_relative 'rubocop/cop/mixin/integer_node'
125
126
  require_relative 'rubocop/cop/mixin/interpolation'
127
+ require_relative 'rubocop/cop/mixin/line_length_help'
126
128
  require_relative 'rubocop/cop/mixin/match_range'
127
129
  require_relative 'rubocop/cop/mixin/method_complexity'
128
130
  require_relative 'rubocop/cop/mixin/method_preference'
@@ -142,6 +144,7 @@ require_relative 'rubocop/cop/mixin/percent_array'
142
144
  require_relative 'rubocop/cop/mixin/percent_literal'
143
145
  require_relative 'rubocop/cop/mixin/preceding_following_alignment'
144
146
  require_relative 'rubocop/cop/mixin/preferred_delimiters'
147
+ require_relative 'rubocop/cop/mixin/rational_literal'
145
148
  require_relative 'rubocop/cop/mixin/rescue_node'
146
149
  require_relative 'rubocop/cop/mixin/safe_assignment'
147
150
  require_relative 'rubocop/cop/mixin/space_after_punctuation'
@@ -211,7 +214,7 @@ require_relative 'rubocop/cop/layout/empty_lines_around_arguments'
211
214
  require_relative 'rubocop/cop/layout/empty_lines_around_begin_body'
212
215
  require_relative 'rubocop/cop/layout/empty_lines_around_block_body'
213
216
  require_relative 'rubocop/cop/layout/empty_lines_around_class_body'
214
- require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable Metrics/LineLength
217
+ require_relative 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords' # rubocop:disable Layout/LineLength
215
218
  require_relative 'rubocop/cop/layout/empty_lines_around_method_body'
216
219
  require_relative 'rubocop/cop/layout/empty_lines_around_module_body'
217
220
  require_relative 'rubocop/cop/layout/empty_lines'
@@ -234,6 +237,7 @@ require_relative 'rubocop/cop/layout/indentation_width'
234
237
  require_relative 'rubocop/cop/layout/initial_indentation'
235
238
  require_relative 'rubocop/cop/layout/leading_comment_space'
236
239
  require_relative 'rubocop/cop/layout/leading_empty_lines'
240
+ require_relative 'rubocop/cop/layout/line_length'
237
241
  require_relative 'rubocop/cop/layout/multiline_array_brace_layout'
238
242
  require_relative 'rubocop/cop/layout/multiline_array_line_breaks'
239
243
  require_relative 'rubocop/cop/layout/multiline_assignment_layout'
@@ -313,6 +317,7 @@ require_relative 'rubocop/cop/lint/multiple_comparison'
313
317
  require_relative 'rubocop/cop/lint/nested_method_definition'
314
318
  require_relative 'rubocop/cop/lint/nested_percent_literal'
315
319
  require_relative 'rubocop/cop/lint/next_without_accumulator'
320
+ require_relative 'rubocop/cop/lint/non_deterministic_require_order'
316
321
  require_relative 'rubocop/cop/lint/non_local_exit_from_iterator'
317
322
  require_relative 'rubocop/cop/lint/number_conversion'
318
323
  require_relative 'rubocop/cop/lint/ordered_magic_comments'
@@ -364,7 +369,6 @@ require_relative 'rubocop/cop/metrics/abc_size'
364
369
  require_relative 'rubocop/cop/metrics/block_length'
365
370
  require_relative 'rubocop/cop/metrics/block_nesting'
366
371
  require_relative 'rubocop/cop/metrics/class_length'
367
- require_relative 'rubocop/cop/metrics/line_length'
368
372
  require_relative 'rubocop/cop/metrics/method_length'
369
373
  require_relative 'rubocop/cop/metrics/module_length'
370
374
  require_relative 'rubocop/cop/metrics/parameter_lists'
@@ -456,7 +460,11 @@ require_relative 'rubocop/cop/style/lambda'
456
460
  require_relative 'rubocop/cop/style/lambda_call'
457
461
  require_relative 'rubocop/cop/style/line_end_concatenation'
458
462
  require_relative 'rubocop/cop/style/method_call_without_args_parentheses'
463
+ # rubocop:disable Layout/LineLength
459
464
  require_relative 'rubocop/cop/style/method_call_with_args_parentheses'
465
+ require_relative 'rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses'
466
+ require_relative 'rubocop/cop/style/method_call_with_args_parentheses/require_parentheses'
467
+ # rubocop:enable Layout/LineLength
460
468
  require_relative 'rubocop/cop/style/method_called_on_do_end_block'
461
469
  require_relative 'rubocop/cop/style/method_def_parentheses'
462
470
  require_relative 'rubocop/cop/style/method_missing_super'
@@ -613,4 +621,5 @@ require_relative 'rubocop/cli/command/show_cops'
613
621
  require_relative 'rubocop/cli/command/version'
614
622
  require_relative 'rubocop/options'
615
623
  require_relative 'rubocop/remote_config'
624
+ require_relative 'rubocop/target_ruby'
616
625
  require_relative 'rubocop/yaml_duplication_checker'
@@ -15,48 +15,49 @@ module RuboCop
15
15
  # root_node = parser.parse(buffer)
16
16
  class Builder < Parser::Builders::Default
17
17
  NODE_MAP = {
18
- and: AndNode,
19
- alias: AliasNode,
20
- args: ArgsNode,
21
- array: ArrayNode,
22
- block: BlockNode,
23
- break: BreakNode,
24
- case: CaseNode,
25
- class: ClassNode,
26
- def: DefNode,
27
- defined?: DefinedNode,
28
- defs: DefNode,
29
- ensure: EnsureNode,
30
- for: ForNode,
31
- float: FloatNode,
32
- hash: HashNode,
33
- if: IfNode,
34
- int: IntNode,
35
- irange: RangeNode,
36
- erange: RangeNode,
37
- kwsplat: KeywordSplatNode,
38
- module: ModuleNode,
39
- or: OrNode,
40
- pair: PairNode,
41
- regexp: RegexpNode,
42
- resbody: ResbodyNode,
43
- retry: RetryNode,
44
- return: ReturnNode,
45
- csend: SendNode,
46
- send: SendNode,
47
- str: StrNode,
48
- dstr: StrNode,
49
- xstr: StrNode,
50
- sclass: SelfClassNode,
51
- super: SuperNode,
52
- zsuper: SuperNode,
53
- sym: SymbolNode,
54
- until: UntilNode,
55
- until_post: UntilNode,
56
- when: WhenNode,
57
- while: WhileNode,
58
- while_post: WhileNode,
59
- yield: YieldNode
18
+ and: AndNode,
19
+ alias: AliasNode,
20
+ args: ArgsNode,
21
+ array: ArrayNode,
22
+ block: BlockNode,
23
+ break: BreakNode,
24
+ case: CaseNode,
25
+ class: ClassNode,
26
+ def: DefNode,
27
+ defined?: DefinedNode,
28
+ defs: DefNode,
29
+ ensure: EnsureNode,
30
+ for: ForNode,
31
+ forward_args: ForwardArgsNode,
32
+ float: FloatNode,
33
+ hash: HashNode,
34
+ if: IfNode,
35
+ int: IntNode,
36
+ irange: RangeNode,
37
+ erange: RangeNode,
38
+ kwsplat: KeywordSplatNode,
39
+ module: ModuleNode,
40
+ or: OrNode,
41
+ pair: PairNode,
42
+ regexp: RegexpNode,
43
+ resbody: ResbodyNode,
44
+ retry: RetryNode,
45
+ return: ReturnNode,
46
+ csend: SendNode,
47
+ send: SendNode,
48
+ str: StrNode,
49
+ dstr: StrNode,
50
+ xstr: StrNode,
51
+ sclass: SelfClassNode,
52
+ super: SuperNode,
53
+ zsuper: SuperNode,
54
+ sym: SymbolNode,
55
+ until: UntilNode,
56
+ until_post: UntilNode,
57
+ when: WhenNode,
58
+ while: WhileNode,
59
+ while_post: WhileNode,
60
+ yield: YieldNode
60
61
  }.freeze
61
62
 
62
63
  # Generates {Node} from the given information.
@@ -16,6 +16,17 @@ module RuboCop
16
16
  method?(:initialize) || assignment_method?
17
17
  end
18
18
 
19
+ # Checks whether this method definition node forwards its arguments
20
+ # as per the feature added in Ruby 2.7.
21
+ #
22
+ # @note This is written in a way that may support lead arguments
23
+ # which are rumored to be added in a later version of Ruby.
24
+ #
25
+ # @return [Boolean] whether the `def` node uses argument forwarding
26
+ def argument_forwarding?
27
+ arguments.any?(&:forward_args_type?)
28
+ end
29
+
19
30
  # The name of the defined method as a symbol.
20
31
  #
21
32
  # @return [Symbol] the name of the defined method
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `forward-args` nodes. This will be used in place
6
+ # of a plain node when the builder constructs the AST, making its methods
7
+ # available to all `forward-args` nodes within RuboCop.
8
+ class ForwardArgsNode < Node
9
+ include CollectionNode
10
+
11
+ # Node wraps itself in an array to be compatible with other
12
+ # enumerable argument types.
13
+ def to_a
14
+ [self]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/ModuleLength
3
4
  module RuboCop
4
5
  module AST
5
6
  # Provides methods for traversing an AST.
@@ -18,15 +19,21 @@ module RuboCop
18
19
  rational str sym regopt self lvar
19
20
  ivar cvar gvar nth_ref back_ref cbase
20
21
  arg restarg blockarg shadowarg
21
- kwrestarg zsuper lambda redo retry].freeze
22
+ kwrestarg zsuper lambda redo retry
23
+ forward_args forwarded_args
24
+ match_var match_nil_pattern].freeze
22
25
  ONE_CHILD_NODE = %i[splat kwsplat block_pass not break next
23
26
  preexe postexe match_current_line defined?
24
- arg_expr].freeze
27
+ arg_expr pin match_rest if_guard unless_guard
28
+ match_with_trailing_comma].freeze
25
29
  MANY_CHILD_NODES = %i[dstr dsym xstr regexp array hash pair
26
30
  mlhs masgn or_asgn and_asgn
27
31
  undef alias args super yield or and
28
32
  while_post until_post iflipflop eflipflop
29
- match_with_lvasgn begin kwbegin return].freeze
33
+ match_with_lvasgn begin kwbegin return
34
+ in_match case_match in_pattern match_alt
35
+ match_as array_pattern array_pattern_with_tail
36
+ hash_pattern const_pattern].freeze
30
37
  SECOND_CHILD_ONLY = %i[lvasgn ivasgn cvasgn gvasgn optarg kwarg
31
38
  kwoptarg].freeze
32
39
 
@@ -181,3 +188,4 @@ module RuboCop
181
188
  end
182
189
  end
183
190
  end
191
+ # rubocop:enable Metrics/ModuleLength
@@ -7,13 +7,13 @@ module RuboCop
7
7
  class AutoGenerateConfig < Base
8
8
  self.command_name = :auto_gen_config
9
9
 
10
- PHASE_1 = 'Phase 1 of 2: run Metrics/LineLength cop'
10
+ PHASE_1 = 'Phase 1 of 2: run Layout/LineLength cop'
11
11
  PHASE_2 = 'Phase 2 of 2: run all cops'
12
12
 
13
13
  PHASE_1_OVERRIDDEN =
14
- '(skipped because the default Metrics/LineLength:Max is overridden)'
14
+ '(skipped because the default Layout/LineLength:Max is overridden)'
15
15
  PHASE_1_DISABLED =
16
- '(skipped because Metrics/LineLength is disabled)'
16
+ '(skipped because Layout/LineLength is disabled)'
17
17
 
18
18
  def run
19
19
  add_formatter
@@ -54,15 +54,15 @@ module RuboCop
54
54
  end
55
55
 
56
56
  def line_length_cop(config)
57
- config.for_cop('Metrics/LineLength')
57
+ config.for_cop('Layout/LineLength')
58
58
  end
59
59
 
60
- # Do an initial run with only Metrics/LineLength so that cops that
61
- # depend on Metrics/LineLength:Max get the correct value for that
60
+ # Do an initial run with only Layout/LineLength so that cops that
61
+ # depend on Layout/LineLength:Max get the correct value for that
62
62
  # parameter.
63
63
  def run_line_length_cop
64
64
  puts Rainbow(PHASE_1).yellow
65
- @options[:only] = ['Metrics/LineLength']
65
+ @options[:only] = ['Layout/LineLength']
66
66
  execute_runner
67
67
  @options.delete(:only)
68
68
  @config_store = ConfigStore.new
@@ -8,6 +8,13 @@ module RuboCop
8
8
  class ShowCops < Base
9
9
  self.command_name = :show_cops
10
10
 
11
+ def initialize(env)
12
+ super
13
+
14
+ # Load the configs so the require()s are done for custom cops
15
+ @config = @config_store.for(Dir.pwd)
16
+ end
17
+
11
18
  def run
12
19
  print_available_cops
13
20
  end
@@ -15,8 +22,6 @@ module RuboCop
15
22
  private
16
23
 
17
24
  def print_available_cops
18
- # Load the configs so the require()s are done for custom cops
19
- @config_store.for(Dir.pwd)
20
25
  registry = Cop::Cop.registry
21
26
  show_all = @options[:show_cops].empty?
22
27
 
@@ -46,7 +51,9 @@ module RuboCop
46
51
 
47
52
  def print_cop_details(cops)
48
53
  cops.each do |cop|
49
- puts '# Supports --auto-correct' if cop.new.support_autocorrect?
54
+ if cop.new(@config).support_autocorrect?
55
+ puts '# Supports --auto-correct'
56
+ end
50
57
  puts "#{cop.cop_name}:"
51
58
  puts config_lines(cop)
52
59
  puts
@@ -64,7 +71,7 @@ module RuboCop
64
71
  end
65
72
 
66
73
  def config_lines(cop)
67
- cnf = @config_store.for(Dir.pwd).for_cop(cop)
74
+ cnf = @config.for_cop(cop)
68
75
  cnf.to_yaml.lines.to_a.drop(1).map { |line| ' ' + line }
69
76
  end
70
77
  end