rubocop 0.48.1 → 0.49.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/config/default.yml +397 -357
  4. data/config/disabled.yml +29 -29
  5. data/config/enabled.yml +366 -326
  6. data/lib/rubocop.rb +85 -70
  7. data/lib/rubocop/ast/builder.rb +4 -1
  8. data/lib/rubocop/ast/node.rb +2 -2
  9. data/lib/rubocop/ast/node/and_node.rb +1 -1
  10. data/lib/rubocop/ast/node/args_node.rb +24 -0
  11. data/lib/rubocop/ast/node/block_node.rb +107 -0
  12. data/lib/rubocop/ast/node/case_node.rb +1 -1
  13. data/lib/rubocop/ast/node/ensure_node.rb +1 -1
  14. data/lib/rubocop/ast/node/for_node.rb +1 -1
  15. data/lib/rubocop/ast/node/if_node.rb +1 -1
  16. data/lib/rubocop/ast/node/mixin/parameterized_node.rb +74 -0
  17. data/lib/rubocop/ast/node/or_node.rb +1 -1
  18. data/lib/rubocop/ast/node/pair_node.rb +1 -1
  19. data/lib/rubocop/ast/node/resbody_node.rb +1 -1
  20. data/lib/rubocop/ast/node/send_node.rb +36 -57
  21. data/lib/rubocop/ast/node/super_node.rb +42 -0
  22. data/lib/rubocop/ast/node/until_node.rb +1 -1
  23. data/lib/rubocop/ast/node/when_node.rb +1 -1
  24. data/lib/rubocop/ast/node/while_node.rb +1 -1
  25. data/lib/rubocop/cli.rb +10 -0
  26. data/lib/rubocop/config.rb +23 -7
  27. data/lib/rubocop/config_loader.rb +19 -3
  28. data/lib/rubocop/cop/badge.rb +1 -1
  29. data/lib/rubocop/cop/bundler/duplicated_gem.rb +2 -2
  30. data/lib/rubocop/cop/commissioner.rb +1 -1
  31. data/lib/rubocop/cop/cop.rb +10 -0
  32. data/lib/rubocop/cop/{style → layout}/access_modifier_indentation.rb +33 -3
  33. data/lib/rubocop/cop/{style → layout}/align_array.rb +16 -1
  34. data/lib/rubocop/cop/{style → layout}/align_hash.rb +1 -1
  35. data/lib/rubocop/cop/{style → layout}/align_parameters.rb +29 -1
  36. data/lib/rubocop/cop/{style → layout}/block_end_newline.rb +10 -5
  37. data/lib/rubocop/cop/{style → layout}/case_indentation.rb +64 -1
  38. data/lib/rubocop/cop/{style → layout}/closing_parenthesis_indentation.rb +2 -2
  39. data/lib/rubocop/cop/{style → layout}/comment_indentation.rb +1 -1
  40. data/lib/rubocop/cop/{style → layout}/dot_position.rb +1 -1
  41. data/lib/rubocop/cop/{style → layout}/else_alignment.rb +1 -1
  42. data/lib/rubocop/cop/{style → layout}/empty_line_after_magic_comment.rb +1 -1
  43. data/lib/rubocop/cop/{style → layout}/empty_line_between_defs.rb +1 -1
  44. data/lib/rubocop/cop/{style → layout}/empty_lines.rb +1 -1
  45. data/lib/rubocop/cop/{style → layout}/empty_lines_around_access_modifier.rb +2 -7
  46. data/lib/rubocop/cop/{style → layout}/empty_lines_around_begin_body.rb +1 -1
  47. data/lib/rubocop/cop/{style → layout}/empty_lines_around_block_body.rb +2 -4
  48. data/lib/rubocop/cop/{style → layout}/empty_lines_around_class_body.rb +1 -1
  49. data/lib/rubocop/cop/{style → layout}/empty_lines_around_exception_handling_keywords.rb +1 -1
  50. data/lib/rubocop/cop/{style → layout}/empty_lines_around_method_body.rb +1 -1
  51. data/lib/rubocop/cop/{style → layout}/empty_lines_around_module_body.rb +1 -1
  52. data/lib/rubocop/cop/{style → layout}/end_of_line.rb +1 -1
  53. data/lib/rubocop/cop/{style → layout}/extra_spacing.rb +1 -1
  54. data/lib/rubocop/cop/{style → layout}/first_array_element_line_break.rb +1 -1
  55. data/lib/rubocop/cop/{style → layout}/first_hash_element_line_break.rb +1 -1
  56. data/lib/rubocop/cop/{style → layout}/first_method_argument_line_break.rb +1 -1
  57. data/lib/rubocop/cop/{style → layout}/first_method_parameter_line_break.rb +1 -1
  58. data/lib/rubocop/cop/{style → layout}/first_parameter_indentation.rb +1 -1
  59. data/lib/rubocop/cop/{style → layout}/indent_array.rb +1 -1
  60. data/lib/rubocop/cop/{style → layout}/indent_assignment.rb +1 -1
  61. data/lib/rubocop/cop/{style → layout}/indent_hash.rb +2 -2
  62. data/lib/rubocop/cop/{style → layout}/indent_heredoc.rb +3 -3
  63. data/lib/rubocop/cop/{style → layout}/indentation_consistency.rb +1 -1
  64. data/lib/rubocop/cop/{style → layout}/indentation_width.rb +10 -12
  65. data/lib/rubocop/cop/{style → layout}/initial_indentation.rb +1 -1
  66. data/lib/rubocop/cop/{style → layout}/leading_comment_space.rb +1 -1
  67. data/lib/rubocop/cop/{style → layout}/multiline_array_brace_layout.rb +1 -1
  68. data/lib/rubocop/cop/{style → layout}/multiline_assignment_layout.rb +1 -1
  69. data/lib/rubocop/cop/{style → layout}/multiline_block_layout.rb +21 -36
  70. data/lib/rubocop/cop/{style → layout}/multiline_hash_brace_layout.rb +5 -1
  71. data/lib/rubocop/cop/{style → layout}/multiline_method_call_brace_layout.rb +1 -1
  72. data/lib/rubocop/cop/{style → layout}/multiline_method_call_indentation.rb +3 -3
  73. data/lib/rubocop/cop/{style → layout}/multiline_method_definition_brace_layout.rb +1 -1
  74. data/lib/rubocop/cop/{style → layout}/multiline_operation_indentation.rb +6 -5
  75. data/lib/rubocop/cop/{style → layout}/rescue_ensure_alignment.rb +1 -1
  76. data/lib/rubocop/cop/{style → layout}/space_after_colon.rb +2 -2
  77. data/lib/rubocop/cop/{style → layout}/space_after_comma.rb +2 -2
  78. data/lib/rubocop/cop/{style → layout}/space_after_method_name.rb +1 -1
  79. data/lib/rubocop/cop/{style → layout}/space_after_not.rb +1 -1
  80. data/lib/rubocop/cop/{style → layout}/space_after_semicolon.rb +2 -2
  81. data/lib/rubocop/cop/{style → layout}/space_around_block_parameters.rb +7 -5
  82. data/lib/rubocop/cop/{style → layout}/space_around_equals_in_parameter_default.rb +1 -1
  83. data/lib/rubocop/cop/{style → layout}/space_around_keyword.rb +1 -1
  84. data/lib/rubocop/cop/{style → layout}/space_around_operators.rb +6 -2
  85. data/lib/rubocop/cop/{style → layout}/space_before_block_braces.rb +6 -2
  86. data/lib/rubocop/cop/{style → layout}/space_before_comma.rb +1 -1
  87. data/lib/rubocop/cop/{style → layout}/space_before_comment.rb +1 -1
  88. data/lib/rubocop/cop/{style → layout}/space_before_first_arg.rb +4 -2
  89. data/lib/rubocop/cop/{style → layout}/space_before_semicolon.rb +1 -1
  90. data/lib/rubocop/cop/{style → layout}/space_in_lambda_literal.rb +1 -1
  91. data/lib/rubocop/cop/{style → layout}/space_inside_array_percent_literal.rb +1 -1
  92. data/lib/rubocop/cop/{style → layout}/space_inside_block_braces.rb +3 -4
  93. data/lib/rubocop/cop/{style → layout}/space_inside_brackets.rb +1 -1
  94. data/lib/rubocop/cop/{style → layout}/space_inside_hash_literal_braces.rb +1 -1
  95. data/lib/rubocop/cop/{style → layout}/space_inside_parens.rb +1 -1
  96. data/lib/rubocop/cop/{style → layout}/space_inside_percent_literal_delimiters.rb +8 -7
  97. data/lib/rubocop/cop/{style → layout}/space_inside_range_literal.rb +1 -1
  98. data/lib/rubocop/cop/{style → layout}/space_inside_string_interpolation.rb +1 -1
  99. data/lib/rubocop/cop/{style → layout}/tab.rb +1 -1
  100. data/lib/rubocop/cop/{style → layout}/trailing_blank_lines.rb +1 -1
  101. data/lib/rubocop/cop/{style → layout}/trailing_whitespace.rb +2 -2
  102. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  103. data/lib/rubocop/cop/lint/ambiguous_operator.rb +4 -4
  104. data/lib/rubocop/cop/lint/debugger.rb +0 -15
  105. data/lib/rubocop/cop/lint/duplicate_methods.rb +2 -1
  106. data/lib/rubocop/cop/lint/rescue_type.rb +81 -0
  107. data/lib/rubocop/cop/lint/script_permission.rb +42 -0
  108. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
  109. data/lib/rubocop/cop/message_annotator.rb +23 -13
  110. data/lib/rubocop/cop/metrics/block_length.rb +1 -1
  111. data/lib/rubocop/cop/mixin/array_min_size.rb +59 -0
  112. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +10 -11
  113. data/lib/rubocop/cop/mixin/def_node.rb +1 -1
  114. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +1 -1
  115. data/lib/rubocop/cop/mixin/enforce_superclass.rb +36 -0
  116. data/lib/rubocop/cop/mixin/hash_alignment.rb +1 -1
  117. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +7 -3
  118. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  119. data/lib/rubocop/cop/performance/caller.rb +41 -0
  120. data/lib/rubocop/cop/performance/compare_with_block.rb +60 -14
  121. data/lib/rubocop/cop/performance/double_start_end_with.rb +2 -2
  122. data/lib/rubocop/cop/performance/redundant_merge.rb +2 -0
  123. data/lib/rubocop/cop/rails/action_filter.rb +1 -3
  124. data/lib/rubocop/cop/rails/application_job.rb +32 -0
  125. data/lib/rubocop/cop/rails/application_record.rb +32 -0
  126. data/lib/rubocop/cop/rails/blank.rb +9 -3
  127. data/lib/rubocop/cop/rails/output_safety.rb +59 -15
  128. data/lib/rubocop/cop/rails/present.rb +9 -3
  129. data/lib/rubocop/cop/rails/relative_date_constant.rb +35 -4
  130. data/lib/rubocop/cop/rails/reversible_migration.rb +82 -18
  131. data/lib/rubocop/cop/rails/save_bang.rb +7 -2
  132. data/lib/rubocop/cop/rails/skips_model_validations.rb +7 -0
  133. data/lib/rubocop/cop/registry.rb +4 -3
  134. data/lib/rubocop/cop/security/eval.rb +9 -3
  135. data/lib/rubocop/cop/style/and_or.rb +1 -1
  136. data/lib/rubocop/cop/style/block_delimiters.rb +11 -17
  137. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
  138. data/lib/rubocop/cop/style/collection_methods.rb +1 -3
  139. data/lib/rubocop/cop/style/conditional_assignment.rb +1 -1
  140. data/lib/rubocop/cop/style/copyright.rb +2 -2
  141. data/lib/rubocop/cop/style/documentation_method.rb +1 -1
  142. data/lib/rubocop/cop/style/each_for_simple_loop.rb +2 -1
  143. data/lib/rubocop/cop/style/each_with_object.rb +10 -6
  144. data/lib/rubocop/cop/style/empty_case_condition.rb +2 -2
  145. data/lib/rubocop/cop/style/for.rb +4 -5
  146. data/lib/rubocop/cop/style/format_string.rb +49 -0
  147. data/lib/rubocop/cop/style/format_string_token.rb +141 -0
  148. data/lib/rubocop/cop/style/hash_syntax.rb +1 -1
  149. data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -2
  150. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -1
  151. data/lib/rubocop/cop/style/inverse_methods.rb +10 -1
  152. data/lib/rubocop/cop/style/lambda.rb +9 -9
  153. data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -0
  154. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -3
  155. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -2
  156. data/lib/rubocop/cop/style/method_name.rb +8 -2
  157. data/lib/rubocop/cop/style/mixin_grouping.rb +41 -3
  158. data/lib/rubocop/cop/style/multiline_block_chain.rb +7 -11
  159. data/lib/rubocop/cop/style/multiple_comparison.rb +77 -0
  160. data/lib/rubocop/cop/style/next.rb +11 -22
  161. data/lib/rubocop/cop/style/parallel_assignment.rb +10 -19
  162. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +2 -2
  163. data/lib/rubocop/cop/style/self_assignment.rb +4 -0
  164. data/lib/rubocop/cop/style/single_line_block_params.rb +23 -17
  165. data/lib/rubocop/cop/style/symbol_array.rb +24 -13
  166. data/lib/rubocop/cop/style/symbol_proc.rb +4 -0
  167. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  168. data/lib/rubocop/cop/style/unneeded_interpolation.rb +4 -0
  169. data/lib/rubocop/cop/style/word_array.rb +33 -53
  170. data/lib/rubocop/cop/style/yoda_condition.rb +78 -0
  171. data/lib/rubocop/cop/team.rb +1 -14
  172. data/lib/rubocop/cop/util.rb +16 -0
  173. data/lib/rubocop/formatter/simple_text_formatter.rb +0 -11
  174. data/lib/rubocop/node_pattern.rb +52 -52
  175. data/lib/rubocop/options.rb +25 -0
  176. data/lib/rubocop/path_util.rb +17 -1
  177. data/lib/rubocop/result_cache.rb +8 -7
  178. data/lib/rubocop/rspec/expect_offense.rb +167 -0
  179. data/lib/rubocop/rspec/shared_examples.rb +0 -8
  180. data/lib/rubocop/rspec/support.rb +1 -0
  181. data/lib/rubocop/runner.rb +12 -2
  182. data/lib/rubocop/target_finder.rb +5 -0
  183. data/lib/rubocop/version.rb +1 -1
  184. metadata +101 -72
@@ -5,7 +5,7 @@ module RuboCop
5
5
  # Identifier of all cops containing a department and cop name.
6
6
  #
7
7
  # All cops are identified by their badge. For example, the badge
8
- # for `RuboCop::Cop::Style::Tab` is `Style/Tab`. Badges can be
8
+ # for `RuboCop::Cop::Layout::Tab` is `Layout/Tab`. Badges can be
9
9
  # parsed as either `Department/CopName` or just `CopName` to allow
10
10
  # for badge references in source files that omit the department
11
11
  # for RuboCop to infer.
@@ -54,13 +54,13 @@ module RuboCop
54
54
  .values
55
55
  end
56
56
 
57
- def register_offense(node, gem_name, line_of_first_occurence)
57
+ def register_offense(node, gem_name, line_of_first_occurrence)
58
58
  line_range = node.loc.column...node.loc.last_column
59
59
 
60
60
  add_offense(
61
61
  node,
62
62
  source_range(processed_source.buffer, node.loc.line, line_range),
63
- format(MSG, gem_name, line_of_first_occurence)
63
+ format(MSG, gem_name, line_of_first_occurrence)
64
64
  )
65
65
  end
66
66
  end
@@ -34,7 +34,7 @@ module RuboCop
34
34
 
35
35
  callback_methods.each do |callback|
36
36
  next unless method_defined?(callback)
37
- class_eval <<-EOS, __FILE__, __LINE__
37
+ class_eval <<-EOS, __FILE__, __LINE__ + 1
38
38
  def #{callback}(node)
39
39
  @callbacks[:"#{callback}"] ||= @cops.select do |cop|
40
40
  cop.respond_to?(:"#{callback}")
@@ -81,6 +81,16 @@ module RuboCop
81
81
  given_names.include?(department.to_s)
82
82
  end
83
83
 
84
+ # List of cops that should not try to autocorrect at the same
85
+ # time as this cop
86
+ #
87
+ # @return [Array<RuboCop::Cop::Cop>]
88
+ #
89
+ # @api public
90
+ def self.autocorrect_incompatible_with
91
+ []
92
+ end
93
+
84
94
  def initialize(config = nil, options = nil)
85
95
  @config = config || Config.new
86
96
  @options = options || { debug: false }
@@ -2,9 +2,38 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Modifiers should be indented as deep as method definitions, or as deep
7
7
  # as the class/module keyword, depending on configuration.
8
+ #
9
+ # @example
10
+ # # EnforcedStyle: indent (default)
11
+ #
12
+ # # bad
13
+ # class Plumbus
14
+ # private
15
+ # def smooth; end
16
+ # end
17
+ #
18
+ # # good
19
+ # class Plumbus
20
+ # private
21
+ # def smooth; end
22
+ # end
23
+ #
24
+ # # EnforcedStyle: outdent
25
+ #
26
+ # # bad
27
+ # class Plumbus
28
+ # private
29
+ # def smooth; end
30
+ # end
31
+ #
32
+ # # good
33
+ # class Plumbus
34
+ # private
35
+ # def smooth; end
36
+ # end
8
37
  class AccessModifierIndentation < Cop
9
38
  include AutocorrectAlignment
10
39
  include ConfigurableEnforcedStyle
@@ -28,8 +57,9 @@ module RuboCop
28
57
  end
29
58
 
30
59
  def on_block(node)
31
- _method, _args, body = *node
32
- check_body(body, node) if node.class_constructor?
60
+ return unless node.class_constructor?
61
+
62
+ check_body(node.body, node)
33
63
  end
34
64
 
35
65
  private
@@ -2,9 +2,24 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Here we check if the elements of a multi-line array literal are
7
7
  # aligned.
8
+ #
9
+ # @example
10
+ # # bad
11
+ # a = [1, 2, 3
12
+ # 4, 5, 6]
13
+ # array = ['run',
14
+ # 'forrest',
15
+ # 'run']
16
+ #
17
+ # # good
18
+ # a = [1, 2, 3
19
+ # 4, 5, 6]
20
+ # a = ['run',
21
+ # 'forrest',
22
+ # 'run']
8
23
  class AlignArray < Cop
9
24
  include AutocorrectAlignment
10
25
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Check that the keys, separators, and values of a multi-line hash
7
7
  # literal are aligned according to configuration. The configuration
8
8
  # options are:
@@ -2,9 +2,37 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Here we check if the parameters on a multi-line method call or
7
7
  # definition are aligned.
8
+ #
9
+ # @example
10
+ #
11
+ # # EnforcedStyle: with_first_parameter
12
+ #
13
+ # # good
14
+ #
15
+ # foo :bar,
16
+ # :baz
17
+ #
18
+ # # bad
19
+ #
20
+ # foo :bar,
21
+ # :baz
22
+ #
23
+ # @example
24
+ #
25
+ # # EnforcedStyle: with_fixed_indentation
26
+ #
27
+ # # good
28
+ #
29
+ # foo :bar,
30
+ # :baz
31
+ #
32
+ # # bad
33
+ #
34
+ # foo :bar,
35
+ # :baz
8
36
  class AlignParameters < Cop
9
37
  include AutocorrectAlignment
10
38
  include OnMethodDef
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cop checks whether the end statement of a do..end block
7
7
  # is on its own line.
8
8
  #
@@ -28,17 +28,18 @@ module RuboCop
28
28
  MSG = 'Expression at %d, %d should be on its own line.'.freeze
29
29
 
30
30
  def on_block(node)
31
+ return if node.single_line?
32
+
31
33
  end_loc = node.loc.end
32
- do_loc = node.loc.begin # Actually it's either do or {.
33
- return if do_loc.line == end_loc.line # Ignore one-liners.
34
34
 
35
35
  # If the end is on its own line, there is no offense
36
36
  return if end_loc.source_line =~ /^\s*#{end_loc.source}/
37
37
 
38
- msg = format(MSG, end_loc.line, end_loc.column + 1)
39
- add_offense(node, end_loc, msg)
38
+ add_offense(node, end_loc)
40
39
  end
41
40
 
41
+ private
42
+
42
43
  def autocorrect(node)
43
44
  lambda do |corrector|
44
45
  indentation = indentation_of_block_start_line(node)
@@ -46,6 +47,10 @@ module RuboCop
46
47
  end
47
48
  end
48
49
 
50
+ def message(node)
51
+ format(MSG, node.loc.end.line, node.loc.end.column + 1)
52
+ end
53
+
49
54
  def indentation_of_block_start_line(node)
50
55
  match = /\S.*/.match(node.loc.begin.source_line)
51
56
  match.begin(0)
@@ -2,11 +2,74 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cop checks how the *when*s of a *case* expression
7
7
  # are indented in relation to its *case* or *end* keyword.
8
8
  #
9
9
  # It will register a separate offense for each misaligned *when*.
10
+ #
11
+ # @example
12
+ # # If Layout/EndAlignment is set to keyword style (default)
13
+ # # *case* and *end* should always be aligned to same depth,
14
+ # # and therefore *when* should always be aligned to both -
15
+ # # regardless of configuration.
16
+ #
17
+ # # bad for all styles
18
+ # case n
19
+ # when 0
20
+ # x * 2
21
+ # else
22
+ # y / 3
23
+ # end
24
+ #
25
+ # # good for all styles
26
+ # case n
27
+ # when 0
28
+ # x * 2
29
+ # else
30
+ # y / 3
31
+ # end
32
+ #
33
+ # @example
34
+ # # if EndAlignment is set to other style such as
35
+ # # start_of_line (as shown below), then *when* alignment
36
+ # # configuration does have an effect.
37
+ #
38
+ # # EnforcedStyle: case (default)
39
+ #
40
+ # # bad
41
+ # a = case n
42
+ # when 0
43
+ # x * 2
44
+ # else
45
+ # y / 3
46
+ # end
47
+ #
48
+ # # good
49
+ # a = case n
50
+ # when 0
51
+ # x * 2
52
+ # else
53
+ # y / 3
54
+ # end
55
+ #
56
+ # # EnforcedStyle: end
57
+ #
58
+ # # bad
59
+ # a = case n
60
+ # when 0
61
+ # x * 2
62
+ # else
63
+ # y / 3
64
+ # end
65
+ #
66
+ # # good
67
+ # a = case n
68
+ # when 0
69
+ # x * 2
70
+ # else
71
+ # y / 3
72
+ # end
10
73
  class CaseIndentation < Cop
11
74
  include AutocorrectAlignment
12
75
  include ConfigurableEnforcedStyle
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cops checks the indentation of hanging closing parentheses in
7
7
  # method calls, method definitions, and grouped expressions. A hanging
8
8
  # closing parenthesis means `)` preceded by a line break.
@@ -75,7 +75,7 @@ module RuboCop
75
75
  end
76
76
 
77
77
  def fixed_parameter_indentation?
78
- config.for_cop('Style/AlignParameters')['EnforcedStyle'] ==
78
+ config.for_cop('Layout/AlignParameters')['EnforcedStyle'] ==
79
79
  'with_fixed_indentation'
80
80
  end
81
81
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cops checks the indentation of comments.
7
7
  class CommentIndentation < Cop
8
8
  include AutocorrectAlignment
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cop checks the . position in multi-line method calls.
7
7
  class DotPosition < Cop
8
8
  include ConfigurableEnforcedStyle
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cops checks the alignment of else keywords. Normally they should
7
7
  # be aligned with an if/unless/while/until/begin/def keyword, but there
8
8
  # are special cases when they should follow the same rules as the
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Checks for a newline after the final magic comment.
7
7
  #
8
8
  # @example
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cop checks whether method definitions are
7
7
  # separated by one empty line.
8
8
  #
@@ -4,7 +4,7 @@ require 'set'
4
4
 
5
5
  module RuboCop
6
6
  module Cop
7
- module Style
7
+ module Layout
8
8
  # This cops checks for two or more consecutive blank lines.
9
9
  class EmptyLines < Cop
10
10
  MSG = 'Extra blank line detected.'.freeze
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # Access modifiers should be surrounded by blank lines.
7
7
  class EmptyLinesAroundAccessModifier < Cop
8
8
  include AccessModifierNode
@@ -23,7 +23,7 @@ module RuboCop
23
23
  send_line = node.loc.line
24
24
  previous_line = processed_source[send_line - 2]
25
25
  next_line = processed_source[send_line]
26
- line = line_range(node)
26
+ line = range_by_whole_lines(node.source_range)
27
27
 
28
28
  unless previous_line_empty?(previous_line)
29
29
  corrector.insert_before(line, "\n")
@@ -37,11 +37,6 @@ module RuboCop
37
37
 
38
38
  private
39
39
 
40
- def line_range(node)
41
- range_between(node.source_range.begin_pos - node.loc.column,
42
- node.source_range.end_pos)
43
- end
44
-
45
40
  def previous_line_ignoring_comments(processed_source, send_line)
46
41
  processed_source[0..send_line - 2].reverse.find do |line|
47
42
  !comment_line?(line)
@@ -3,7 +3,7 @@
3
3
 
4
4
  module RuboCop
5
5
  module Cop
6
- module Style
6
+ module Layout
7
7
  # This cops checks if empty lines exist around the bodies of begin-end
8
8
  # blocks.
9
9
  #
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cops checks if empty lines around the bodies of blocks match
7
7
  # the configuration.
8
8
  #
@@ -31,9 +31,7 @@ module RuboCop
31
31
  KIND = 'block'.freeze
32
32
 
33
33
  def on_block(node)
34
- _send, _args, body = *node
35
-
36
- check(node, body)
34
+ check(node, node.body)
37
35
  end
38
36
  end
39
37
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cop
5
- module Style
5
+ module Layout
6
6
  # This cops checks if empty lines around the bodies of classes match
7
7
  # the configuration.
8
8
  #