rubocop 0.48.1 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -26,9 +26,12 @@ require 'rubocop/ast/node/mixin/binary_operator_node'
26
26
  require 'rubocop/ast/node/mixin/conditional_node'
27
27
  require 'rubocop/ast/node/mixin/hash_element_node'
28
28
  require 'rubocop/ast/node/mixin/modifier_node'
29
+ require 'rubocop/ast/node/mixin/parameterized_node'
29
30
  require 'rubocop/ast/node/mixin/predicate_operator_node'
30
31
  require 'rubocop/ast/node/and_node'
32
+ require 'rubocop/ast/node/args_node'
31
33
  require 'rubocop/ast/node/array_node'
34
+ require 'rubocop/ast/node/block_node'
32
35
  require 'rubocop/ast/node/case_node'
33
36
  require 'rubocop/ast/node/ensure_node'
34
37
  require 'rubocop/ast/node/for_node'
@@ -39,6 +42,7 @@ require 'rubocop/ast/node/or_node'
39
42
  require 'rubocop/ast/node/pair_node'
40
43
  require 'rubocop/ast/node/resbody_node'
41
44
  require 'rubocop/ast/node/send_node'
45
+ require 'rubocop/ast/node/super_node'
42
46
  require 'rubocop/ast/node/until_node'
43
47
  require 'rubocop/ast/node/when_node'
44
48
  require 'rubocop/ast/node/while_node'
@@ -72,6 +76,7 @@ require 'rubocop/cop/variable_force/variable_table'
72
76
  require 'rubocop/cop/mixin/access_modifier_node'
73
77
  require 'rubocop/cop/mixin/annotation_comment'
74
78
  require 'rubocop/cop/mixin/array_hash_indentation'
79
+ require 'rubocop/cop/mixin/array_min_size'
75
80
  require 'rubocop/cop/mixin/array_syntax'
76
81
  require 'rubocop/cop/mixin/autocorrect_alignment'
77
82
  require 'rubocop/cop/mixin/check_assignment'
@@ -87,6 +92,7 @@ require 'rubocop/cop/mixin/documentation_comment'
87
92
  require 'rubocop/cop/mixin/duplication'
88
93
  require 'rubocop/cop/mixin/empty_lines_around_body'
89
94
  require 'rubocop/cop/mixin/end_keyword_alignment'
95
+ require 'rubocop/cop/mixin/enforce_superclass'
90
96
  require 'rubocop/cop/mixin/first_element_line_break'
91
97
  require 'rubocop/cop/mixin/frozen_string_literal'
92
98
  require 'rubocop/cop/mixin/hash_alignment'
@@ -124,6 +130,77 @@ require 'rubocop/cop/mixin/unused_argument'
124
130
  require 'rubocop/cop/bundler/duplicated_gem'
125
131
  require 'rubocop/cop/bundler/ordered_gems'
126
132
 
133
+ require 'rubocop/cop/layout/access_modifier_indentation'
134
+ require 'rubocop/cop/layout/align_array'
135
+ require 'rubocop/cop/layout/align_hash'
136
+ require 'rubocop/cop/layout/align_parameters'
137
+ require 'rubocop/cop/layout/block_end_newline'
138
+ require 'rubocop/cop/layout/case_indentation'
139
+ require 'rubocop/cop/layout/closing_parenthesis_indentation'
140
+ require 'rubocop/cop/layout/comment_indentation'
141
+ require 'rubocop/cop/layout/dot_position'
142
+ require 'rubocop/cop/layout/else_alignment'
143
+ require 'rubocop/cop/layout/empty_line_after_magic_comment'
144
+ require 'rubocop/cop/layout/empty_line_between_defs'
145
+ require 'rubocop/cop/layout/empty_lines_around_access_modifier'
146
+ require 'rubocop/cop/layout/empty_lines_around_begin_body'
147
+ require 'rubocop/cop/layout/empty_lines_around_block_body'
148
+ require 'rubocop/cop/layout/empty_lines_around_class_body'
149
+ require 'rubocop/cop/layout/empty_lines_around_exception_handling_keywords'
150
+ require 'rubocop/cop/layout/empty_lines_around_method_body'
151
+ require 'rubocop/cop/layout/empty_lines_around_module_body'
152
+ require 'rubocop/cop/layout/empty_lines'
153
+ require 'rubocop/cop/layout/end_of_line'
154
+ require 'rubocop/cop/layout/extra_spacing'
155
+ require 'rubocop/cop/layout/first_array_element_line_break'
156
+ require 'rubocop/cop/layout/first_hash_element_line_break'
157
+ require 'rubocop/cop/layout/first_method_argument_line_break'
158
+ require 'rubocop/cop/layout/first_method_parameter_line_break'
159
+ require 'rubocop/cop/layout/first_parameter_indentation'
160
+ require 'rubocop/cop/layout/indent_array'
161
+ require 'rubocop/cop/layout/indent_assignment'
162
+ require 'rubocop/cop/layout/indentation_consistency'
163
+ require 'rubocop/cop/layout/indentation_width'
164
+ require 'rubocop/cop/layout/indent_hash'
165
+ require 'rubocop/cop/layout/indent_heredoc'
166
+ require 'rubocop/cop/layout/initial_indentation'
167
+ require 'rubocop/cop/layout/leading_comment_space'
168
+ require 'rubocop/cop/layout/multiline_array_brace_layout'
169
+ require 'rubocop/cop/layout/multiline_assignment_layout'
170
+ require 'rubocop/cop/layout/multiline_block_layout'
171
+ require 'rubocop/cop/layout/multiline_hash_brace_layout'
172
+ require 'rubocop/cop/layout/multiline_method_call_brace_layout'
173
+ require 'rubocop/cop/layout/multiline_method_call_indentation'
174
+ require 'rubocop/cop/layout/multiline_method_definition_brace_layout'
175
+ require 'rubocop/cop/layout/multiline_operation_indentation'
176
+ require 'rubocop/cop/layout/rescue_ensure_alignment'
177
+ require 'rubocop/cop/layout/space_after_colon'
178
+ require 'rubocop/cop/layout/space_after_comma'
179
+ require 'rubocop/cop/layout/space_after_method_name'
180
+ require 'rubocop/cop/layout/space_after_not'
181
+ require 'rubocop/cop/layout/space_after_semicolon'
182
+ require 'rubocop/cop/layout/space_around_block_parameters'
183
+ require 'rubocop/cop/layout/space_around_equals_in_parameter_default'
184
+ require 'rubocop/cop/layout/space_around_keyword'
185
+ require 'rubocop/cop/layout/space_around_operators'
186
+ require 'rubocop/cop/layout/space_before_block_braces'
187
+ require 'rubocop/cop/layout/space_before_comma'
188
+ require 'rubocop/cop/layout/space_before_comment'
189
+ require 'rubocop/cop/layout/space_before_first_arg'
190
+ require 'rubocop/cop/layout/space_before_semicolon'
191
+ require 'rubocop/cop/layout/space_in_lambda_literal'
192
+ require 'rubocop/cop/layout/space_inside_array_percent_literal'
193
+ require 'rubocop/cop/layout/space_inside_block_braces'
194
+ require 'rubocop/cop/layout/space_inside_brackets'
195
+ require 'rubocop/cop/layout/space_inside_hash_literal_braces'
196
+ require 'rubocop/cop/layout/space_inside_parens'
197
+ require 'rubocop/cop/layout/space_inside_percent_literal_delimiters'
198
+ require 'rubocop/cop/layout/space_inside_range_literal'
199
+ require 'rubocop/cop/layout/space_inside_string_interpolation'
200
+ require 'rubocop/cop/layout/tab'
201
+ require 'rubocop/cop/layout/trailing_blank_lines'
202
+ require 'rubocop/cop/layout/trailing_whitespace'
203
+
127
204
  require 'rubocop/cop/lint/ambiguous_block_association'
128
205
  require 'rubocop/cop/lint/ambiguous_operator'
129
206
  require 'rubocop/cop/lint/ambiguous_regexp_literal'
@@ -166,7 +243,9 @@ require 'rubocop/cop/lint/percent_symbol_array'
166
243
  require 'rubocop/cop/lint/rand_one'
167
244
  require 'rubocop/cop/lint/require_parentheses'
168
245
  require 'rubocop/cop/lint/rescue_exception'
246
+ require 'rubocop/cop/lint/rescue_type'
169
247
  require 'rubocop/cop/lint/safe_navigation_chain'
248
+ require 'rubocop/cop/lint/script_permission'
170
249
  require 'rubocop/cop/lint/shadowed_exception'
171
250
  require 'rubocop/cop/lint/shadowing_outer_local_variable'
172
251
  require 'rubocop/cop/lint/string_conversion_in_interpolation'
@@ -196,6 +275,7 @@ require 'rubocop/cop/metrics/module_length'
196
275
  require 'rubocop/cop/metrics/parameter_lists'
197
276
  require 'rubocop/cop/metrics/perceived_complexity'
198
277
 
278
+ require 'rubocop/cop/performance/caller'
199
279
  require 'rubocop/cop/performance/case_when_splat'
200
280
  require 'rubocop/cop/performance/casecmp'
201
281
  require 'rubocop/cop/performance/count'
@@ -220,12 +300,8 @@ require 'rubocop/cop/performance/start_with'
220
300
  require 'rubocop/cop/performance/string_replacement'
221
301
  require 'rubocop/cop/performance/times_map'
222
302
 
223
- require 'rubocop/cop/style/access_modifier_indentation'
224
303
  require 'rubocop/cop/style/accessor_method_name'
225
304
  require 'rubocop/cop/style/alias'
226
- require 'rubocop/cop/style/align_array'
227
- require 'rubocop/cop/style/align_hash'
228
- require 'rubocop/cop/style/align_parameters'
229
305
  require 'rubocop/cop/style/and_or'
230
306
  require 'rubocop/cop/style/array_join'
231
307
  require 'rubocop/cop/style/ascii_comments'
@@ -236,22 +312,18 @@ require 'rubocop/cop/style/bare_percent_literals'
236
312
  require 'rubocop/cop/style/begin_block'
237
313
  require 'rubocop/cop/style/block_comments'
238
314
  require 'rubocop/cop/style/block_delimiters'
239
- require 'rubocop/cop/style/block_end_newline'
240
315
  require 'rubocop/cop/style/braces_around_hash_parameters'
241
316
  require 'rubocop/cop/style/case_equality'
242
- require 'rubocop/cop/style/case_indentation'
243
317
  require 'rubocop/cop/style/character_literal'
244
318
  require 'rubocop/cop/style/class_and_module_camel_case'
245
319
  require 'rubocop/cop/style/class_and_module_children'
246
320
  require 'rubocop/cop/style/class_check'
247
321
  require 'rubocop/cop/style/class_methods'
248
322
  require 'rubocop/cop/style/class_vars'
249
- require 'rubocop/cop/style/closing_parenthesis_indentation'
250
323
  require 'rubocop/cop/style/collection_methods'
251
324
  require 'rubocop/cop/style/colon_method_call'
252
325
  require 'rubocop/cop/style/command_literal'
253
326
  require 'rubocop/cop/style/comment_annotation'
254
- require 'rubocop/cop/style/comment_indentation'
255
327
  require 'rubocop/cop/style/conditional_assignment'
256
328
  require 'rubocop/cop/style/constant_name'
257
329
  require 'rubocop/cop/style/copyright'
@@ -259,39 +331,21 @@ require 'rubocop/cop/style/def_with_parentheses'
259
331
  require 'rubocop/cop/style/preferred_hash_methods'
260
332
  require 'rubocop/cop/style/documentation_method'
261
333
  require 'rubocop/cop/style/documentation'
262
- require 'rubocop/cop/style/dot_position'
263
334
  require 'rubocop/cop/style/double_negation'
264
335
  require 'rubocop/cop/style/each_for_simple_loop'
265
336
  require 'rubocop/cop/style/each_with_object'
266
- require 'rubocop/cop/style/else_alignment'
267
337
  require 'rubocop/cop/style/empty_case_condition'
268
338
  require 'rubocop/cop/style/empty_else'
269
- require 'rubocop/cop/style/empty_line_after_magic_comment'
270
- require 'rubocop/cop/style/empty_line_between_defs'
271
- require 'rubocop/cop/style/empty_lines'
272
- require 'rubocop/cop/style/empty_lines_around_access_modifier'
273
- require 'rubocop/cop/style/empty_lines_around_begin_body'
274
- require 'rubocop/cop/style/empty_lines_around_block_body'
275
- require 'rubocop/cop/style/empty_lines_around_class_body'
276
- require 'rubocop/cop/style/empty_lines_around_exception_handling_keywords'
277
- require 'rubocop/cop/style/empty_lines_around_method_body'
278
- require 'rubocop/cop/style/empty_lines_around_module_body'
279
339
  require 'rubocop/cop/style/empty_literal'
280
340
  require 'rubocop/cop/style/empty_method'
281
341
  require 'rubocop/cop/style/encoding'
282
342
  require 'rubocop/cop/style/end_block'
283
- require 'rubocop/cop/style/end_of_line'
284
343
  require 'rubocop/cop/style/even_odd'
285
- require 'rubocop/cop/style/extra_spacing'
286
344
  require 'rubocop/cop/style/file_name'
287
- require 'rubocop/cop/style/first_array_element_line_break'
288
- require 'rubocop/cop/style/first_hash_element_line_break'
289
- require 'rubocop/cop/style/first_method_argument_line_break'
290
- require 'rubocop/cop/style/first_method_parameter_line_break'
291
- require 'rubocop/cop/style/first_parameter_indentation'
292
345
  require 'rubocop/cop/style/flip_flop'
293
346
  require 'rubocop/cop/style/for'
294
347
  require 'rubocop/cop/style/format_string'
348
+ require 'rubocop/cop/style/format_string_token'
295
349
  require 'rubocop/cop/style/frozen_string_literal_comment'
296
350
  require 'rubocop/cop/style/global_vars'
297
351
  require 'rubocop/cop/style/guard_clause'
@@ -302,19 +356,11 @@ require 'rubocop/cop/style/if_unless_modifier'
302
356
  require 'rubocop/cop/style/if_unless_modifier_of_if_unless'
303
357
  require 'rubocop/cop/style/if_with_semicolon'
304
358
  require 'rubocop/cop/style/implicit_runtime_error'
305
- require 'rubocop/cop/style/indent_array'
306
- require 'rubocop/cop/style/indent_assignment'
307
- require 'rubocop/cop/style/indent_hash'
308
- require 'rubocop/cop/style/indent_heredoc'
309
- require 'rubocop/cop/style/indentation_consistency'
310
- require 'rubocop/cop/style/indentation_width'
311
359
  require 'rubocop/cop/style/infinite_loop'
312
360
  require 'rubocop/cop/style/inverse_methods'
313
- require 'rubocop/cop/style/initial_indentation'
314
361
  require 'rubocop/cop/style/inline_comment'
315
362
  require 'rubocop/cop/style/lambda'
316
363
  require 'rubocop/cop/style/lambda_call'
317
- require 'rubocop/cop/style/leading_comment_space'
318
364
  require 'rubocop/cop/style/line_end_concatenation'
319
365
  require 'rubocop/cop/style/method_call_without_args_parentheses'
320
366
  require 'rubocop/cop/style/method_call_with_args_parentheses'
@@ -325,19 +371,12 @@ require 'rubocop/cop/style/method_missing'
325
371
  require 'rubocop/cop/style/missing_else'
326
372
  require 'rubocop/cop/style/mixin_grouping'
327
373
  require 'rubocop/cop/style/module_function'
328
- require 'rubocop/cop/style/multiline_array_brace_layout'
329
- require 'rubocop/cop/style/multiline_assignment_layout'
330
374
  require 'rubocop/cop/style/multiline_block_chain'
331
- require 'rubocop/cop/style/multiline_block_layout'
332
- require 'rubocop/cop/style/multiline_hash_brace_layout'
333
375
  require 'rubocop/cop/style/multiline_if_then'
334
376
  require 'rubocop/cop/style/multiline_if_modifier'
335
377
  require 'rubocop/cop/style/multiline_memoization'
336
- require 'rubocop/cop/style/multiline_method_call_brace_layout'
337
- require 'rubocop/cop/style/multiline_method_call_indentation'
338
- require 'rubocop/cop/style/multiline_method_definition_brace_layout'
339
- require 'rubocop/cop/style/multiline_operation_indentation'
340
378
  require 'rubocop/cop/style/multiline_ternary_operator'
379
+ require 'rubocop/cop/style/multiple_comparison'
341
380
  require 'rubocop/cop/style/mutable_constant'
342
381
  require 'rubocop/cop/style/negated_if'
343
382
  require 'rubocop/cop/style/negated_while'
@@ -370,7 +409,6 @@ require 'rubocop/cop/style/redundant_parentheses'
370
409
  require 'rubocop/cop/style/redundant_return'
371
410
  require 'rubocop/cop/style/redundant_self'
372
411
  require 'rubocop/cop/style/regexp_literal'
373
- require 'rubocop/cop/style/rescue_ensure_alignment'
374
412
  require 'rubocop/cop/style/rescue_modifier'
375
413
  require 'rubocop/cop/style/safe_navigation'
376
414
  require 'rubocop/cop/style/self_assignment'
@@ -379,29 +417,6 @@ require 'rubocop/cop/style/send'
379
417
  require 'rubocop/cop/style/signal_exception'
380
418
  require 'rubocop/cop/style/single_line_block_params'
381
419
  require 'rubocop/cop/style/single_line_methods'
382
- require 'rubocop/cop/style/space_after_colon'
383
- require 'rubocop/cop/style/space_after_comma'
384
- require 'rubocop/cop/style/space_after_method_name'
385
- require 'rubocop/cop/style/space_after_not'
386
- require 'rubocop/cop/style/space_after_semicolon'
387
- require 'rubocop/cop/style/space_around_block_parameters'
388
- require 'rubocop/cop/style/space_around_equals_in_parameter_default'
389
- require 'rubocop/cop/style/space_around_keyword'
390
- require 'rubocop/cop/style/space_around_operators'
391
- require 'rubocop/cop/style/space_before_block_braces'
392
- require 'rubocop/cop/style/space_before_comma'
393
- require 'rubocop/cop/style/space_before_comment'
394
- require 'rubocop/cop/style/space_before_first_arg'
395
- require 'rubocop/cop/style/space_before_semicolon'
396
- require 'rubocop/cop/style/space_in_lambda_literal'
397
- require 'rubocop/cop/style/space_inside_array_percent_literal'
398
- require 'rubocop/cop/style/space_inside_block_braces'
399
- require 'rubocop/cop/style/space_inside_brackets'
400
- require 'rubocop/cop/style/space_inside_hash_literal_braces'
401
- require 'rubocop/cop/style/space_inside_parens'
402
- require 'rubocop/cop/style/space_inside_percent_literal_delimiters'
403
- require 'rubocop/cop/style/space_inside_range_literal'
404
- require 'rubocop/cop/style/space_inside_string_interpolation'
405
420
  require 'rubocop/cop/style/special_global_vars'
406
421
  require 'rubocop/cop/style/stabby_lambda_parentheses'
407
422
  require 'rubocop/cop/style/string_literals'
@@ -411,13 +426,10 @@ require 'rubocop/cop/style/struct_inheritance'
411
426
  require 'rubocop/cop/style/symbol_array'
412
427
  require 'rubocop/cop/style/symbol_literal'
413
428
  require 'rubocop/cop/style/symbol_proc'
414
- require 'rubocop/cop/style/tab'
415
429
  require 'rubocop/cop/style/ternary_parentheses'
416
- require 'rubocop/cop/style/trailing_blank_lines'
417
430
  require 'rubocop/cop/style/trailing_comma_in_arguments'
418
431
  require 'rubocop/cop/style/trailing_comma_in_literal'
419
432
  require 'rubocop/cop/style/trailing_underscore_variable'
420
- require 'rubocop/cop/style/trailing_whitespace'
421
433
  require 'rubocop/cop/style/trivial_accessors'
422
434
  require 'rubocop/cop/style/unless_else'
423
435
  require 'rubocop/cop/style/unneeded_capital_w'
@@ -430,10 +442,13 @@ require 'rubocop/cop/style/when_then'
430
442
  require 'rubocop/cop/style/while_until_do'
431
443
  require 'rubocop/cop/style/while_until_modifier'
432
444
  require 'rubocop/cop/style/word_array'
445
+ require 'rubocop/cop/style/yoda_condition'
433
446
  require 'rubocop/cop/style/zero_length_predicate'
434
447
 
435
448
  require 'rubocop/cop/rails/action_filter'
436
449
  require 'rubocop/cop/rails/active_support_aliases'
450
+ require 'rubocop/cop/rails/application_job'
451
+ require 'rubocop/cop/rails/application_record'
437
452
  require 'rubocop/cop/rails/blank'
438
453
  require 'rubocop/cop/rails/date'
439
454
  require 'rubocop/cop/rails/dynamic_find_by'
@@ -15,7 +15,9 @@ module RuboCop
15
15
  class Builder < Parser::Builders::Default
16
16
  NODE_MAP = {
17
17
  AndNode => [:and],
18
+ ArgsNode => [:args],
18
19
  ArrayNode => [:array],
20
+ BlockNode => [:block],
19
21
  CaseNode => [:case],
20
22
  EnsureNode => [:ensure],
21
23
  ForNode => [:for],
@@ -25,7 +27,8 @@ module RuboCop
25
27
  OrNode => [:or],
26
28
  PairNode => [:pair],
27
29
  ResbodyNode => [:resbody],
28
- SendNode => [:send],
30
+ SendNode => %i[csend send],
31
+ SuperNode => %i[super zsuper],
29
32
  UntilNode => %i[until until_post],
30
33
  WhenNode => [:when],
31
34
  WhileNode => %i[while while_post]
@@ -52,8 +52,8 @@ module RuboCop
52
52
  "#{compiler.emit_param_list});" \
53
53
  "#{compiler.emit_method_code};end"
54
54
 
55
- file, lineno = *caller.first.split(':')
56
- class_eval(src, file, lineno.to_i)
55
+ location = caller_locations(1, 1).first
56
+ class_eval(src, location.path, location.lineno)
57
57
  end
58
58
  end
59
59
 
@@ -30,7 +30,7 @@ module RuboCop
30
30
  #
31
31
  # @return [Array<Node>] the different parts of the `and` predicate
32
32
  def node_parts
33
- [*self]
33
+ to_a
34
34
  end
35
35
  end
36
36
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `args` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available
7
+ # to all `args` nodes within RuboCop.
8
+ class ArgsNode < Node
9
+ # Whether this `args` node has any arguments.
10
+ #
11
+ # @return [Boolean] whether this `args` node has any arguments
12
+ def empty?
13
+ to_a.empty?
14
+ end
15
+
16
+ # The number of arguments in this `args` node.
17
+ #
18
+ # @return [Integer] the number of arguments in this `args` node
19
+ def size
20
+ to_a.size
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module AST
5
+ # A node extension for `block` nodes. This will be used in place of a plain
6
+ # node when the builder constructs the AST, making its methods available
7
+ # to all `send` nodes within RuboCop.
8
+ #
9
+ # A `block` node is essentially a method send with a block. Parser nests
10
+ # the `send` node inside the `block` node.
11
+ class BlockNode < Node
12
+ # The `send` node associated with this block.
13
+ #
14
+ # @return [SendNode] the `send` node associated with the `block` node
15
+ def send_node
16
+ node_parts[0]
17
+ end
18
+
19
+ # The arguments of this block.
20
+ #
21
+ # @return [Array<Node>]
22
+ def arguments
23
+ node_parts[1]
24
+ end
25
+
26
+ # The body of this block.
27
+ #
28
+ # @return [Node, nil] the body of the `block` node or `nil`
29
+ def body
30
+ node_parts[2]
31
+ end
32
+
33
+ # Checks whether this block takes any arguments.
34
+ #
35
+ # @return [Boolean] whether this `block` node takes any arguments
36
+ def arguments?
37
+ !arguments.empty?
38
+ end
39
+
40
+ # Checks whether the `block` literal is delimited by curly braces.
41
+ #
42
+ # @return [Boolean] whether the `block` literal is enclosed in braces
43
+ def braces?
44
+ loc.end && loc.end.is?('}')
45
+ end
46
+
47
+ # Checks whether the `block` literal is delimited by `do`-`end` keywords.
48
+ #
49
+ # @return [Boolean] whether the `block` literal is enclosed in `do`-`end`
50
+ def keywords?
51
+ loc.end && loc.end.is?('end')
52
+ end
53
+
54
+ # The delimiters for this `block` literal.
55
+ #
56
+ # @return [Array<String>] the delimiters for the `block` literal
57
+ def delimiters
58
+ [loc.begin.source, loc.end.source].freeze
59
+ end
60
+
61
+ # The opening delimiter for this `block` literal.
62
+ #
63
+ # @return [String] the opening delimiter for the `block` literal
64
+ def opening_delimiter
65
+ delimiters.first
66
+ end
67
+
68
+ # The closing delimiter for this `block` literal.
69
+ #
70
+ # @return [String] the closing delimiter for the `block` literal
71
+ def closing_delimiter
72
+ delimiters.last
73
+ end
74
+
75
+ # Checks whether this is a single line block. This is overridden here
76
+ # because the general version in `Node` does not work for `block` nodes.
77
+ #
78
+ # @return [Boolean] whether the `block` literal is on a single line
79
+ def single_line?
80
+ loc.begin.line == loc.end.line
81
+ end
82
+
83
+ # Checks whether this is a multiline block. This is overridden here
84
+ # because the general version in `Node` does not work for `block` nodes.
85
+ #
86
+ # @return [Boolean] whether the `block` literal is on a several lines
87
+ def multiline?
88
+ !single_line?
89
+ end
90
+
91
+ # Checks whether this `block` literal belongs to a lambda.
92
+ #
93
+ # @return [Boolean] whether the `block` literal belongs to a lambda
94
+ def lambda?
95
+ send_node.method?(:lambda)
96
+ end
97
+
98
+ # Custom destructuring method. This can be used to normalize
99
+ # destructuring for different variations of the node.
100
+ #
101
+ # @return [Array] the different parts of the `block` node
102
+ def node_parts
103
+ to_a
104
+ end
105
+ end
106
+ end
107
+ end