rubocop 0.71.0 → 0.72.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -8
  3. data/config/default.yml +42 -484
  4. data/lib/rubocop.rb +5 -53
  5. data/lib/rubocop/ast/builder.rb +2 -0
  6. data/lib/rubocop/ast/node.rb +1 -1
  7. data/lib/rubocop/ast/node/float_node.rb +12 -0
  8. data/lib/rubocop/ast/node/int_node.rb +12 -0
  9. data/lib/rubocop/ast/node/mixin/numeric_node.rb +21 -0
  10. data/lib/rubocop/ast/node/resbody_node.rb +1 -6
  11. data/lib/rubocop/cached_data.rb +1 -1
  12. data/lib/rubocop/config.rb +34 -5
  13. data/lib/rubocop/config_loader.rb +2 -6
  14. data/lib/rubocop/config_loader_resolver.rb +0 -14
  15. data/lib/rubocop/cop/cop.rb +0 -4
  16. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +55 -0
  17. data/lib/rubocop/cop/layout/class_structure.rb +1 -1
  18. data/lib/rubocop/cop/layout/indent_first_argument.rb +6 -2
  19. data/lib/rubocop/cop/layout/indent_first_parameter.rb +7 -3
  20. data/lib/rubocop/cop/layout/indent_heredoc.rb +0 -1
  21. data/lib/rubocop/cop/layout/indentation_consistency.rb +13 -12
  22. data/lib/rubocop/cop/layout/indentation_width.rb +8 -4
  23. data/lib/rubocop/cop/lint/number_conversion.rb +1 -1
  24. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +21 -20
  25. data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
  26. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -1
  27. data/lib/rubocop/cop/style/float_division.rb +94 -0
  28. data/lib/rubocop/cop/style/format_string.rb +7 -3
  29. data/lib/rubocop/cop/style/if_inside_else.rb +42 -0
  30. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -1
  31. data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
  32. data/lib/rubocop/cop/style/ternary_parentheses.rb +12 -2
  33. data/lib/rubocop/cop/style/word_array.rb +2 -2
  34. data/lib/rubocop/cop/style/zero_length_predicate.rb +1 -1
  35. data/lib/rubocop/options.rb +0 -2
  36. data/lib/rubocop/processed_source.rb +2 -1
  37. data/lib/rubocop/rspec/cop_helper.rb +0 -1
  38. data/lib/rubocop/rspec/shared_contexts.rb +0 -17
  39. data/lib/rubocop/rspec/support.rb +0 -1
  40. data/lib/rubocop/runner.rb +0 -17
  41. data/lib/rubocop/version.rb +1 -1
  42. data/lib/rubocop/yaml_duplication_checker.rb +8 -2
  43. metadata +8 -91
  44. data/lib/rubocop/cop/mixin/target_rails_version.rb +0 -16
  45. data/lib/rubocop/cop/rails/action_filter.rb +0 -117
  46. data/lib/rubocop/cop/rails/active_record_aliases.rb +0 -48
  47. data/lib/rubocop/cop/rails/active_record_override.rb +0 -82
  48. data/lib/rubocop/cop/rails/active_support_aliases.rb +0 -69
  49. data/lib/rubocop/cop/rails/application_job.rb +0 -40
  50. data/lib/rubocop/cop/rails/application_record.rb +0 -40
  51. data/lib/rubocop/cop/rails/assert_not.rb +0 -44
  52. data/lib/rubocop/cop/rails/belongs_to.rb +0 -102
  53. data/lib/rubocop/cop/rails/blank.rb +0 -164
  54. data/lib/rubocop/cop/rails/bulk_change_table.rb +0 -289
  55. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +0 -91
  56. data/lib/rubocop/cop/rails/date.rb +0 -161
  57. data/lib/rubocop/cop/rails/delegate.rb +0 -132
  58. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +0 -37
  59. data/lib/rubocop/cop/rails/dynamic_find_by.rb +0 -91
  60. data/lib/rubocop/cop/rails/enum_uniqueness.rb +0 -45
  61. data/lib/rubocop/cop/rails/environment_comparison.rb +0 -68
  62. data/lib/rubocop/cop/rails/exit.rb +0 -67
  63. data/lib/rubocop/cop/rails/file_path.rb +0 -108
  64. data/lib/rubocop/cop/rails/find_by.rb +0 -55
  65. data/lib/rubocop/cop/rails/find_each.rb +0 -51
  66. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -25
  67. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +0 -106
  68. data/lib/rubocop/cop/rails/http_positional_arguments.rb +0 -117
  69. data/lib/rubocop/cop/rails/http_status.rb +0 -179
  70. data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +0 -94
  71. data/lib/rubocop/cop/rails/inverse_of.rb +0 -246
  72. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +0 -175
  73. data/lib/rubocop/cop/rails/link_to_blank.rb +0 -98
  74. data/lib/rubocop/cop/rails/not_null_column.rb +0 -67
  75. data/lib/rubocop/cop/rails/output.rb +0 -49
  76. data/lib/rubocop/cop/rails/output_safety.rb +0 -99
  77. data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -107
  78. data/lib/rubocop/cop/rails/presence.rb +0 -124
  79. data/lib/rubocop/cop/rails/present.rb +0 -153
  80. data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -74
  81. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +0 -111
  82. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -136
  83. data/lib/rubocop/cop/rails/reflection_class_name.rb +0 -37
  84. data/lib/rubocop/cop/rails/refute_methods.rb +0 -76
  85. data/lib/rubocop/cop/rails/relative_date_constant.rb +0 -93
  86. data/lib/rubocop/cop/rails/request_referer.rb +0 -56
  87. data/lib/rubocop/cop/rails/reversible_migration.rb +0 -286
  88. data/lib/rubocop/cop/rails/safe_navigation.rb +0 -87
  89. data/lib/rubocop/cop/rails/save_bang.rb +0 -316
  90. data/lib/rubocop/cop/rails/scope_args.rb +0 -29
  91. data/lib/rubocop/cop/rails/skips_model_validations.rb +0 -87
  92. data/lib/rubocop/cop/rails/time_zone.rb +0 -238
  93. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +0 -105
  94. data/lib/rubocop/cop/rails/unknown_env.rb +0 -63
  95. data/lib/rubocop/cop/rails/validation.rb +0 -109
  96. data/lib/rubocop/rspec/shared_examples.rb +0 -59
@@ -27,6 +27,7 @@ require_relative 'rubocop/ast/node/mixin/conditional_node'
27
27
  require_relative 'rubocop/ast/node/mixin/hash_element_node'
28
28
  require_relative 'rubocop/ast/node/mixin/method_dispatch_node'
29
29
  require_relative 'rubocop/ast/node/mixin/modifier_node'
30
+ require_relative 'rubocop/ast/node/mixin/numeric_node'
30
31
  require_relative 'rubocop/ast/node/mixin/parameterized_node'
31
32
  require_relative 'rubocop/ast/node/mixin/predicate_operator_node'
32
33
  require_relative 'rubocop/ast/node/mixin/basic_literal_node'
@@ -42,8 +43,10 @@ require_relative 'rubocop/ast/node/def_node'
42
43
  require_relative 'rubocop/ast/node/defined_node'
43
44
  require_relative 'rubocop/ast/node/ensure_node'
44
45
  require_relative 'rubocop/ast/node/for_node'
46
+ require_relative 'rubocop/ast/node/float_node'
45
47
  require_relative 'rubocop/ast/node/hash_node'
46
48
  require_relative 'rubocop/ast/node/if_node'
49
+ require_relative 'rubocop/ast/node/int_node'
47
50
  require_relative 'rubocop/ast/node/keyword_splat_node'
48
51
  require_relative 'rubocop/ast/node/module_node'
49
52
  require_relative 'rubocop/ast/node/or_node'
@@ -148,7 +151,6 @@ require_relative 'rubocop/cop/mixin/statement_modifier'
148
151
  require_relative 'rubocop/cop/mixin/string_help'
149
152
  require_relative 'rubocop/cop/mixin/string_literals_help'
150
153
  require_relative 'rubocop/cop/mixin/target_ruby_version'
151
- require_relative 'rubocop/cop/mixin/target_rails_version'
152
154
  require_relative 'rubocop/cop/mixin/too_many_lines'
153
155
  require_relative 'rubocop/cop/mixin/trailing_body'
154
156
  require_relative 'rubocop/cop/mixin/trailing_comma'
@@ -179,6 +181,7 @@ require_relative 'rubocop/cop/bundler/ordered_gems'
179
181
  require_relative 'rubocop/cop/gemspec/duplicated_assignment'
180
182
  require_relative 'rubocop/cop/gemspec/ordered_dependencies'
181
183
  require_relative 'rubocop/cop/gemspec/required_ruby_version'
184
+ require_relative 'rubocop/cop/gemspec/ruby_version_globals_usage'
182
185
 
183
186
  require_relative 'rubocop/cop/layout/access_modifier_indentation'
184
187
  require_relative 'rubocop/cop/layout/align_arguments'
@@ -425,6 +428,7 @@ require_relative 'rubocop/cop/style/end_block'
425
428
  require_relative 'rubocop/cop/style/eval_with_location'
426
429
  require_relative 'rubocop/cop/style/even_odd'
427
430
  require_relative 'rubocop/cop/style/expand_path_arguments'
431
+ require_relative 'rubocop/cop/style/float_division'
428
432
  require_relative 'rubocop/cop/style/for'
429
433
  require_relative 'rubocop/cop/style/format_string'
430
434
  require_relative 'rubocop/cop/style/format_string_token'
@@ -547,58 +551,6 @@ require_relative 'rubocop/cop/style/word_array'
547
551
  require_relative 'rubocop/cop/style/yoda_condition'
548
552
  require_relative 'rubocop/cop/style/zero_length_predicate'
549
553
 
550
- require_relative 'rubocop/cop/rails/action_filter'
551
- require_relative 'rubocop/cop/rails/active_record_aliases'
552
- require_relative 'rubocop/cop/rails/active_record_override'
553
- require_relative 'rubocop/cop/rails/active_support_aliases'
554
- require_relative 'rubocop/cop/rails/application_job'
555
- require_relative 'rubocop/cop/rails/application_record'
556
- require_relative 'rubocop/cop/rails/assert_not'
557
- require_relative 'rubocop/cop/rails/belongs_to'
558
- require_relative 'rubocop/cop/rails/blank'
559
- require_relative 'rubocop/cop/rails/bulk_change_table'
560
- require_relative 'rubocop/cop/rails/create_table_with_timestamps'
561
- require_relative 'rubocop/cop/rails/date'
562
- require_relative 'rubocop/cop/rails/delegate'
563
- require_relative 'rubocop/cop/rails/delegate_allow_blank'
564
- require_relative 'rubocop/cop/rails/dynamic_find_by'
565
- require_relative 'rubocop/cop/rails/enum_uniqueness'
566
- require_relative 'rubocop/cop/rails/environment_comparison'
567
- require_relative 'rubocop/cop/rails/exit'
568
- require_relative 'rubocop/cop/rails/file_path'
569
- require_relative 'rubocop/cop/rails/find_by'
570
- require_relative 'rubocop/cop/rails/find_each'
571
- require_relative 'rubocop/cop/rails/has_and_belongs_to_many'
572
- require_relative 'rubocop/cop/rails/has_many_or_has_one_dependent'
573
- require_relative 'rubocop/cop/rails/http_positional_arguments'
574
- require_relative 'rubocop/cop/rails/http_status'
575
- require_relative 'rubocop/cop/rails/ignored_skip_action_filter_option'
576
- require_relative 'rubocop/cop/rails/inverse_of'
577
- require_relative 'rubocop/cop/rails/lexically_scoped_action_filter'
578
- require_relative 'rubocop/cop/rails/link_to_blank'
579
- require_relative 'rubocop/cop/rails/not_null_column'
580
- require_relative 'rubocop/cop/rails/output'
581
- require_relative 'rubocop/cop/rails/output_safety'
582
- require_relative 'rubocop/cop/rails/pluralization_grammar'
583
- require_relative 'rubocop/cop/rails/presence'
584
- require_relative 'rubocop/cop/rails/present'
585
- require_relative 'rubocop/cop/rails/read_write_attribute'
586
- require_relative 'rubocop/cop/rails/redundant_allow_nil'
587
- require_relative 'rubocop/cop/rails/redundant_receiver_in_with_options'
588
- require_relative 'rubocop/cop/rails/reflection_class_name'
589
- require_relative 'rubocop/cop/rails/refute_methods'
590
- require_relative 'rubocop/cop/rails/relative_date_constant'
591
- require_relative 'rubocop/cop/rails/request_referer'
592
- require_relative 'rubocop/cop/rails/reversible_migration'
593
- require_relative 'rubocop/cop/rails/safe_navigation'
594
- require_relative 'rubocop/cop/rails/save_bang'
595
- require_relative 'rubocop/cop/rails/scope_args'
596
- require_relative 'rubocop/cop/rails/skips_model_validations'
597
- require_relative 'rubocop/cop/rails/time_zone'
598
- require_relative 'rubocop/cop/rails/uniq_before_pluck'
599
- require_relative 'rubocop/cop/rails/unknown_env'
600
- require_relative 'rubocop/cop/rails/validation'
601
-
602
554
  require_relative 'rubocop/cop/security/eval'
603
555
  require_relative 'rubocop/cop/security/json_load'
604
556
  require_relative 'rubocop/cop/security/marshal_load'
@@ -28,8 +28,10 @@ module RuboCop
28
28
  defs: DefNode,
29
29
  ensure: EnsureNode,
30
30
  for: ForNode,
31
+ float: FloatNode,
31
32
  hash: HashNode,
32
33
  if: IfNode,
34
+ int: IntNode,
33
35
  irange: RangeNode,
34
36
  erange: RangeNode,
35
37
  kwsplat: KeywordSplatNode,
@@ -405,7 +405,7 @@ module RuboCop
405
405
  receiver.send(recursive_kind) &&
406
406
  arguments.all?(&recursive_kind)
407
407
  when :begin, :pair, *OPERATOR_KEYWORDS, *COMPOSITE_LITERALS
408
- children.all?(&recursive_kind)
408
+ children.compact.all?(&recursive_kind)
409
409
  else
410
410
  send(kind_filter)
411
411
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `float` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available to
7
+ # all `float` nodes within RuboCop.
8
+ class FloatNode < Node
9
+ include NumericNode
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `int` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available to
7
+ # all `int` nodes within RuboCop.
8
+ class IntNode < Node
9
+ include NumericNode
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # Common functionality for primitive numeric nodes: `int`, `float`, ...
6
+ module NumericNode
7
+ SIGN_REGEX = /\A[+-]/.freeze
8
+
9
+ # Checks whether this is literal has a sign.
10
+ #
11
+ # @example
12
+ #
13
+ # +42
14
+ #
15
+ # @return [Boolean] whether this literal has a sign.
16
+ def sign?
17
+ source.match(SIGN_REGEX)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -17,12 +17,7 @@ module RuboCop
17
17
  #
18
18
  # @return [Node, nil] The exception variable of the `resbody`.
19
19
  def exception_variable
20
- variable = node_parts[1]
21
- return variable if variable
22
-
23
- # When resbody is an implicit rescue (i.e. `rescue e` style),
24
- # the exception variable is descendants[1].
25
- descendants[1]
20
+ node_parts[1]
26
21
  end
27
22
  end
28
23
  end
@@ -38,7 +38,7 @@ module RuboCop
38
38
  def message(offense)
39
39
  # JSON.dump will fail if the offense message contains text which is not
40
40
  # valid UTF-8
41
- offense.message.scrub
41
+ offense.message.dup.force_encoding(::Encoding::UTF_8).scrub
42
42
  end
43
43
 
44
44
  # Restore an offense object loaded from a JSON file.
@@ -229,6 +229,16 @@ module RuboCop
229
229
  }
230
230
  ].freeze
231
231
 
232
+ OBSOLETE_ENFORCED_STYLES = [
233
+ {
234
+ cop: 'Layout/IndentationConsistency',
235
+ parameter: 'EnforcedStyle',
236
+ enforced_style: 'rails',
237
+ alternative: '`EnforcedStyle: rails` has been renamed to ' \
238
+ '`EnforcedStyle: indented_internal_methods`'
239
+ }
240
+ ].freeze
241
+
232
242
  attr_reader :loaded_path
233
243
 
234
244
  def initialize(hash = {}, loaded_path = nil)
@@ -565,7 +575,8 @@ module RuboCop
565
575
  def reject_obsolete_cops_and_parameters
566
576
  messages = [
567
577
  obsolete_cops,
568
- obsolete_parameters
578
+ obsolete_parameters,
579
+ obsolete_enforced_style
569
580
  ].flatten.compact
570
581
  return if messages.empty?
571
582
 
@@ -596,17 +607,35 @@ module RuboCop
596
607
  end
597
608
  end
598
609
 
610
+ def obsolete_enforced_style
611
+ OBSOLETE_ENFORCED_STYLES.map do |params|
612
+ obsolete_enforced_style_message(params[:cop], params[:parameter],
613
+ params[:enforced_style],
614
+ params[:alternative])
615
+ end
616
+ end
617
+
618
+ def obsolete_enforced_style_message(cop, param, enforced_style, alternative)
619
+ style = self[cop]&.detect { |key, _| key.start_with?(param) }
620
+
621
+ return unless style && style[1] == enforced_style
622
+
623
+ "obsolete `#{param}: #{enforced_style}` (for #{cop}) " \
624
+ "found in #{smart_loaded_path}" \
625
+ "\n#{alternative}"
626
+ end
627
+
599
628
  def check_target_ruby
600
629
  return if KNOWN_RUBIES.include?(target_ruby_version)
601
630
 
602
631
  msg = if OBSOLETE_RUBIES.include?(target_ruby_version)
603
- "Unsupported Ruby version #{target_ruby_version} found in " \
604
- "#{target_ruby_source}. #{target_ruby_version}-compatible " \
632
+ "RuboCop found unsupported Ruby version #{target_ruby_version} " \
633
+ "in #{target_ruby_source}. #{target_ruby_version}-compatible " \
605
634
  'analysis was dropped after version ' \
606
635
  "#{OBSOLETE_RUBIES[target_ruby_version]}."
607
636
  else
608
- "Unknown Ruby version #{target_ruby_version.inspect} found in " \
609
- "#{target_ruby_source}."
637
+ 'RuboCop found unknown Ruby version ' \
638
+ "#{target_ruby_version.inspect} in #{target_ruby_source}."
610
639
  end
611
640
 
612
641
  msg += "\nSupported versions: #{KNOWN_RUBIES.join(', ')}"
@@ -144,10 +144,6 @@ module RuboCop
144
144
  puts "Added inheritance from `#{AUTO_GENERATED_FILE}` in `#{DOTFILE}`."
145
145
  end
146
146
 
147
- def required_features
148
- resolver.required_features
149
- end
150
-
151
147
  private
152
148
 
153
149
  def find_project_dotfile(target_dir)
@@ -177,8 +173,8 @@ module RuboCop
177
173
 
178
174
  def existing_configuration(config_file)
179
175
  IO.read(config_file, encoding: Encoding::UTF_8)
180
- .sub(%r{^inherit_from: *[.\/\w]+}, '')
181
- .sub(%r{^inherit_from: *(\n *- *[.\/\w]+)+}, '')
176
+ .sub(/^inherit_from: *[^\n]+/, '')
177
+ .sub(/^inherit_from: *(\n *- *[^\n]+)+/, '')
182
178
  end
183
179
 
184
180
  def write_config_file(file_name, file_string, rubocop_yml_contents)
@@ -6,17 +6,9 @@ require 'pathname'
6
6
  module RuboCop
7
7
  # A help class for ConfigLoader that handles configuration resolution.
8
8
  class ConfigLoaderResolver
9
- attr_reader :required_features
10
-
11
- def initialize
12
- @required_features = []
13
- end
14
-
15
9
  def resolve_requires(path, hash)
16
10
  config_dir = File.dirname(path)
17
11
  Array(hash.delete('require')).each do |r|
18
- @required_features << r
19
-
20
12
  if r.start_with?('.')
21
13
  require(File.join(config_dir, r))
22
14
  else
@@ -172,12 +164,6 @@ module RuboCop
172
164
  def handle_disabled_by_default(config, new_default_configuration)
173
165
  department_config = config.to_hash.reject { |cop| cop.include?('/') }
174
166
  department_config.each do |dept, dept_params|
175
- # Rails is always disabled by default and the department's Enabled flag
176
- # works like the --rails command line option, which is that when
177
- # AllCops:DisabledByDefault is true, each Rails cop must still be
178
- # explicitly mentioned in user configuration in order to be enabled.
179
- next if dept == 'Rails'
180
-
181
167
  next unless dept_params['Enabled']
182
168
 
183
169
  new_default_configuration.each do |cop, params|
@@ -48,10 +48,6 @@ module RuboCop
48
48
  registry.qualified_cop_name(name, origin)
49
49
  end
50
50
 
51
- def self.non_rails
52
- registry.without_department(:Rails)
53
- end
54
-
55
51
  def self.inherited(subclass)
56
52
  registry.enlist(subclass)
57
53
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Gemspec
6
+ # Checks that `RUBY_VERSION` constant is not used in gemspec.
7
+ # Using `RUBY_VERSION` is dangerous because value of the
8
+ # constant is determined by `rake release`.
9
+ # It's possible to have dependency based on ruby version used
10
+ # to execute `rake release` and not user's ruby version.
11
+ #
12
+ # @example
13
+ #
14
+ # # bad
15
+ # Gem::Specification.new do |spec|
16
+ # if RUBY_VERSION >= '2.5'
17
+ # spec.add_runtime_dependency 'gem_a'
18
+ # else
19
+ # spec.add_runtime_dependency 'gem_b'
20
+ # end
21
+ # end
22
+ #
23
+ # # good
24
+ # Gem::Specification.new do |spec|
25
+ # spec.add_runtime_dependency 'gem_a'
26
+ # end
27
+ #
28
+ class RubyVersionGlobalsUsage < Cop
29
+ MSG = 'Do not use `RUBY_VERSION` in gemspec file.'
30
+
31
+ def_node_matcher :ruby_version?, '(const nil? :RUBY_VERSION)'
32
+
33
+ def_node_search :gem_specification?, <<-PATTERN
34
+ (block
35
+ (send
36
+ (const
37
+ (const {cbase nil?} :Gem) :Specification) :new)
38
+ ...)
39
+ PATTERN
40
+
41
+ def on_const(node)
42
+ return unless gem_spec_with_ruby_version?(node)
43
+
44
+ add_offense(node)
45
+ end
46
+
47
+ private
48
+
49
+ def gem_spec_with_ruby_version?(node)
50
+ gem_specification?(processed_source.ast) && ruby_version?(node)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -129,7 +129,7 @@ module RuboCop
129
129
  # end
130
130
  # end
131
131
  #
132
- # @see https://github.com/rubocop-hq/ruby-style-guide#consistent-classes
132
+ # @see https://rubystyle.guide#consistent-classes
133
133
  class ClassStructure < Cop
134
134
  HUMANIZED_NODE_TYPE = {
135
135
  casgn: :constants,
@@ -4,8 +4,12 @@ module RuboCop
4
4
  module Cop
5
5
  # rubocop:disable Metrics/LineLength
6
6
  module Layout
7
- # This cop checks the indentation of the first argument in a method call
8
- # or definition.
7
+ # This cop checks the indentation of the first argument in a method call.
8
+ # Arguments after the first one are checked by Layout/AlignArguments,
9
+ # not by this cop.
10
+ #
11
+ # For indenting the first parameter of method *definitions*, check out
12
+ # Layout/IndentFirstParameter.
9
13
  #
10
14
  # @example
11
15
  #
@@ -3,9 +3,13 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Layout
6
- # This cop checks the indentation of the first parameter in a method call.
7
- # Parameters after the first one are checked by Layout/AlignParameters,
8
- # not by this cop.
6
+ # This cop checks the indentation of the first parameter in a method
7
+ # definition. Parameters after the first one are checked by
8
+ # Layout/AlignParameters, not by this cop.
9
+ #
10
+ # For indenting the first argument of method *calls*, check out
11
+ # Layout/IndentFirstArgument, which supports options related to
12
+ # nesting that are irrelevant for method *definitions*.
9
13
  #
10
14
  # @example
11
15
  #
@@ -52,7 +52,6 @@ module RuboCop
52
52
  class IndentHeredoc < Cop
53
53
  include Heredoc
54
54
  include ConfigurableEnforcedStyle
55
- include SafeMode
56
55
 
57
56
  RUBY23_TYPE_MSG = 'Use %<indentation_width>d spaces for indentation ' \
58
57
  'in a heredoc by using `<<~` instead of ' \
@@ -5,12 +5,13 @@ module RuboCop
5
5
  module Layout
6
6
  # This cop checks for inconsistent indentation.
7
7
  #
8
- # The difference between `rails` and `normal` is that the `rails` style
9
- # prescribes that in classes and modules the `protected` and `private`
10
- # modifier keywords shall be indented the same as public methods and that
11
- # protected and private members shall be indented one step more than the
12
- # modifiers. Other than that, both styles mean that entities on the same
13
- # logical depth shall have the same indentation.
8
+ # The difference between `indented_internal_methods` and `normal` is
9
+ # that the `indented_internal_methods` style prescribes that in
10
+ # classes and modules the `protected` and `private` modifier keywords
11
+ # shall be indented the same as public methods and that protected and
12
+ # private members shall be indented one step more than the modifiers.
13
+ # Other than that, both styles mean that entities on the same logical
14
+ # depth shall have the same indentation.
14
15
  #
15
16
  # @example EnforcedStyle: normal (default)
16
17
  # # bad
@@ -65,7 +66,7 @@ module RuboCop
65
66
  # end
66
67
  # end
67
68
  #
68
- # @example EnforcedStyle: rails
69
+ # @example EnforcedStyle: indented_internal_methods
69
70
  # # bad
70
71
  # class A
71
72
  # def test
@@ -166,8 +167,8 @@ module RuboCop
166
167
  end
167
168
 
168
169
  def check(node)
169
- if style == :rails
170
- check_rails_style(node)
170
+ if style == :indented_internal_methods
171
+ check_indented_internal_methods_style(node)
171
172
  else
172
173
  check_normal_style(node)
173
174
  end
@@ -180,13 +181,13 @@ module RuboCop
180
181
  )
181
182
  end
182
183
 
183
- def check_rails_style(node)
184
+ def check_indented_internal_methods_style(node)
184
185
  children_to_check = [[]]
185
186
  node.children.each do |child|
186
187
  # Modifier nodes have special indentation and will be checked by
187
188
  # the AccessModifierIndentation cop. This cop uses them as dividers
188
- # in rails mode. Then consistency is checked only within each
189
- # section delimited by a modifier node.
189
+ # in indented_internal_methods mode. Then consistency is checked
190
+ # only within each section delimited by a modifier node.
190
191
  if bare_access_modifier?(child)
191
192
  children_to_check << []
192
193
  else