rubocop 0.52.1 → 0.93.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (749) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +1 -1
  3. data/README.md +49 -38
  4. data/assets/output.html.erb +1 -1
  5. data/bin/console +10 -0
  6. data/bin/rubocop-profile +32 -0
  7. data/bin/setup +7 -0
  8. data/config/default.yml +3332 -538
  9. data/{bin → exe}/rubocop +0 -0
  10. data/lib/rubocop.rb +206 -158
  11. data/lib/rubocop/ast_aliases.rb +8 -0
  12. data/lib/rubocop/cached_data.rb +4 -2
  13. data/lib/rubocop/cli.rb +50 -187
  14. data/lib/rubocop/cli/command.rb +22 -0
  15. data/lib/rubocop/cli/command/auto_genenerate_config.rb +141 -0
  16. data/lib/rubocop/cli/command/base.rb +35 -0
  17. data/lib/rubocop/cli/command/execute_runner.rb +85 -0
  18. data/lib/rubocop/cli/command/init_dotfile.rb +46 -0
  19. data/lib/rubocop/cli/command/show_cops.rb +77 -0
  20. data/lib/rubocop/cli/command/version.rb +18 -0
  21. data/lib/rubocop/cli/environment.rb +22 -0
  22. data/lib/rubocop/comment_config.rb +73 -12
  23. data/lib/rubocop/config.rb +117 -385
  24. data/lib/rubocop/config_loader.rb +145 -92
  25. data/lib/rubocop/config_loader_resolver.rb +124 -30
  26. data/lib/rubocop/config_obsoletion.rb +283 -0
  27. data/lib/rubocop/config_regeneration.rb +33 -0
  28. data/lib/rubocop/config_store.rb +19 -5
  29. data/lib/rubocop/config_validator.rb +224 -0
  30. data/lib/rubocop/cop/autocorrect_logic.rb +73 -4
  31. data/lib/rubocop/cop/badge.rb +7 -7
  32. data/lib/rubocop/cop/base.rb +430 -0
  33. data/lib/rubocop/cop/bundler/duplicated_gem.rb +9 -3
  34. data/lib/rubocop/cop/bundler/gem_comment.rb +138 -0
  35. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +19 -25
  36. data/lib/rubocop/cop/bundler/ordered_gems.rb +6 -4
  37. data/lib/rubocop/cop/commissioner.rb +102 -62
  38. data/lib/rubocop/cop/cop.rb +104 -181
  39. data/lib/rubocop/cop/corrector.rb +82 -98
  40. data/lib/rubocop/cop/correctors/alignment_corrector.rb +50 -29
  41. data/lib/rubocop/cop/correctors/condition_corrector.rb +3 -6
  42. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +53 -0
  43. data/lib/rubocop/cop/correctors/empty_line_corrector.rb +9 -10
  44. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +73 -0
  45. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +136 -0
  46. data/lib/rubocop/cop/correctors/line_break_corrector.rb +61 -0
  47. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +82 -45
  48. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +6 -9
  49. data/lib/rubocop/cop/correctors/percent_literal_corrector.rb +112 -0
  50. data/lib/rubocop/cop/correctors/punctuation_corrector.rb +8 -10
  51. data/lib/rubocop/cop/correctors/space_corrector.rb +15 -3
  52. data/lib/rubocop/cop/correctors/string_literal_corrector.rb +2 -2
  53. data/lib/rubocop/cop/correctors/unused_arg_corrector.rb +18 -9
  54. data/lib/rubocop/cop/documentation.rb +22 -0
  55. data/lib/rubocop/cop/force.rb +2 -0
  56. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +7 -5
  57. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +5 -7
  58. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +49 -25
  59. data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +55 -0
  60. data/lib/rubocop/cop/generator.rb +70 -37
  61. data/lib/rubocop/cop/generator/configuration_injector.rb +66 -0
  62. data/lib/rubocop/cop/generator/require_file_injector.rb +2 -2
  63. data/lib/rubocop/cop/ignored_node.rb +1 -3
  64. data/lib/rubocop/cop/internal_affairs.rb +1 -0
  65. data/lib/rubocop/cop/internal_affairs/method_name_equal.rb +52 -0
  66. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +13 -15
  67. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +14 -16
  68. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +12 -11
  69. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +15 -22
  70. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +13 -11
  71. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +5 -5
  72. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +15 -27
  73. data/lib/rubocop/cop/layout/{align_parameters.rb → argument_alignment.rb} +21 -17
  74. data/lib/rubocop/cop/layout/array_alignment.rb +83 -0
  75. data/lib/rubocop/cop/layout/{indent_assignment.rb → assignment_indentation.rb} +12 -3
  76. data/lib/rubocop/cop/layout/begin_end_alignment.rb +77 -0
  77. data/lib/rubocop/cop/{lint → layout}/block_alignment.rb +36 -29
  78. data/lib/rubocop/cop/layout/block_end_newline.rb +9 -20
  79. data/lib/rubocop/cop/layout/case_indentation.rb +23 -26
  80. data/lib/rubocop/cop/layout/class_structure.rb +97 -98
  81. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +124 -0
  82. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +140 -30
  83. data/lib/rubocop/cop/layout/comment_indentation.rb +34 -7
  84. data/lib/rubocop/cop/{lint → layout}/condition_position.rb +18 -10
  85. data/lib/rubocop/cop/{lint → layout}/def_end_alignment.rb +11 -7
  86. data/lib/rubocop/cop/layout/dot_position.rb +31 -27
  87. data/lib/rubocop/cop/layout/else_alignment.rb +28 -15
  88. data/lib/rubocop/cop/layout/empty_comment.rb +158 -0
  89. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +160 -0
  90. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +17 -16
  91. data/lib/rubocop/cop/layout/empty_line_after_multiline_condition.rb +136 -0
  92. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +32 -29
  93. data/lib/rubocop/cop/layout/empty_lines.rb +11 -12
  94. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +147 -39
  95. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +29 -18
  96. data/lib/rubocop/cop/layout/empty_lines_around_attribute_accessor.rb +118 -0
  97. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +4 -8
  98. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +6 -7
  99. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +28 -11
  100. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +6 -9
  101. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +4 -7
  102. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +5 -9
  103. data/lib/rubocop/cop/{lint → layout}/end_alignment.rb +49 -23
  104. data/lib/rubocop/cop/layout/end_of_line.rb +48 -8
  105. data/lib/rubocop/cop/layout/extra_spacing.rb +71 -118
  106. data/lib/rubocop/cop/layout/first_argument_indentation.rb +251 -0
  107. data/lib/rubocop/cop/layout/{indent_array.rb → first_array_element_indentation.rb} +22 -16
  108. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +4 -7
  109. data/lib/rubocop/cop/layout/{indent_hash.rb → first_hash_element_indentation.rb} +10 -9
  110. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +3 -6
  111. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +8 -12
  112. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +3 -6
  113. data/lib/rubocop/cop/layout/first_parameter_indentation.rb +57 -76
  114. data/lib/rubocop/cop/layout/hash_alignment.rb +362 -0
  115. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +286 -0
  116. data/lib/rubocop/cop/layout/heredoc_indentation.rb +176 -0
  117. data/lib/rubocop/cop/layout/indentation_consistency.rb +155 -7
  118. data/lib/rubocop/cop/layout/indentation_style.rb +115 -0
  119. data/lib/rubocop/cop/layout/indentation_width.rb +72 -28
  120. data/lib/rubocop/cop/layout/initial_indentation.rb +24 -11
  121. data/lib/rubocop/cop/layout/leading_comment_space.rb +75 -12
  122. data/lib/rubocop/cop/layout/leading_empty_lines.rb +48 -0
  123. data/lib/rubocop/cop/layout/line_length.rb +280 -0
  124. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +13 -16
  125. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +36 -0
  126. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +18 -16
  127. data/lib/rubocop/cop/layout/multiline_block_layout.rb +74 -29
  128. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +6 -13
  129. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +47 -0
  130. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +48 -0
  131. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +68 -38
  132. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +7 -8
  133. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +80 -42
  134. data/lib/rubocop/cop/layout/multiline_operation_indentation.rb +29 -5
  135. data/lib/rubocop/cop/layout/parameter_alignment.rb +118 -0
  136. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +142 -30
  137. data/lib/rubocop/cop/layout/space_after_colon.rb +13 -9
  138. data/lib/rubocop/cop/layout/space_after_comma.rb +2 -5
  139. data/lib/rubocop/cop/layout/space_after_method_name.rb +11 -9
  140. data/lib/rubocop/cop/layout/space_after_not.rb +13 -13
  141. data/lib/rubocop/cop/layout/space_after_semicolon.rb +2 -5
  142. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +76 -47
  143. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +33 -24
  144. data/lib/rubocop/cop/layout/space_around_keyword.rb +42 -29
  145. data/lib/rubocop/cop/layout/space_around_method_call_operator.rb +98 -0
  146. data/lib/rubocop/cop/layout/space_around_operators.rb +132 -48
  147. data/lib/rubocop/cop/layout/space_before_block_braces.rb +69 -25
  148. data/lib/rubocop/cop/layout/space_before_comma.rb +3 -5
  149. data/lib/rubocop/cop/layout/space_before_comment.rb +15 -11
  150. data/lib/rubocop/cop/layout/space_before_first_arg.rb +18 -8
  151. data/lib/rubocop/cop/layout/space_before_semicolon.rb +2 -5
  152. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +29 -40
  153. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +68 -77
  154. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +5 -10
  155. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +41 -24
  156. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +68 -62
  157. data/lib/rubocop/cop/layout/space_inside_parens.rb +72 -17
  158. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +8 -13
  159. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +10 -19
  160. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +76 -26
  161. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +26 -42
  162. data/lib/rubocop/cop/layout/trailing_empty_lines.rb +108 -0
  163. data/lib/rubocop/cop/layout/trailing_whitespace.rb +58 -9
  164. data/lib/rubocop/cop/legacy/corrections_proxy.rb +49 -0
  165. data/lib/rubocop/cop/legacy/corrector.rb +29 -0
  166. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +15 -7
  167. data/lib/rubocop/cop/lint/ambiguous_operator.rb +54 -6
  168. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +36 -7
  169. data/lib/rubocop/cop/lint/assignment_in_condition.rb +30 -27
  170. data/lib/rubocop/cop/lint/big_decimal_new.rb +43 -0
  171. data/lib/rubocop/cop/lint/binary_operator_with_identical_operands.rb +50 -0
  172. data/lib/rubocop/cop/lint/boolean_symbol.rb +23 -3
  173. data/lib/rubocop/cop/lint/circular_argument_reference.rb +3 -3
  174. data/lib/rubocop/cop/lint/constant_definition_in_block.rb +74 -0
  175. data/lib/rubocop/cop/lint/constant_resolution.rb +89 -0
  176. data/lib/rubocop/cop/lint/debugger.rb +14 -11
  177. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +41 -23
  178. data/lib/rubocop/cop/lint/deprecated_open_ssl_constant.rb +141 -0
  179. data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +87 -0
  180. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +2 -2
  181. data/lib/rubocop/cop/lint/duplicate_elsif_condition.rb +39 -0
  182. data/lib/rubocop/cop/lint/{duplicated_key.rb → duplicate_hash_key.rb} +2 -2
  183. data/lib/rubocop/cop/lint/duplicate_methods.rb +44 -30
  184. data/lib/rubocop/cop/lint/duplicate_require.rb +46 -0
  185. data/lib/rubocop/cop/lint/duplicate_rescue_exception.rb +47 -0
  186. data/lib/rubocop/cop/lint/each_with_object_argument.rb +7 -3
  187. data/lib/rubocop/cop/lint/else_layout.rb +3 -2
  188. data/lib/rubocop/cop/lint/empty_conditional_body.rb +67 -0
  189. data/lib/rubocop/cop/lint/empty_ensure.rb +6 -6
  190. data/lib/rubocop/cop/lint/empty_expression.rb +3 -3
  191. data/lib/rubocop/cop/lint/empty_file.rb +50 -0
  192. data/lib/rubocop/cop/lint/empty_interpolation.rb +9 -10
  193. data/lib/rubocop/cop/lint/empty_when.rb +32 -9
  194. data/lib/rubocop/cop/lint/ensure_return.rb +31 -13
  195. data/lib/rubocop/cop/lint/erb_new_arguments.rb +165 -0
  196. data/lib/rubocop/cop/{style → lint}/flip_flop.rb +5 -4
  197. data/lib/rubocop/cop/lint/float_comparison.rb +93 -0
  198. data/lib/rubocop/cop/lint/float_out_of_range.rb +3 -3
  199. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +65 -46
  200. data/lib/rubocop/cop/lint/hash_compare_by_identity.rb +37 -0
  201. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +155 -0
  202. data/lib/rubocop/cop/lint/identity_comparison.rb +51 -0
  203. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +26 -19
  204. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +43 -67
  205. data/lib/rubocop/cop/lint/inherit_exception.rb +34 -9
  206. data/lib/rubocop/cop/lint/interpolation_check.rb +24 -5
  207. data/lib/rubocop/cop/lint/literal_as_condition.rb +30 -24
  208. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +38 -16
  209. data/lib/rubocop/cop/lint/loop.rb +31 -8
  210. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +15 -11
  211. data/lib/rubocop/cop/lint/missing_super.rb +99 -0
  212. data/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb +37 -0
  213. data/lib/rubocop/cop/lint/{multiple_compare.rb → multiple_comparison.rb} +12 -13
  214. data/lib/rubocop/cop/lint/nested_method_definition.rb +21 -26
  215. data/lib/rubocop/cop/lint/nested_percent_literal.rb +7 -14
  216. data/lib/rubocop/cop/lint/next_without_accumulator.rb +3 -3
  217. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +160 -0
  218. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +14 -16
  219. data/lib/rubocop/cop/lint/number_conversion.rb +79 -0
  220. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +84 -0
  221. data/lib/rubocop/cop/lint/out_of_range_regexp_ref.rb +79 -0
  222. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +39 -15
  223. data/lib/rubocop/cop/lint/percent_string_array.rb +10 -17
  224. data/lib/rubocop/cop/lint/percent_symbol_array.rb +21 -17
  225. data/lib/rubocop/cop/lint/raise_exception.rb +86 -0
  226. data/lib/rubocop/cop/lint/rand_one.rb +7 -6
  227. data/lib/rubocop/cop/lint/{unneeded_disable.rb → redundant_cop_disable_directive.rb} +91 -76
  228. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +125 -0
  229. data/lib/rubocop/cop/lint/{unneeded_require_statement.rb → redundant_require_statement.rb} +12 -15
  230. data/lib/rubocop/cop/lint/redundant_safe_navigation.rb +78 -0
  231. data/lib/rubocop/cop/lint/{unneeded_splat_expansion.rb → redundant_splat_expansion.rb} +32 -23
  232. data/lib/rubocop/cop/lint/{string_conversion_in_interpolation.rb → redundant_string_coercion.rb} +15 -21
  233. data/lib/rubocop/cop/lint/redundant_with_index.rb +17 -18
  234. data/lib/rubocop/cop/lint/redundant_with_object.rb +18 -19
  235. data/lib/rubocop/cop/lint/regexp_as_condition.rb +7 -3
  236. data/lib/rubocop/cop/lint/require_parentheses.rb +6 -3
  237. data/lib/rubocop/cop/lint/rescue_exception.rb +4 -3
  238. data/lib/rubocop/cop/lint/rescue_type.rb +15 -12
  239. data/lib/rubocop/cop/lint/return_in_void_context.rb +4 -6
  240. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +21 -29
  241. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +98 -0
  242. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +46 -0
  243. data/lib/rubocop/cop/lint/script_permission.rb +40 -16
  244. data/lib/rubocop/cop/lint/self_assignment.rb +78 -0
  245. data/lib/rubocop/cop/lint/send_with_mixin_argument.rb +87 -0
  246. data/lib/rubocop/cop/lint/shadowed_argument.rb +51 -15
  247. data/lib/rubocop/cop/lint/shadowed_exception.rb +47 -28
  248. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +9 -9
  249. data/lib/rubocop/cop/lint/struct_new_override.rb +59 -0
  250. data/lib/rubocop/cop/lint/suppressed_exception.rb +89 -0
  251. data/lib/rubocop/cop/lint/syntax.rb +12 -28
  252. data/lib/rubocop/cop/lint/to_json.rb +50 -0
  253. data/lib/rubocop/cop/lint/top_level_return_with_argument.rb +34 -0
  254. data/lib/rubocop/cop/lint/trailing_comma_in_attribute_declaration.rb +57 -0
  255. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +30 -10
  256. data/lib/rubocop/cop/lint/unified_integer.rb +6 -8
  257. data/lib/rubocop/cop/lint/unreachable_code.rb +10 -8
  258. data/lib/rubocop/cop/lint/unreachable_loop.rb +171 -0
  259. data/lib/rubocop/cop/lint/unused_block_argument.rb +30 -9
  260. data/lib/rubocop/cop/lint/unused_method_argument.rb +64 -15
  261. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +19 -16
  262. data/lib/rubocop/cop/lint/uri_regexp.rb +12 -47
  263. data/lib/rubocop/cop/lint/useless_access_modifier.rb +110 -47
  264. data/lib/rubocop/cop/lint/useless_assignment.rb +12 -14
  265. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +10 -11
  266. data/lib/rubocop/cop/lint/useless_method_definition.rb +70 -0
  267. data/lib/rubocop/cop/lint/useless_setter_call.rb +17 -16
  268. data/lib/rubocop/cop/lint/useless_times.rb +106 -0
  269. data/lib/rubocop/cop/lint/void.rb +63 -35
  270. data/lib/rubocop/cop/message_annotator.rb +22 -11
  271. data/lib/rubocop/cop/metrics/abc_size.rb +4 -19
  272. data/lib/rubocop/cop/metrics/block_length.rb +46 -4
  273. data/lib/rubocop/cop/metrics/block_nesting.rb +4 -3
  274. data/lib/rubocop/cop/metrics/class_length.rb +43 -2
  275. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +38 -5
  276. data/lib/rubocop/cop/metrics/method_length.rb +31 -4
  277. data/lib/rubocop/cop/metrics/module_length.rb +35 -2
  278. data/lib/rubocop/cop/metrics/parameter_lists.rb +4 -8
  279. data/lib/rubocop/cop/metrics/perceived_complexity.rb +9 -11
  280. data/lib/rubocop/cop/metrics/utils/abc_size_calculator.rb +138 -0
  281. data/lib/rubocop/cop/metrics/utils/code_length_calculator.rb +158 -0
  282. data/lib/rubocop/cop/metrics/utils/iterating_block.rb +61 -0
  283. data/lib/rubocop/cop/metrics/utils/repeated_csend_discount.rb +37 -0
  284. data/lib/rubocop/cop/migration/department_name.rb +83 -0
  285. data/lib/rubocop/cop/mixin/alignment.rb +12 -6
  286. data/lib/rubocop/cop/mixin/allowed_methods.rb +21 -0
  287. data/lib/rubocop/cop/mixin/annotation_comment.rb +6 -0
  288. data/lib/rubocop/cop/mixin/array_min_size.rb +2 -4
  289. data/lib/rubocop/cop/mixin/array_syntax.rb +1 -1
  290. data/lib/rubocop/cop/mixin/auto_corrector.rb +12 -0
  291. data/lib/rubocop/cop/mixin/check_assignment.rb +13 -9
  292. data/lib/rubocop/cop/mixin/check_line_breakable.rb +193 -0
  293. data/lib/rubocop/cop/mixin/code_length.rb +28 -3
  294. data/lib/rubocop/cop/mixin/comments_help.rb +48 -0
  295. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +8 -5
  296. data/lib/rubocop/cop/mixin/configurable_formatting.rb +4 -7
  297. data/lib/rubocop/cop/mixin/configurable_max.rb +4 -2
  298. data/lib/rubocop/cop/mixin/configurable_naming.rb +2 -2
  299. data/lib/rubocop/cop/mixin/configurable_numbering.rb +3 -3
  300. data/lib/rubocop/cop/mixin/def_node.rb +5 -1
  301. data/lib/rubocop/cop/mixin/documentation_comment.rb +13 -7
  302. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +35 -18
  303. data/lib/rubocop/cop/mixin/empty_parameter.rb +5 -2
  304. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +24 -6
  305. data/lib/rubocop/cop/mixin/enforce_superclass.rb +6 -4
  306. data/lib/rubocop/cop/mixin/first_element_line_break.rb +4 -2
  307. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +31 -6
  308. data/lib/rubocop/cop/mixin/{hash_alignment.rb → hash_alignment_styles.rb} +38 -7
  309. data/lib/rubocop/cop/mixin/hash_transform_method.rb +197 -0
  310. data/lib/rubocop/cop/mixin/heredoc.rb +6 -2
  311. data/lib/rubocop/cop/mixin/ignored_methods.rb +19 -0
  312. data/lib/rubocop/cop/mixin/ignored_pattern.rb +1 -1
  313. data/lib/rubocop/cop/mixin/integer_node.rb +1 -1
  314. data/lib/rubocop/cop/mixin/interpolation.rb +27 -0
  315. data/lib/rubocop/cop/mixin/line_length_help.rb +87 -0
  316. data/lib/rubocop/cop/mixin/match_range.rb +2 -0
  317. data/lib/rubocop/cop/mixin/method_complexity.rb +18 -4
  318. data/lib/rubocop/cop/mixin/method_preference.rb +2 -1
  319. data/lib/rubocop/cop/mixin/min_body_length.rb +1 -1
  320. data/lib/rubocop/cop/mixin/{array_hash_indentation.rb → multiline_element_indentation.rb} +3 -2
  321. data/lib/rubocop/cop/mixin/multiline_element_line_breaks.rb +35 -0
  322. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +42 -13
  323. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +17 -14
  324. data/lib/rubocop/cop/mixin/negative_conditional.rb +3 -3
  325. data/lib/rubocop/cop/mixin/nil_methods.rb +23 -0
  326. data/lib/rubocop/cop/mixin/ordered_gem_node.rb +15 -2
  327. data/lib/rubocop/cop/mixin/parentheses.rb +1 -2
  328. data/lib/rubocop/cop/mixin/percent_array.rb +18 -11
  329. data/lib/rubocop/cop/mixin/percent_literal.rb +3 -65
  330. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +96 -6
  331. data/lib/rubocop/cop/mixin/preferred_delimiters.rb +53 -0
  332. data/lib/rubocop/cop/mixin/range_help.rb +131 -0
  333. data/lib/rubocop/cop/mixin/rational_literal.rb +18 -0
  334. data/lib/rubocop/cop/mixin/rescue_node.rb +13 -4
  335. data/lib/rubocop/cop/mixin/safe_assignment.rb +2 -1
  336. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +13 -11
  337. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +16 -13
  338. data/lib/rubocop/cop/mixin/statement_modifier.rb +48 -18
  339. data/lib/rubocop/cop/mixin/string_literals_help.rb +2 -1
  340. data/lib/rubocop/cop/mixin/surrounding_space.rb +62 -42
  341. data/lib/rubocop/cop/mixin/target_ruby_version.rb +5 -1
  342. data/lib/rubocop/cop/mixin/trailing_body.rb +26 -0
  343. data/lib/rubocop/cop/mixin/trailing_comma.rb +96 -46
  344. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +106 -0
  345. data/lib/rubocop/cop/mixin/unused_argument.rb +4 -6
  346. data/lib/rubocop/cop/mixin/visibility_help.rb +38 -0
  347. data/lib/rubocop/cop/naming/accessor_method_name.rb +6 -4
  348. data/lib/rubocop/cop/naming/ascii_identifiers.rb +33 -7
  349. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +7 -6
  350. data/lib/rubocop/cop/naming/block_parameter_name.rb +49 -0
  351. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +15 -5
  352. data/lib/rubocop/cop/naming/constant_name.rb +35 -11
  353. data/lib/rubocop/cop/naming/file_name.rb +58 -33
  354. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +3 -3
  355. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +10 -14
  356. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +171 -0
  357. data/lib/rubocop/cop/naming/method_name.rb +41 -2
  358. data/lib/rubocop/cop/naming/method_parameter_name.rb +58 -0
  359. data/lib/rubocop/cop/naming/predicate_name.rb +18 -15
  360. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +113 -0
  361. data/lib/rubocop/cop/naming/variable_name.rb +4 -2
  362. data/lib/rubocop/cop/naming/variable_number.rb +3 -3
  363. data/lib/rubocop/cop/offense.rb +64 -13
  364. data/lib/rubocop/cop/registry.rb +118 -14
  365. data/lib/rubocop/cop/security/eval.rb +6 -4
  366. data/lib/rubocop/cop/security/json_load.rb +11 -12
  367. data/lib/rubocop/cop/security/marshal_load.rb +5 -6
  368. data/lib/rubocop/cop/security/open.rb +72 -0
  369. data/lib/rubocop/cop/security/yaml_load.rb +9 -8
  370. data/lib/rubocop/cop/severity.rb +2 -11
  371. data/lib/rubocop/cop/style/access_modifier_declarations.rb +135 -0
  372. data/lib/rubocop/cop/style/accessor_grouping.rb +152 -0
  373. data/lib/rubocop/cop/style/alias.rb +51 -38
  374. data/lib/rubocop/cop/style/and_or.rb +23 -25
  375. data/lib/rubocop/cop/style/array_coercion.rb +67 -0
  376. data/lib/rubocop/cop/style/array_join.rb +10 -11
  377. data/lib/rubocop/cop/style/ascii_comments.rb +7 -4
  378. data/lib/rubocop/cop/style/attr.rb +25 -14
  379. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +8 -8
  380. data/lib/rubocop/cop/style/bare_percent_literals.rb +14 -16
  381. data/lib/rubocop/cop/style/begin_block.rb +9 -3
  382. data/lib/rubocop/cop/style/bisected_attr_accessor.rb +141 -0
  383. data/lib/rubocop/cop/style/block_comments.rb +25 -19
  384. data/lib/rubocop/cop/style/block_delimiters.rb +131 -37
  385. data/lib/rubocop/cop/style/case_equality.rb +55 -5
  386. data/lib/rubocop/cop/style/case_like_if.rb +252 -0
  387. data/lib/rubocop/cop/style/character_literal.rb +3 -3
  388. data/lib/rubocop/cop/style/class_and_module_children.rb +43 -36
  389. data/lib/rubocop/cop/style/class_check.rb +7 -12
  390. data/lib/rubocop/cop/style/class_equality_comparison.rb +64 -0
  391. data/lib/rubocop/cop/style/class_methods.rb +19 -31
  392. data/lib/rubocop/cop/style/class_methods_definitions.rb +157 -0
  393. data/lib/rubocop/cop/style/class_vars.rb +47 -7
  394. data/lib/rubocop/cop/style/collection_methods.rb +40 -18
  395. data/lib/rubocop/cop/style/colon_method_call.rb +11 -13
  396. data/lib/rubocop/cop/style/colon_method_definition.rb +7 -6
  397. data/lib/rubocop/cop/style/combinable_loops.rb +91 -0
  398. data/lib/rubocop/cop/style/command_literal.rb +41 -34
  399. data/lib/rubocop/cop/style/comment_annotation.rb +35 -22
  400. data/lib/rubocop/cop/style/commented_keyword.rb +24 -33
  401. data/lib/rubocop/cop/style/conditional_assignment.rb +108 -138
  402. data/lib/rubocop/cop/style/constant_visibility.rb +78 -0
  403. data/lib/rubocop/cop/style/copyright.rb +39 -28
  404. data/lib/rubocop/cop/style/date_time.rb +55 -11
  405. data/lib/rubocop/cop/style/def_with_parentheses.rb +9 -11
  406. data/lib/rubocop/cop/style/dir.rb +11 -13
  407. data/lib/rubocop/cop/style/disable_cops_within_source_code_directive.rb +47 -0
  408. data/lib/rubocop/cop/style/documentation.rb +62 -23
  409. data/lib/rubocop/cop/style/documentation_method.rb +52 -3
  410. data/lib/rubocop/cop/style/double_cop_disable_directive.rb +52 -0
  411. data/lib/rubocop/cop/style/double_negation.rb +46 -8
  412. data/lib/rubocop/cop/style/each_for_simple_loop.rb +7 -10
  413. data/lib/rubocop/cop/style/each_with_object.rb +30 -19
  414. data/lib/rubocop/cop/style/empty_block_parameter.rb +12 -12
  415. data/lib/rubocop/cop/style/empty_case_condition.rb +36 -12
  416. data/lib/rubocop/cop/style/empty_else.rb +28 -24
  417. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +13 -12
  418. data/lib/rubocop/cop/style/empty_literal.rb +34 -31
  419. data/lib/rubocop/cop/style/empty_method.rb +14 -18
  420. data/lib/rubocop/cop/style/encoding.rb +17 -14
  421. data/lib/rubocop/cop/style/end_block.rb +15 -3
  422. data/lib/rubocop/cop/style/eval_with_location.rb +15 -13
  423. data/lib/rubocop/cop/style/even_odd.rb +13 -16
  424. data/lib/rubocop/cop/style/expand_path_arguments.rb +195 -0
  425. data/lib/rubocop/cop/style/explicit_block_argument.rb +106 -0
  426. data/lib/rubocop/cop/style/exponential_notation.rb +117 -0
  427. data/lib/rubocop/cop/style/float_division.rb +93 -0
  428. data/lib/rubocop/cop/style/for.rb +48 -21
  429. data/lib/rubocop/cop/style/format_string.rb +52 -49
  430. data/lib/rubocop/cop/style/format_string_token.rb +32 -77
  431. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +131 -62
  432. data/lib/rubocop/cop/style/global_std_stream.rb +65 -0
  433. data/lib/rubocop/cop/style/global_vars.rb +5 -5
  434. data/lib/rubocop/cop/style/guard_clause.rb +69 -16
  435. data/lib/rubocop/cop/style/hash_as_last_array_item.rb +88 -0
  436. data/lib/rubocop/cop/style/hash_each_methods.rb +86 -0
  437. data/lib/rubocop/cop/style/hash_like_case.rb +76 -0
  438. data/lib/rubocop/cop/style/hash_syntax.rb +39 -31
  439. data/lib/rubocop/cop/style/hash_transform_keys.rb +91 -0
  440. data/lib/rubocop/cop/style/hash_transform_values.rb +88 -0
  441. data/lib/rubocop/cop/style/identical_conditional_branches.rb +11 -15
  442. data/lib/rubocop/cop/style/if_inside_else.rb +46 -4
  443. data/lib/rubocop/cop/style/if_unless_modifier.rb +114 -46
  444. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +12 -4
  445. data/lib/rubocop/cop/style/if_with_semicolon.rb +18 -4
  446. data/lib/rubocop/cop/style/implicit_runtime_error.rb +3 -2
  447. data/lib/rubocop/cop/style/infinite_loop.rb +64 -27
  448. data/lib/rubocop/cop/style/inline_comment.rb +6 -4
  449. data/lib/rubocop/cop/style/inverse_methods.rb +78 -40
  450. data/lib/rubocop/cop/style/ip_addresses.rb +76 -0
  451. data/lib/rubocop/cop/style/keyword_parameters_order.rb +53 -0
  452. data/lib/rubocop/cop/style/lambda.rb +15 -99
  453. data/lib/rubocop/cop/style/lambda_call.rb +17 -34
  454. data/lib/rubocop/cop/style/line_end_concatenation.rb +37 -28
  455. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +136 -35
  456. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +174 -0
  457. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +48 -0
  458. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +17 -18
  459. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +17 -5
  460. data/lib/rubocop/cop/style/method_def_parentheses.rb +27 -27
  461. data/lib/rubocop/cop/style/min_max.rb +10 -14
  462. data/lib/rubocop/cop/style/missing_else.rb +87 -31
  463. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +53 -0
  464. data/lib/rubocop/cop/style/mixin_grouping.rb +42 -42
  465. data/lib/rubocop/cop/style/mixin_usage.rb +16 -27
  466. data/lib/rubocop/cop/style/module_function.rb +85 -18
  467. data/lib/rubocop/cop/style/multiline_block_chain.rb +16 -5
  468. data/lib/rubocop/cop/style/multiline_if_modifier.rb +5 -12
  469. data/lib/rubocop/cop/style/multiline_if_then.rb +8 -13
  470. data/lib/rubocop/cop/style/multiline_memoization.rb +17 -14
  471. data/lib/rubocop/cop/style/multiline_method_signature.rb +61 -0
  472. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +32 -10
  473. data/lib/rubocop/cop/style/multiline_when_then.rb +73 -0
  474. data/lib/rubocop/cop/style/multiple_comparison.rb +20 -5
  475. data/lib/rubocop/cop/style/mutable_constant.rb +130 -19
  476. data/lib/rubocop/cop/style/negated_if.rb +10 -10
  477. data/lib/rubocop/cop/style/negated_unless.rb +89 -0
  478. data/lib/rubocop/cop/style/negated_while.rb +25 -15
  479. data/lib/rubocop/cop/style/nested_modifier.rb +37 -20
  480. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +26 -24
  481. data/lib/rubocop/cop/style/nested_ternary_operator.rb +41 -3
  482. data/lib/rubocop/cop/style/next.rb +40 -43
  483. data/lib/rubocop/cop/style/nil_comparison.rb +51 -9
  484. data/lib/rubocop/cop/style/non_nil_check.rb +55 -35
  485. data/lib/rubocop/cop/style/not.rb +26 -29
  486. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +43 -25
  487. data/lib/rubocop/cop/style/numeric_literals.rb +28 -15
  488. data/lib/rubocop/cop/style/numeric_predicate.rb +19 -27
  489. data/lib/rubocop/cop/style/one_line_conditional.rb +95 -27
  490. data/lib/rubocop/cop/style/option_hash.rb +14 -3
  491. data/lib/rubocop/cop/style/optional_arguments.rb +4 -7
  492. data/lib/rubocop/cop/style/optional_boolean_parameter.rb +53 -0
  493. data/lib/rubocop/cop/style/or_assignment.rb +27 -16
  494. data/lib/rubocop/cop/style/parallel_assignment.rb +20 -20
  495. data/lib/rubocop/cop/style/parentheses_around_condition.rb +50 -10
  496. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +26 -26
  497. data/lib/rubocop/cop/style/percent_q_literals.rb +10 -12
  498. data/lib/rubocop/cop/style/perl_backrefs.rb +9 -11
  499. data/lib/rubocop/cop/style/preferred_hash_methods.rb +12 -14
  500. data/lib/rubocop/cop/style/proc.rb +9 -9
  501. data/lib/rubocop/cop/style/raise_args.rb +30 -30
  502. data/lib/rubocop/cop/style/random_with_offset.rb +65 -72
  503. data/lib/rubocop/cop/style/redundant_assignment.rb +107 -0
  504. data/lib/rubocop/cop/style/redundant_begin.rb +69 -10
  505. data/lib/rubocop/cop/style/{unneeded_capital_w.rb → redundant_capital_w.rb} +7 -10
  506. data/lib/rubocop/cop/style/redundant_condition.rb +139 -0
  507. data/lib/rubocop/cop/style/redundant_conditional.rb +13 -12
  508. data/lib/rubocop/cop/style/redundant_exception.rb +28 -17
  509. data/lib/rubocop/cop/style/redundant_fetch_block.rb +113 -0
  510. data/lib/rubocop/cop/style/redundant_file_extension_in_require.rb +51 -0
  511. data/lib/rubocop/cop/style/redundant_freeze.rb +29 -9
  512. data/lib/rubocop/cop/style/{unneeded_interpolation.rb → redundant_interpolation.rb} +34 -28
  513. data/lib/rubocop/cop/style/redundant_parentheses.rb +73 -39
  514. data/lib/rubocop/cop/style/{unneeded_percent_q.rb → redundant_percent_q.rb} +36 -23
  515. data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +98 -0
  516. data/lib/rubocop/cop/style/redundant_regexp_escape.rb +105 -0
  517. data/lib/rubocop/cop/style/redundant_return.rb +90 -55
  518. data/lib/rubocop/cop/style/redundant_self.rb +39 -25
  519. data/lib/rubocop/cop/style/redundant_self_assignment.rb +116 -0
  520. data/lib/rubocop/cop/style/redundant_sort.rb +162 -0
  521. data/lib/rubocop/cop/{performance → style}/redundant_sort_by.rb +10 -12
  522. data/lib/rubocop/cop/style/regexp_literal.rb +76 -34
  523. data/lib/rubocop/cop/style/rescue_modifier.rb +55 -10
  524. data/lib/rubocop/cop/style/rescue_standard_error.rb +27 -21
  525. data/lib/rubocop/cop/style/return_nil.rb +9 -9
  526. data/lib/rubocop/cop/style/safe_navigation.rb +130 -50
  527. data/lib/rubocop/cop/{performance → style}/sample.rb +28 -26
  528. data/lib/rubocop/cop/style/self_assignment.rb +27 -23
  529. data/lib/rubocop/cop/style/semicolon.rb +32 -14
  530. data/lib/rubocop/cop/style/send.rb +6 -6
  531. data/lib/rubocop/cop/style/signal_exception.rb +29 -22
  532. data/lib/rubocop/cop/style/single_argument_dig.rb +55 -0
  533. data/lib/rubocop/cop/style/single_line_block_params.rb +25 -3
  534. data/lib/rubocop/cop/style/single_line_methods.rb +31 -32
  535. data/lib/rubocop/cop/style/slicing_with_range.rb +37 -0
  536. data/lib/rubocop/cop/style/sole_nested_conditional.rb +66 -0
  537. data/lib/rubocop/cop/style/special_global_vars.rb +74 -33
  538. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +21 -27
  539. data/lib/rubocop/cop/style/stderr_puts.rb +17 -11
  540. data/lib/rubocop/cop/style/string_concatenation.rb +106 -0
  541. data/lib/rubocop/cop/style/string_hash_keys.rb +22 -9
  542. data/lib/rubocop/cop/style/string_literals.rb +3 -3
  543. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +1 -1
  544. data/lib/rubocop/cop/style/string_methods.rb +8 -17
  545. data/lib/rubocop/cop/style/strip.rb +41 -0
  546. data/lib/rubocop/cop/style/struct_inheritance.rb +34 -9
  547. data/lib/rubocop/cop/style/symbol_array.rb +47 -20
  548. data/lib/rubocop/cop/style/symbol_literal.rb +7 -9
  549. data/lib/rubocop/cop/style/symbol_proc.rb +32 -59
  550. data/lib/rubocop/cop/style/ternary_parentheses.rb +60 -35
  551. data/lib/rubocop/cop/style/trailing_body_on_class.rb +40 -0
  552. data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +12 -62
  553. data/lib/rubocop/cop/style/trailing_body_on_module.rb +40 -0
  554. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +49 -25
  555. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +96 -0
  556. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +90 -0
  557. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +97 -0
  558. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +12 -39
  559. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +20 -23
  560. data/lib/rubocop/cop/style/trivial_accessors.rb +42 -37
  561. data/lib/rubocop/cop/style/unless_else.rb +10 -12
  562. data/lib/rubocop/cop/style/unpack_first.rb +58 -0
  563. data/lib/rubocop/cop/style/variable_interpolation.rb +12 -25
  564. data/lib/rubocop/cop/style/when_then.rb +6 -8
  565. data/lib/rubocop/cop/style/while_until_do.rb +7 -17
  566. data/lib/rubocop/cop/style/while_until_modifier.rb +9 -23
  567. data/lib/rubocop/cop/style/word_array.rb +18 -28
  568. data/lib/rubocop/cop/style/yoda_condition.rb +84 -29
  569. data/lib/rubocop/cop/style/zero_length_predicate.rb +34 -24
  570. data/lib/rubocop/cop/team.rb +160 -91
  571. data/lib/rubocop/cop/util.rb +38 -216
  572. data/lib/rubocop/cop/utils/format_string.rb +135 -0
  573. data/lib/rubocop/cop/variable_force.rb +40 -35
  574. data/lib/rubocop/cop/variable_force/assignment.rb +5 -0
  575. data/lib/rubocop/cop/variable_force/branch.rb +6 -7
  576. data/lib/rubocop/cop/variable_force/branchable.rb +2 -0
  577. data/lib/rubocop/cop/variable_force/scope.rb +7 -0
  578. data/lib/rubocop/cop/variable_force/variable.rb +23 -10
  579. data/lib/rubocop/cop/variable_force/variable_table.rb +4 -3
  580. data/lib/rubocop/cops_documentation_generator.rb +284 -0
  581. data/lib/rubocop/core_ext/string.rb +23 -0
  582. data/lib/rubocop/directive_comment.rb +32 -0
  583. data/lib/rubocop/error.rb +24 -0
  584. data/lib/rubocop/ext/processed_source.rb +18 -0
  585. data/lib/rubocop/ext/regexp_node.rb +62 -0
  586. data/lib/rubocop/file_finder.rb +43 -0
  587. data/lib/rubocop/formatter/auto_gen_config_formatter.rb +17 -0
  588. data/lib/rubocop/formatter/base_formatter.rb +3 -7
  589. data/lib/rubocop/formatter/clang_style_formatter.rb +9 -6
  590. data/lib/rubocop/formatter/disabled_config_formatter.rb +69 -35
  591. data/lib/rubocop/formatter/emacs_style_formatter.rb +22 -9
  592. data/lib/rubocop/formatter/file_list_formatter.rb +2 -1
  593. data/lib/rubocop/formatter/formatter_set.rb +18 -17
  594. data/lib/rubocop/formatter/fuubar_style_formatter.rb +2 -2
  595. data/lib/rubocop/formatter/html_formatter.rb +15 -6
  596. data/lib/rubocop/formatter/json_formatter.rb +14 -13
  597. data/lib/rubocop/formatter/junit_formatter.rb +84 -0
  598. data/lib/rubocop/formatter/offense_count_formatter.rb +17 -0
  599. data/lib/rubocop/formatter/pacman_formatter.rb +80 -0
  600. data/lib/rubocop/formatter/progress_formatter.rb +3 -2
  601. data/lib/rubocop/formatter/quiet_formatter.rb +1 -1
  602. data/lib/rubocop/formatter/simple_text_formatter.rb +54 -11
  603. data/lib/rubocop/formatter/tap_formatter.rb +17 -6
  604. data/lib/rubocop/magic_comment.rb +15 -11
  605. data/lib/rubocop/name_similarity.rb +18 -10
  606. data/lib/rubocop/options.rb +267 -139
  607. data/lib/rubocop/path_util.rb +36 -17
  608. data/lib/rubocop/platform.rb +1 -1
  609. data/lib/rubocop/rake_task.rb +8 -9
  610. data/lib/rubocop/remote_config.rb +24 -9
  611. data/lib/rubocop/result_cache.rb +86 -31
  612. data/lib/rubocop/rspec/cop_helper.rb +14 -38
  613. data/lib/rubocop/rspec/expect_offense.rb +168 -14
  614. data/lib/rubocop/rspec/host_environment_simulation_helper.rb +1 -5
  615. data/lib/rubocop/rspec/shared_contexts.rb +93 -47
  616. data/lib/rubocop/rspec/support.rb +5 -1
  617. data/lib/rubocop/runner.rb +146 -77
  618. data/lib/rubocop/string_interpreter.rb +11 -8
  619. data/lib/rubocop/target_finder.rb +94 -95
  620. data/lib/rubocop/target_ruby.rb +160 -0
  621. data/lib/rubocop/version.rb +15 -5
  622. data/lib/rubocop/yaml_duplication_checker.rb +40 -0
  623. metadata +265 -192
  624. data/config/disabled.yml +0 -128
  625. data/config/enabled.yml +0 -1989
  626. data/lib/rubocop/ast/builder.rb +0 -72
  627. data/lib/rubocop/ast/node.rb +0 -634
  628. data/lib/rubocop/ast/node/and_node.rb +0 -37
  629. data/lib/rubocop/ast/node/args_node.rb +0 -29
  630. data/lib/rubocop/ast/node/array_node.rb +0 -57
  631. data/lib/rubocop/ast/node/block_node.rb +0 -116
  632. data/lib/rubocop/ast/node/case_node.rb +0 -64
  633. data/lib/rubocop/ast/node/def_node.rb +0 -71
  634. data/lib/rubocop/ast/node/ensure_node.rb +0 -25
  635. data/lib/rubocop/ast/node/for_node.rb +0 -61
  636. data/lib/rubocop/ast/node/hash_node.rb +0 -109
  637. data/lib/rubocop/ast/node/if_node.rb +0 -146
  638. data/lib/rubocop/ast/node/keyword_splat_node.rb +0 -45
  639. data/lib/rubocop/ast/node/mixin/basic_literal_node.rb +0 -16
  640. data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +0 -23
  641. data/lib/rubocop/ast/node/mixin/collection_node.rb +0 -15
  642. data/lib/rubocop/ast/node/mixin/conditional_node.rb +0 -45
  643. data/lib/rubocop/ast/node/mixin/hash_element_node.rb +0 -125
  644. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +0 -174
  645. data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +0 -89
  646. data/lib/rubocop/ast/node/mixin/modifier_node.rb +0 -17
  647. data/lib/rubocop/ast/node/mixin/parameterized_node.rb +0 -61
  648. data/lib/rubocop/ast/node/mixin/predicate_operator_node.rb +0 -35
  649. data/lib/rubocop/ast/node/or_node.rb +0 -37
  650. data/lib/rubocop/ast/node/pair_node.rb +0 -64
  651. data/lib/rubocop/ast/node/regexp_node.rb +0 -35
  652. data/lib/rubocop/ast/node/resbody_node.rb +0 -25
  653. data/lib/rubocop/ast/node/send_node.rb +0 -45
  654. data/lib/rubocop/ast/node/str_node.rb +0 -14
  655. data/lib/rubocop/ast/node/super_node.rb +0 -21
  656. data/lib/rubocop/ast/node/symbol_node.rb +0 -20
  657. data/lib/rubocop/ast/node/until_node.rb +0 -43
  658. data/lib/rubocop/ast/node/when_node.rb +0 -61
  659. data/lib/rubocop/ast/node/while_node.rb +0 -43
  660. data/lib/rubocop/ast/node/yield_node.rb +0 -21
  661. data/lib/rubocop/ast/sexp.rb +0 -16
  662. data/lib/rubocop/ast/traversal.rb +0 -171
  663. data/lib/rubocop/cop/layout/align_array.rb +0 -39
  664. data/lib/rubocop/cop/layout/align_hash.rb +0 -235
  665. data/lib/rubocop/cop/layout/indent_heredoc.rb +0 -208
  666. data/lib/rubocop/cop/layout/tab.rb +0 -60
  667. data/lib/rubocop/cop/layout/trailing_blank_lines.rb +0 -80
  668. data/lib/rubocop/cop/lint/end_in_method.rb +0 -40
  669. data/lib/rubocop/cop/lint/handle_exceptions.rb +0 -56
  670. data/lib/rubocop/cop/lint/useless_comparison.rb +0 -28
  671. data/lib/rubocop/cop/metrics/line_length.rb +0 -171
  672. data/lib/rubocop/cop/mixin/classish_length.rb +0 -36
  673. data/lib/rubocop/cop/mixin/parser_diagnostic.rb +0 -37
  674. data/lib/rubocop/cop/mixin/safe_mode.rb +0 -22
  675. data/lib/rubocop/cop/mixin/target_rails_version.rb +0 -16
  676. data/lib/rubocop/cop/mixin/too_many_lines.rb +0 -39
  677. data/lib/rubocop/cop/performance/caller.rb +0 -69
  678. data/lib/rubocop/cop/performance/case_when_splat.rb +0 -172
  679. data/lib/rubocop/cop/performance/casecmp.rb +0 -108
  680. data/lib/rubocop/cop/performance/compare_with_block.rb +0 -117
  681. data/lib/rubocop/cop/performance/count.rb +0 -101
  682. data/lib/rubocop/cop/performance/detect.rb +0 -110
  683. data/lib/rubocop/cop/performance/double_start_end_with.rb +0 -94
  684. data/lib/rubocop/cop/performance/end_with.rb +0 -55
  685. data/lib/rubocop/cop/performance/fixed_size.rb +0 -56
  686. data/lib/rubocop/cop/performance/flat_map.rb +0 -76
  687. data/lib/rubocop/cop/performance/hash_each_methods.rb +0 -129
  688. data/lib/rubocop/cop/performance/lstrip_rstrip.rb +0 -44
  689. data/lib/rubocop/cop/performance/range_include.rb +0 -41
  690. data/lib/rubocop/cop/performance/redundant_block_call.rb +0 -93
  691. data/lib/rubocop/cop/performance/redundant_match.rb +0 -56
  692. data/lib/rubocop/cop/performance/redundant_merge.rb +0 -169
  693. data/lib/rubocop/cop/performance/regexp_match.rb +0 -224
  694. data/lib/rubocop/cop/performance/reverse_each.rb +0 -40
  695. data/lib/rubocop/cop/performance/size.rb +0 -71
  696. data/lib/rubocop/cop/performance/start_with.rb +0 -58
  697. data/lib/rubocop/cop/performance/string_replacement.rb +0 -170
  698. data/lib/rubocop/cop/performance/times_map.rb +0 -71
  699. data/lib/rubocop/cop/performance/unfreeze_string.rb +0 -50
  700. data/lib/rubocop/cop/performance/uri_default_parser.rb +0 -47
  701. data/lib/rubocop/cop/rails/action_filter.rb +0 -117
  702. data/lib/rubocop/cop/rails/active_support_aliases.rb +0 -68
  703. data/lib/rubocop/cop/rails/application_job.rb +0 -40
  704. data/lib/rubocop/cop/rails/application_record.rb +0 -40
  705. data/lib/rubocop/cop/rails/blank.rb +0 -142
  706. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +0 -82
  707. data/lib/rubocop/cop/rails/date.rb +0 -136
  708. data/lib/rubocop/cop/rails/delegate.rb +0 -130
  709. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +0 -51
  710. data/lib/rubocop/cop/rails/dynamic_find_by.rb +0 -82
  711. data/lib/rubocop/cop/rails/enum_uniqueness.rb +0 -45
  712. data/lib/rubocop/cop/rails/environment_comparison.rb +0 -66
  713. data/lib/rubocop/cop/rails/exit.rb +0 -68
  714. data/lib/rubocop/cop/rails/file_path.rb +0 -72
  715. data/lib/rubocop/cop/rails/find_by.rb +0 -52
  716. data/lib/rubocop/cop/rails/find_each.rb +0 -47
  717. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -25
  718. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +0 -84
  719. data/lib/rubocop/cop/rails/http_positional_arguments.rb +0 -102
  720. data/lib/rubocop/cop/rails/inverse_of.rb +0 -218
  721. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +0 -112
  722. data/lib/rubocop/cop/rails/not_null_column.rb +0 -67
  723. data/lib/rubocop/cop/rails/output.rb +0 -32
  724. data/lib/rubocop/cop/rails/output_safety.rb +0 -93
  725. data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -107
  726. data/lib/rubocop/cop/rails/presence.rb +0 -118
  727. data/lib/rubocop/cop/rails/present.rb +0 -143
  728. data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -65
  729. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +0 -133
  730. data/lib/rubocop/cop/rails/relative_date_constant.rb +0 -88
  731. data/lib/rubocop/cop/rails/request_referer.rb +0 -55
  732. data/lib/rubocop/cop/rails/reversible_migration.rb +0 -281
  733. data/lib/rubocop/cop/rails/safe_navigation.rb +0 -90
  734. data/lib/rubocop/cop/rails/save_bang.rb +0 -162
  735. data/lib/rubocop/cop/rails/scope_args.rb +0 -29
  736. data/lib/rubocop/cop/rails/skips_model_validations.rb +0 -70
  737. data/lib/rubocop/cop/rails/time_zone.rb +0 -198
  738. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +0 -95
  739. data/lib/rubocop/cop/rails/unknown_env.rb +0 -63
  740. data/lib/rubocop/cop/rails/validation.rb +0 -64
  741. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -202
  742. data/lib/rubocop/cop/style/method_missing.rb +0 -68
  743. data/lib/rubocop/cop/style/trailing_comma_in_literal.rb +0 -75
  744. data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -57
  745. data/lib/rubocop/node_pattern.rb +0 -560
  746. data/lib/rubocop/processed_source.rb +0 -150
  747. data/lib/rubocop/rspec/shared_examples.rb +0 -92
  748. data/lib/rubocop/string_util.rb +0 -158
  749. data/lib/rubocop/token.rb +0 -103
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9c220d66052a5e9bbd4c5c4b8152f9eb198def00
4
- data.tar.gz: 3b3e355cef47c417d03265e565f7bf1fe94c7b9e
2
+ SHA256:
3
+ metadata.gz: b8ce11205d6a6bb518654cbe498544aa799fbb8d9c9057afd2f551edfc35bbb8
4
+ data.tar.gz: a1f79001991b28508ca7c9a79d75ed58f39ae0dcf2bad419d6a75919b3a3d539
5
5
  SHA512:
6
- metadata.gz: cba8acef3a405e92862d9ae1e1783bbeb6f9d4675fe978068a519a759598a26b2b79b10e0bc688fe0ee2c1b8a0c640316395c65f94903179b0b45a9b091f63b9
7
- data.tar.gz: 3e31e510ef57bd3ccd4b2085398c22b1da1a0a137efa487c4f110b5c1d0d8ad568197d899f05a3b79bd9d281c9933ee8c6d19f134b0d052344ca778e50c07739
6
+ metadata.gz: a32001a91575c41b5ca71b6a148af79f45b2a7b8cbc3909a0dcbb7a652f5e62b6a79a84c14189eda64fd3d2a9e8c40d207c37c0f5a78a156e1f636c5191b995e
7
+ data.tar.gz: 9ac5df57938099031807a96bd87a7fb9c5f7f40c314528b4c3254edb45b1386ce199fa9c394c9e7531655d117df9d3d5215bd66e4a927b9b2b0878e0eac2a1f6
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-17 Bozhidar Batsov
1
+ Copyright (c) 2012-20 Bozhidar Batsov
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,36 +1,33 @@
1
- [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](http://badge.fury.io/rb/rubocop)
2
- [![Dependency Status](https://gemnasium.com/bbatsov/rubocop.svg)](https://gemnasium.com/bbatsov/rubocop)
3
- [![Travis Status](https://travis-ci.org/bbatsov/rubocop.svg?branch=master)](https://travis-ci.org/bbatsov/rubocop)
4
- [![Appveyor status](https://ci.appveyor.com/api/projects/status/e5jdwocv30oqm4sm?svg=true)](https://ci.appveyor.com/project/bbatsov/rubocop)
5
- [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/bbatsov/rubocop.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
- [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
7
- [![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/rubocop-hq/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
3
+ </p>
4
+
5
+ ----------
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
7
+ [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](https://badge.fury.io/rb/rubocop)
8
+ [![CircleCI Status](https://circleci.com/gh/rubocop-hq/rubocop/tree/master.svg?style=svg)](https://circleci.com/gh/rubocop-hq/rubocop/tree/master)
9
+ [![Actions Status](https://github.com/rubocop-hq/rubocop/workflows/CI/badge.svg?branch=master)](https://github.com/rubocop-hq/rubocop/actions?query=workflow%3ACI)
10
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/test_coverage)](https://codeclimate.com/github/rubocop-hq/rubocop/test_coverage)
11
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d2d67f728e88ea84ac69/maintainability)](https://codeclimate.com/github/rubocop-hq/rubocop/maintainability)
12
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=rubocop&package-manager=bundler&version-scheme=semver)
8
13
 
9
14
  [![Patreon](https://img.shields.io/badge/patreon-donate-orange.svg)](https://www.patreon.com/bbatsov)
10
- [![Liberapay](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/bbatsov/donate)
11
15
  [![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
12
16
  [![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
13
-
14
- <p align="center">
15
- <img src="https://raw.githubusercontent.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
16
- </p>
17
+ [![Tidelift](https://tidelift.com/badges/package/rubygems/rubocop)](https://tidelift.com/subscription/pkg/rubygems-rubocop?utm_source=rubygems-rubocop&utm_medium=referral&utm_campaign=readme)
17
18
 
18
19
  > Role models are important. <br/>
19
20
  > -- Officer Alex J. Murphy / RoboCop
20
21
 
21
- **RuboCop** is a Ruby static code analyzer. Out of the box it will
22
- enforce many of the guidelines outlined in the community
23
- [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
24
-
25
- Most aspects of its behavior can be tweaked via various
26
- [configuration options](https://github.com/bbatsov/rubocop/blob/master/config/default.yml).
22
+ **RuboCop** is a Ruby static code analyzer (a.k.a. `linter`) and code formatter. Out of the box it
23
+ will enforce many of the guidelines outlined in the community [Ruby Style
24
+ Guide](https://rubystyle.guide). Apart from reporting the problems discovered in your code,
25
+ RuboCop can also automatically fix many of them for you.
27
26
 
28
- Apart from reporting problems in your code, RuboCop can also
29
- automatically fix some of the problems for you.
27
+ RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various
28
+ [configuration options](https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml).
30
29
 
31
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bbatsov/rubocop?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
32
-
33
- **Please consider [supporting financially its ongoing development](#funding).**
30
+ **Please consider [financially supporting its ongoing development](#funding).**
34
31
 
35
32
  ## Installation
36
33
 
@@ -40,7 +37,7 @@ automatically fix some of the problems for you.
40
37
  $ gem install rubocop
41
38
  ```
42
39
 
43
- If you'd rather install RuboCop using `bundler`, don't require it in your `Gemfile`:
40
+ If you'd rather install RuboCop using `bundler`, add a line for it in your `Gemfile` (but set the `require` option to `false`, as it is a standalone tool):
44
41
 
45
42
  ```rb
46
43
  gem 'rubocop', require: false
@@ -49,10 +46,10 @@ gem 'rubocop', require: false
49
46
  RuboCop's development is moving at a very rapid pace and there are
50
47
  often backward-incompatible changes between minor releases (since we
51
48
  haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
52
- might want to use a conservative version locking in your `Gemfile`:
49
+ might want to use a conservative version lock in your `Gemfile`:
53
50
 
54
51
  ```rb
55
- gem 'rubocop', '~> 0.52.1', require: false
52
+ gem 'rubocop', '~> 0.93.1', require: false
56
53
  ```
57
54
 
58
55
  ## Quickstart
@@ -64,39 +61,53 @@ $ cd my/cool/ruby/project
64
61
  $ rubocop
65
62
  ```
66
63
 
67
- ## Official manual
64
+ ## Documentation
68
65
 
69
- You can read a ton more about RuboCop in its [official manual](http://rubocop.readthedocs.io).
66
+ You can read a lot more about RuboCop in its [official docs](https://docs.rubocop.org).
70
67
 
71
68
  ## Compatibility
72
69
 
73
70
  RuboCop supports the following Ruby implementations:
74
71
 
75
- * MRI 2.1+
76
- * JRuby 9.0+
72
+ * MRI 2.4+
73
+ * JRuby 9.2+
74
+
75
+ See [compatibility](https://docs.rubocop.org/rubocop/compatibility.html) for further details.
76
+
77
+ ## Readme Badge
78
+
79
+ If you use RuboCop in your project, you can include one of these badges in your readme to let people know that your code is written following the community Ruby Style Guide.
80
+
81
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop-hq/rubocop)
82
+
83
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-community-brightgreen.svg)](https://rubystyle.guide)
77
84
 
78
85
  ## Team
79
86
 
80
87
  Here's a list of RuboCop's core developers:
81
88
 
82
- * [Bozhidar Batsov](https://github.com/bbatsov)
89
+ * [Bozhidar Batsov](https://github.com/bbatsov) (author & head maintainer)
83
90
  * [Jonas Arvidsson](https://github.com/jonas054)
84
- * [Yuji Nakayama](https://github.com/yujinakayama)
91
+ * [Yuji Nakayama](https://github.com/yujinakayama) (retired)
85
92
  * [Evgeni Dzhelyov](https://github.com/edzhelyov) (retired)
86
93
  * [Ted Johansson](https://github.com/drenmi)
87
94
  * [Masataka Kuwabara](https://github.com/pocke)
95
+ * [Koichi Ito](https://github.com/koic)
96
+ * [Maxim Krizhanovski](https://github.com/darhazer)
97
+ * [Benjamin Quorning](https://github.com/bquorning)
98
+ * [Marc-André Lafortune](https://github.com/marcandre)
88
99
 
89
100
  ## Logo
90
101
 
91
102
  RuboCop's logo was created by [Dimiter Petrov](https://www.chadomoto.com/). You can find the logo in various
92
- formats [here](https://github.com/bbatsov/rubocop/tree/master/logo).
103
+ formats [here](https://github.com/rubocop-hq/rubocop/tree/master/logo).
93
104
 
94
105
  The logo is licensed under a
95
- [Creative Commons Attribution-NonCommercial 4.0 International License](http://creativecommons.org/licenses/by-nc/4.0/deed.en_GB).
106
+ [Creative Commons Attribution-NonCommercial 4.0 International License](https://creativecommons.org/licenses/by-nc/4.0/deed.en_GB).
96
107
 
97
108
  ## Contributors
98
109
 
99
- Here's a [list](https://github.com/bbatsov/rubocop/graphs/contributors) of
110
+ Here's a [list](https://github.com/rubocop-hq/rubocop/graphs/contributors) of
100
111
  all the people who have contributed to the development of RuboCop.
101
112
 
102
113
  I'm extremely grateful to each and every one of them!
@@ -129,9 +140,9 @@ If you're working in a company that's making significant use of RuboCop we'd app
129
140
  to become a RuboCop sponsor.
130
141
 
131
142
  You can support the development of RuboCop via
132
- [Salt](https://salt.bountysource.com/teams/rubocop),
143
+ [GitHub Sponsors](https://github.com/sponsors/bbatsov),
133
144
  [Patreon](https://www.patreon.com/bbatsov),
134
- [Liberapay](https://liberapay.com/bbatsov/donate),
145
+ [PayPal](https://paypal.me/bbatsov)
135
146
  and [Open Collective](https://opencollective.com/rubocop).
136
147
 
137
148
  ### Open Collective Backers
@@ -210,5 +221,5 @@ RuboCop's changelog is available [here](CHANGELOG.md).
210
221
 
211
222
  ## Copyright
212
223
 
213
- Copyright (c) 2012-2017 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
224
+ Copyright (c) 2012-2020 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
214
225
  further details.
@@ -254,7 +254,7 @@
254
254
  <% end %>
255
255
  </div>
256
256
  <footer>
257
- Generated by <a href="https://github.com/bbatsov/rubocop">RuboCop</a>
257
+ Generated by <a href="https://github.com/rubocop-hq/rubocop">RuboCop</a>
258
258
  <span class="version"><%= RuboCop::Version::STRING %></span>
259
259
  </footer>
260
260
  </body>
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'pry'
6
+ require 'rubocop'
7
+
8
+ ARGV.clear
9
+
10
+ RuboCop.pry
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ if ARGV.include?('-h') || ARGV.include?('--help')
5
+ puts "Usage: same as main `rubocop` command but gathers profiling info"
6
+ puts "Additional option: `--memory` to print memory usage"
7
+ exit(0)
8
+ end
9
+ with_mem = ARGV.delete('--memory')
10
+ ARGV.unshift '--cache', 'false' unless ARGV.include?('--cache')
11
+
12
+ require 'stackprof'
13
+ if with_mem
14
+ require 'memory_profiler'
15
+ MemoryProfiler.start
16
+ end
17
+ StackProf.start
18
+ start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
19
+ begin
20
+ load "#{__dir__}/../exe/rubocop"
21
+ ensure
22
+ delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
23
+ puts "Finished in #{delta.round(1)} seconds"
24
+ StackProf.stop
25
+ if with_mem
26
+ puts "Building memory report..."
27
+ report = MemoryProfiler.stop
28
+ end
29
+ Dir.mkdir('tmp') unless File.exist?('tmp')
30
+ StackProf.results('tmp/stackprof.dump')
31
+ report&.pretty_print(scale_bytes: true)
32
+ end
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ bundle install
data/config/default.yml CHANGED
@@ -1,16 +1,20 @@
1
- # This is the default configuration file. Enabling and disabling is configured
2
- # in separate files. This file adds all other parameters apart from Enabled.
3
-
4
- inherit_from:
5
- - enabled.yml
6
- - disabled.yml
7
-
8
1
  # Common configuration.
2
+
9
3
  AllCops:
4
+ RubyInterpreters:
5
+ - ruby
6
+ - macruby
7
+ - rake
8
+ - jruby
9
+ - rbx
10
10
  # Include common Ruby source files.
11
11
  Include:
12
+ - '**/*.rb'
13
+ - '**/*.arb'
14
+ - '**/*.axlsx'
12
15
  - '**/*.builder'
13
16
  - '**/*.fcgi'
17
+ - '**/*.gemfile'
14
18
  - '**/*.gemspec'
15
19
  - '**/*.god'
16
20
  - '**/*.jb'
@@ -31,8 +35,8 @@ AllCops:
31
35
  - '**/*.watchr'
32
36
  - '**/.irbrc'
33
37
  - '**/.pryrc'
38
+ - '**/.simplecov'
34
39
  - '**/buildfile'
35
- - '**/config.ru'
36
40
  - '**/Appraisals'
37
41
  - '**/Berksfile'
38
42
  - '**/Brewfile'
@@ -50,13 +54,17 @@ AllCops:
50
54
  - '**/Podfile'
51
55
  - '**/Puppetfile'
52
56
  - '**/Rakefile'
57
+ - '**/rakefile'
53
58
  - '**/Snapfile'
59
+ - '**/Steepfile'
54
60
  - '**/Thorfile'
55
61
  - '**/Vagabondfile'
56
62
  - '**/Vagrantfile'
57
63
  Exclude:
58
64
  - 'node_modules/**/*'
65
+ - 'tmp/**/*'
59
66
  - 'vendor/**/*'
67
+ - '.git/**/*'
60
68
  # Default formatter will be used if no `-f/--format` option is given.
61
69
  DefaultFormatter: progress
62
70
  # Cop names are displayed in offense messages by default. Change behavior
@@ -69,7 +77,7 @@ AllCops:
69
77
  DisplayStyleGuide: false
70
78
  # When specifying style guide URLs, any paths and/or fragments will be
71
79
  # evaluated relative to the base URL.
72
- StyleGuideBaseURL: https://github.com/bbatsov/ruby-style-guide
80
+ StyleGuideBaseURL: https://rubystyle.guide
73
81
  # Extra details are not displayed in offense messages by default. Change
74
82
  # behavior by overriding ExtraDetails, or by giving the
75
83
  # `-E/--extra-details` option.
@@ -78,19 +86,27 @@ AllCops:
78
86
  # default. Change behavior by overriding `StyleGuideCopsOnly`, or by giving
79
87
  # the `--only-guide-cops` option.
80
88
  StyleGuideCopsOnly: false
81
- # All cops except the ones in disabled.yml are enabled by default. Change
82
- # this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`.
89
+ # All cops except the ones configured `Enabled: false` in this file are enabled by default.
90
+ # Change this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`.
83
91
  # When `DisabledByDefault` is `true`, all cops in the default configuration
84
92
  # are disabled, and only cops in user configuration are enabled. This makes
85
93
  # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`,
86
94
  # cops in user configuration will be enabled even if they don't set the
87
95
  # Enabled parameter.
88
- # When `EnabledByDefault` is `true`, all cops, even those in disabled.yml,
89
- # are enabled by default. Cops can still be disabled in user configuration.
96
+ # When `EnabledByDefault` is `true`, all cops, even those configured `Enabled: false`
97
+ # in this file are enabled by default. Cops can still be disabled in user configuration.
90
98
  # Note that it is invalid to set both EnabledByDefault and DisabledByDefault
91
99
  # to true in the same configuration.
92
100
  EnabledByDefault: false
93
101
  DisabledByDefault: false
102
+ # New cops introduced between major versions are set to a special pending status
103
+ # and are not enabled by default with warning message.
104
+ # Change this behavior by overriding either `NewCops: enable` or `NewCops: disable`.
105
+ # When `NewCops` is `enable`, pending cops are enabled in bulk. Can be overridden by
106
+ # the `--enable-pending-cops` command-line option.
107
+ # When `NewCops` is `disable`, pending cops are disabled in bulk. Can be overridden by
108
+ # the `--disable-pending-cops` command-line option.
109
+ NewCops: pending
94
110
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
95
111
  # line option.
96
112
  UseCache: true
@@ -101,6 +117,8 @@ AllCops:
101
117
  # CacheRootDirectory is ~ (nil), which it is by default, the root will be
102
118
  # taken from the environment variable `$XDG_CACHE_HOME` if it is set, or if
103
119
  # `$XDG_CACHE_HOME` is not set, it will be `$HOME/.cache/`.
120
+ # The CacheRootDirectory can be overwritten by passing the `--cache-root` command
121
+ # line option or by setting `$RUBOCOP_CACHE_ROOT` environment variable.
104
122
  CacheRootDirectory: ~
105
123
  # It is possible for a malicious user to know the location of RuboCop's cache
106
124
  # directory by looking at CacheRootDirectory, and create a symlink in its
@@ -111,16 +129,111 @@ AllCops:
111
129
  AllowSymlinksInCacheRootDirectory: false
112
130
  # What MRI version of the Ruby interpreter is the inspected code intended to
113
131
  # run on? (If there is more than one, set this to the lowest version.)
114
- # If a value is specified for TargetRubyVersion then it is used.
115
- # Else if .ruby-version exists and it contains an MRI version it is used.
116
- # Otherwise we fallback to the oldest officially supported Ruby version (2.1).
132
+ # If a value is specified for TargetRubyVersion then it is used. Acceptable
133
+ # values are specificed as a float (i.e. 2.5); the teeny version of Ruby
134
+ # should not be included. If the project specifies a Ruby version in the
135
+ # .ruby-version file, Gemfile or gems.rb file, RuboCop will try to determine
136
+ # the desired version of Ruby by inspecting the .ruby-version file first,
137
+ # followed by the Gemfile.lock or gems.locked file. (Although the Ruby version
138
+ # is specified in the Gemfile or gems.rb file, RuboCop reads the final value
139
+ # from the lock file.) If the Ruby version is still unresolved, RuboCop will
140
+ # use the oldest officially supported Ruby version (currently Ruby 2.4).
117
141
  TargetRubyVersion: ~
118
- TargetRailsVersion: 5.0
142
+
143
+ #################### Bundler ###############################
144
+
145
+ Bundler/DuplicatedGem:
146
+ Description: 'Checks for duplicate gem entries in Gemfile.'
147
+ Enabled: true
148
+ VersionAdded: '0.46'
149
+ Include:
150
+ - '**/*.gemfile'
151
+ - '**/Gemfile'
152
+ - '**/gems.rb'
153
+
154
+ Bundler/GemComment:
155
+ Description: 'Add a comment describing each gem.'
156
+ Enabled: false
157
+ VersionAdded: '0.59'
158
+ VersionChanged: '0.85'
159
+ Include:
160
+ - '**/*.gemfile'
161
+ - '**/Gemfile'
162
+ - '**/gems.rb'
163
+ IgnoredGems: []
164
+ OnlyFor: []
165
+
166
+ Bundler/InsecureProtocolSource:
167
+ Description: >-
168
+ The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated
169
+ because HTTP requests are insecure. Please change your source to
170
+ 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
171
+ Enabled: true
172
+ VersionAdded: '0.50'
173
+ Include:
174
+ - '**/*.gemfile'
175
+ - '**/Gemfile'
176
+ - '**/gems.rb'
177
+
178
+ Bundler/OrderedGems:
179
+ Description: >-
180
+ Gems within groups in the Gemfile should be alphabetically sorted.
181
+ Enabled: true
182
+ VersionAdded: '0.46'
183
+ VersionChanged: '0.47'
184
+ TreatCommentsAsGroupSeparators: true
185
+ # By default, "-" and "_" are ignored for order purposes.
186
+ # This can be overridden by setting this parameter to true.
187
+ ConsiderPunctuation: false
188
+ Include:
189
+ - '**/*.gemfile'
190
+ - '**/Gemfile'
191
+ - '**/gems.rb'
192
+
193
+ #################### Gemspec ###############################
194
+
195
+ Gemspec/DuplicatedAssignment:
196
+ Description: 'An attribute assignment method calls should be listed only once in a gemspec.'
197
+ Enabled: true
198
+ VersionAdded: '0.52'
199
+ Include:
200
+ - '**/*.gemspec'
201
+
202
+ Gemspec/OrderedDependencies:
203
+ Description: >-
204
+ Dependencies in the gemspec should be alphabetically sorted.
205
+ Enabled: true
206
+ VersionAdded: '0.51'
207
+ TreatCommentsAsGroupSeparators: true
208
+ # By default, "-" and "_" are ignored for order purposes.
209
+ # This can be overridden by setting this parameter to true.
210
+ ConsiderPunctuation: false
211
+ Include:
212
+ - '**/*.gemspec'
213
+
214
+ Gemspec/RequiredRubyVersion:
215
+ Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
216
+ Enabled: true
217
+ VersionAdded: '0.52'
218
+ VersionChanged: '0.89'
219
+ Include:
220
+ - '**/*.gemspec'
221
+
222
+ Gemspec/RubyVersionGlobalsUsage:
223
+ Description: Checks usage of RUBY_VERSION in gemspec.
224
+ StyleGuide: '#no-ruby-version-in-the-gemspec'
225
+ Enabled: true
226
+ VersionAdded: '0.72'
227
+ Include:
228
+ - '**/*.gemspec'
119
229
 
120
230
  #################### Layout ###########################
121
231
 
122
- # Indent private/protected/public as deep as method definitions
123
232
  Layout/AccessModifierIndentation:
233
+ Description: Check indentation of private/protected visibility modifiers.
234
+ StyleGuide: '#indent-public-private-protected'
235
+ Enabled: true
236
+ VersionAdded: '0.49'
124
237
  EnforcedStyle: indent
125
238
  SupportedStyles:
126
239
  - outdent
@@ -129,82 +242,17 @@ Layout/AccessModifierIndentation:
129
242
  # But it can be overridden by setting this parameter
130
243
  IndentationWidth: ~
131
244
 
132
- # Align the elements of a hash literal if they span more than one line.
133
- Layout/AlignHash:
134
- # Alignment of entries using hash rocket as separator. Valid values are:
245
+ Layout/ArgumentAlignment:
246
+ Description: >-
247
+ Align the arguments of a method call if they span more
248
+ than one line.
249
+ StyleGuide: '#no-double-indent'
250
+ Enabled: true
251
+ VersionAdded: '0.68'
252
+ VersionChanged: '0.77'
253
+ # Alignment of arguments in multi-line method calls.
135
254
  #
136
- # key - left alignment of keys
137
- # 'a' => 2
138
- # 'bb' => 3
139
- # separator - alignment of hash rockets, keys are right aligned
140
- # 'a' => 2
141
- # 'bb' => 3
142
- # table - left alignment of keys, hash rockets, and values
143
- # 'a' => 2
144
- # 'bb' => 3
145
- EnforcedHashRocketStyle: key
146
- SupportedHashRocketStyles:
147
- - key
148
- - separator
149
- - table
150
- # Alignment of entries using colon as separator. Valid values are:
151
- #
152
- # key - left alignment of keys
153
- # a: 0
154
- # bb: 1
155
- # separator - alignment of colons, keys are right aligned
156
- # a: 0
157
- # bb: 1
158
- # table - left alignment of keys and values
159
- # a: 0
160
- # bb: 1
161
- EnforcedColonStyle: key
162
- SupportedColonStyles:
163
- - key
164
- - separator
165
- - table
166
- # Select whether hashes that are the last argument in a method call should be
167
- # inspected? Valid values are:
168
- #
169
- # always_inspect - Inspect both implicit and explicit hashes.
170
- # Registers an offense for:
171
- # function(a: 1,
172
- # b: 2)
173
- # Registers an offense for:
174
- # function({a: 1,
175
- # b: 2})
176
- # always_ignore - Ignore both implicit and explicit hashes.
177
- # Accepts:
178
- # function(a: 1,
179
- # b: 2)
180
- # Accepts:
181
- # function({a: 1,
182
- # b: 2})
183
- # ignore_implicit - Ignore only implicit hashes.
184
- # Accepts:
185
- # function(a: 1,
186
- # b: 2)
187
- # Registers an offense for:
188
- # function({a: 1,
189
- # b: 2})
190
- # ignore_explicit - Ignore only explicit hashes.
191
- # Accepts:
192
- # function({a: 1,
193
- # b: 2})
194
- # Registers an offense for:
195
- # function(a: 1,
196
- # b: 2)
197
- EnforcedLastArgumentHashStyle: always_inspect
198
- SupportedLastArgumentHashStyles:
199
- - always_inspect
200
- - always_ignore
201
- - ignore_implicit
202
- - ignore_explicit
203
-
204
- Layout/AlignParameters:
205
- # Alignment of parameters in multi-line method calls.
206
- #
207
- # The `with_first_parameter` style aligns the following lines along the same
255
+ # The `with_first_argument` style aligns the following lines along the same
208
256
  # column as the first parameter.
209
257
  #
210
258
  # method_call(a,
@@ -215,16 +263,92 @@ Layout/AlignParameters:
215
263
  #
216
264
  # method_call(a,
217
265
  # b)
218
- EnforcedStyle: with_first_parameter
266
+ EnforcedStyle: with_first_argument
219
267
  SupportedStyles:
220
- - with_first_parameter
268
+ - with_first_argument
269
+ - with_fixed_indentation
270
+ # By default, the indentation width from Layout/IndentationWidth is used
271
+ # But it can be overridden by setting this parameter
272
+ IndentationWidth: ~
273
+
274
+ Layout/ArrayAlignment:
275
+ Description: >-
276
+ Align the elements of an array literal if they span more than
277
+ one line.
278
+ StyleGuide: '#no-double-indent'
279
+ Enabled: true
280
+ VersionAdded: '0.49'
281
+ VersionChanged: '0.77'
282
+ # Alignment of elements of a multi-line array.
283
+ #
284
+ # The `with_first_parameter` style aligns the following lines along the same
285
+ # column as the first element.
286
+ #
287
+ # array = [1, 2, 3,
288
+ # 4, 5, 6]
289
+ #
290
+ # The `with_fixed_indentation` style aligns the following lines with one
291
+ # level of indentation relative to the start of the line with start of array.
292
+ #
293
+ # array = [1, 2, 3,
294
+ # 4, 5, 6]
295
+ EnforcedStyle: with_first_element
296
+ SupportedStyles:
297
+ - with_first_element
221
298
  - with_fixed_indentation
222
299
  # By default, the indentation width from Layout/IndentationWidth is used
223
300
  # But it can be overridden by setting this parameter
224
301
  IndentationWidth: ~
225
302
 
226
- # Indentation of `when`.
303
+ Layout/AssignmentIndentation:
304
+ Description: >-
305
+ Checks the indentation of the first line of the
306
+ right-hand-side of a multi-line assignment.
307
+ Enabled: true
308
+ VersionAdded: '0.49'
309
+ VersionChanged: '0.77'
310
+ # By default, the indentation width from `Layout/IndentationWidth` is used
311
+ # But it can be overridden by setting this parameter
312
+ IndentationWidth: ~
313
+
314
+ Layout/BeginEndAlignment:
315
+ Description: 'Align ends corresponding to begins correctly.'
316
+ Enabled: pending
317
+ VersionAdded: '0.91'
318
+ # The value `start_of_line` means that `end` should be aligned the start of the line
319
+ # where the `begin` keyword is.
320
+ # The value `begin` means that `end` should be aligned with the `begin` keyword.
321
+ EnforcedStyleAlignWith: start_of_line
322
+ SupportedStylesAlignWith:
323
+ - start_of_line
324
+ - begin
325
+ Severity: warning
326
+
327
+ Layout/BlockAlignment:
328
+ Description: 'Align block ends correctly.'
329
+ Enabled: true
330
+ VersionAdded: '0.53'
331
+ # The value `start_of_block` means that the `end` should be aligned with line
332
+ # where the `do` keyword appears.
333
+ # The value `start_of_line` means it should be aligned with the whole
334
+ # expression's starting line.
335
+ # The value `either` means both are allowed.
336
+ EnforcedStyleAlignWith: either
337
+ SupportedStylesAlignWith:
338
+ - either
339
+ - start_of_block
340
+ - start_of_line
341
+
342
+ Layout/BlockEndNewline:
343
+ Description: 'Put end statement of multiline block on its own line.'
344
+ Enabled: true
345
+ VersionAdded: '0.49'
346
+
227
347
  Layout/CaseIndentation:
348
+ Description: 'Indentation of when in a case/when/[else/]end.'
349
+ StyleGuide: '#indent-when-to-case'
350
+ Enabled: true
351
+ VersionAdded: '0.49'
228
352
  EnforcedStyle: case
229
353
  SupportedStyles:
230
354
  - case
@@ -235,36 +359,201 @@ Layout/CaseIndentation:
235
359
  # This only matters if `IndentOneStep` is `true`
236
360
  IndentationWidth: ~
237
361
 
238
- # Multi-line method chaining should be done with leading dots.
362
+ Layout/ClassStructure:
363
+ Description: 'Enforces a configured order of definitions within a class body.'
364
+ StyleGuide: '#consistent-classes'
365
+ Enabled: false
366
+ VersionAdded: '0.52'
367
+ Categories:
368
+ module_inclusion:
369
+ - include
370
+ - prepend
371
+ - extend
372
+ ExpectedOrder:
373
+ - module_inclusion
374
+ - constants
375
+ - public_class_methods
376
+ - initializer
377
+ - public_methods
378
+ - protected_methods
379
+ - private_methods
380
+
381
+ Layout/ClosingHeredocIndentation:
382
+ Description: 'Checks the indentation of here document closings.'
383
+ Enabled: true
384
+ VersionAdded: '0.57'
385
+
386
+ Layout/ClosingParenthesisIndentation:
387
+ Description: 'Checks the indentation of hanging closing parentheses.'
388
+ Enabled: true
389
+ VersionAdded: '0.49'
390
+
391
+ Layout/CommentIndentation:
392
+ Description: 'Indentation of comments.'
393
+ Enabled: true
394
+ VersionAdded: '0.49'
395
+
396
+ Layout/ConditionPosition:
397
+ Description: >-
398
+ Checks for condition placed in a confusing position relative to
399
+ the keyword.
400
+ StyleGuide: '#same-line-condition'
401
+ Enabled: true
402
+ VersionAdded: '0.53'
403
+ VersionChanged: '0.83'
404
+
405
+ Layout/DefEndAlignment:
406
+ Description: 'Align ends corresponding to defs correctly.'
407
+ Enabled: true
408
+ VersionAdded: '0.53'
409
+ # The value `def` means that `end` should be aligned with the def keyword.
410
+ # The value `start_of_line` means that `end` should be aligned with method
411
+ # calls like `private`, `public`, etc, if present in front of the `def`
412
+ # keyword on the same line.
413
+ EnforcedStyleAlignWith: start_of_line
414
+ SupportedStylesAlignWith:
415
+ - start_of_line
416
+ - def
417
+ Severity: warning
418
+
239
419
  Layout/DotPosition:
420
+ Description: 'Checks the position of the dot in multi-line method calls.'
421
+ StyleGuide: '#consistent-multi-line-chains'
422
+ Enabled: true
423
+ VersionAdded: '0.49'
240
424
  EnforcedStyle: leading
241
425
  SupportedStyles:
242
426
  - leading
243
427
  - trailing
244
428
 
245
- # Use empty lines between defs.
429
+ Layout/ElseAlignment:
430
+ Description: 'Align elses and elsifs correctly.'
431
+ Enabled: true
432
+ VersionAdded: '0.49'
433
+
434
+ Layout/EmptyComment:
435
+ Description: 'Checks empty comment.'
436
+ Enabled: true
437
+ VersionAdded: '0.53'
438
+ AllowBorderComment: true
439
+ AllowMarginComment: true
440
+
441
+ Layout/EmptyLineAfterGuardClause:
442
+ Description: 'Add empty line after guard clause.'
443
+ Enabled: true
444
+ VersionAdded: '0.56'
445
+ VersionChanged: '0.59'
446
+
447
+ Layout/EmptyLineAfterMagicComment:
448
+ Description: 'Add an empty line after magic comments to separate them from code.'
449
+ StyleGuide: '#separate-magic-comments-from-code'
450
+ Enabled: true
451
+ VersionAdded: '0.49'
452
+
453
+ Layout/EmptyLineAfterMultilineCondition:
454
+ Description: 'Enforces empty line after multiline condition.'
455
+ # This is disabled, because this style is not very common in practice.
456
+ Enabled: false
457
+ VersionAdded: '0.90'
458
+ Reference:
459
+ - https://github.com/airbnb/ruby#multiline-if-newline
460
+
246
461
  Layout/EmptyLineBetweenDefs:
462
+ Description: 'Use empty lines between defs.'
463
+ StyleGuide: '#empty-lines-between-methods'
464
+ Enabled: true
465
+ VersionAdded: '0.49'
247
466
  # If `true`, this parameter means that single line method definitions don't
248
467
  # need an empty line between them.
249
468
  AllowAdjacentOneLineDefs: false
250
469
  # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
251
470
  NumberOfEmptyLines: 1
252
471
 
472
+ Layout/EmptyLines:
473
+ Description: "Don't use several empty lines in a row."
474
+ StyleGuide: '#two-or-more-empty-lines'
475
+ Enabled: true
476
+ VersionAdded: '0.49'
477
+
478
+ Layout/EmptyLinesAroundAccessModifier:
479
+ Description: "Keep blank lines around access modifiers."
480
+ StyleGuide: '#empty-lines-around-access-modifier'
481
+ Enabled: true
482
+ VersionAdded: '0.49'
483
+ EnforcedStyle: around
484
+ SupportedStyles:
485
+ - around
486
+ - only_before
487
+ Reference:
488
+ # A reference to `EnforcedStyle: only_before`.
489
+ - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
490
+
491
+ Layout/EmptyLinesAroundArguments:
492
+ Description: "Keeps track of empty lines around method arguments."
493
+ Enabled: true
494
+ VersionAdded: '0.52'
495
+
496
+ Layout/EmptyLinesAroundAttributeAccessor:
497
+ Description: "Keep blank lines around attribute accessors."
498
+ StyleGuide: '#empty-lines-around-attribute-accessor'
499
+ Enabled: pending
500
+ VersionAdded: '0.83'
501
+ VersionChanged: '0.84'
502
+ AllowAliasSyntax: true
503
+ AllowedMethods:
504
+ - alias_method
505
+ - public
506
+ - protected
507
+ - private
508
+
509
+ Layout/EmptyLinesAroundBeginBody:
510
+ Description: "Keeps track of empty lines around begin-end bodies."
511
+ StyleGuide: '#empty-lines-around-bodies'
512
+ Enabled: true
513
+ VersionAdded: '0.49'
514
+
253
515
  Layout/EmptyLinesAroundBlockBody:
516
+ Description: "Keeps track of empty lines around block bodies."
517
+ StyleGuide: '#empty-lines-around-bodies'
518
+ Enabled: true
519
+ VersionAdded: '0.49'
254
520
  EnforcedStyle: no_empty_lines
255
521
  SupportedStyles:
256
522
  - empty_lines
257
523
  - no_empty_lines
258
524
 
259
525
  Layout/EmptyLinesAroundClassBody:
526
+ Description: "Keeps track of empty lines around class bodies."
527
+ StyleGuide: '#empty-lines-around-bodies'
528
+ Enabled: true
529
+ VersionAdded: '0.49'
530
+ VersionChanged: '0.53'
260
531
  EnforcedStyle: no_empty_lines
261
532
  SupportedStyles:
262
533
  - empty_lines
263
534
  - empty_lines_except_namespace
264
535
  - empty_lines_special
265
536
  - no_empty_lines
537
+ - beginning_only
538
+ - ending_only
539
+
540
+ Layout/EmptyLinesAroundExceptionHandlingKeywords:
541
+ Description: "Keeps track of empty lines around exception handling keywords."
542
+ StyleGuide: '#empty-lines-around-bodies'
543
+ Enabled: true
544
+ VersionAdded: '0.49'
545
+
546
+ Layout/EmptyLinesAroundMethodBody:
547
+ Description: "Keeps track of empty lines around method bodies."
548
+ StyleGuide: '#empty-lines-around-bodies'
549
+ Enabled: true
550
+ VersionAdded: '0.49'
266
551
 
267
552
  Layout/EmptyLinesAroundModuleBody:
553
+ Description: "Keeps track of empty lines around module bodies."
554
+ StyleGuide: '#empty-lines-around-bodies'
555
+ Enabled: true
556
+ VersionAdded: '0.49'
268
557
  EnforcedStyle: no_empty_lines
269
558
  SupportedStyles:
270
559
  - empty_lines
@@ -272,7 +561,29 @@ Layout/EmptyLinesAroundModuleBody:
272
561
  - empty_lines_special
273
562
  - no_empty_lines
274
563
 
564
+ Layout/EndAlignment:
565
+ Description: 'Align ends correctly.'
566
+ Enabled: true
567
+ VersionAdded: '0.53'
568
+ # The value `keyword` means that `end` should be aligned with the matching
569
+ # keyword (`if`, `while`, etc.).
570
+ # The value `variable` means that in assignments, `end` should be aligned
571
+ # with the start of the variable on the left hand side of `=`. In all other
572
+ # situations, `end` should still be aligned with the keyword.
573
+ # The value `start_of_line` means that `end` should be aligned with the start
574
+ # of the line which the matching keyword appears on.
575
+ EnforcedStyleAlignWith: keyword
576
+ SupportedStylesAlignWith:
577
+ - keyword
578
+ - variable
579
+ - start_of_line
580
+ Severity: warning
581
+
275
582
  Layout/EndOfLine:
583
+ Description: 'Use Unix-style line endings.'
584
+ StyleGuide: '#crlf'
585
+ Enabled: true
586
+ VersionAdded: '0.49'
276
587
  # The `native` style means that CR+LF (Carriage Return + Line Feed) is
277
588
  # enforced on Windows, and LF is enforced on other platforms. The other styles
278
589
  # mean LF and CR+LF, respectively.
@@ -283,19 +594,33 @@ Layout/EndOfLine:
283
594
  - crlf
284
595
 
285
596
  Layout/ExtraSpacing:
597
+ Description: 'Do not use unnecessary spacing.'
598
+ Enabled: true
599
+ VersionAdded: '0.49'
286
600
  # When true, allows most uses of extra spacing if the intent is to align
287
601
  # things with the previous or next line, not counting empty lines or comment
288
602
  # lines.
289
603
  AllowForAlignment: true
604
+ # When true, allows things like 'obj.meth(arg) # comment',
605
+ # rather than insisting on 'obj.meth(arg) # comment'.
606
+ # If done for alignment, either this OR AllowForAlignment will allow it.
607
+ AllowBeforeTrailingComments: false
290
608
  # When true, forces the alignment of `=` in assignments on consecutive lines.
291
609
  ForceEqualSignAlignment: false
292
610
 
293
- Layout/FirstParameterIndentation:
611
+ Layout/FirstArgumentIndentation:
612
+ Description: 'Checks the indentation of the first argument in a method call.'
613
+ Enabled: true
614
+ VersionAdded: '0.68'
615
+ VersionChanged: '0.77'
294
616
  EnforcedStyle: special_for_inner_method_call_in_parentheses
295
617
  SupportedStyles:
296
618
  # The first parameter should always be indented one step more than the
297
619
  # preceding line.
298
620
  - consistent
621
+ # The first parameter should always be indented one level relative to the
622
+ # parent that is receiving the parameter
623
+ - consistent_relative_to_receiver
299
624
  # The first parameter should normally be indented one step more than the
300
625
  # preceding line, but if it's a parameter for a method call that is itself
301
626
  # a parameter in a method call, then the inner parameter should be indented
@@ -308,25 +633,13 @@ Layout/FirstParameterIndentation:
308
633
  # But it can be overridden by setting this parameter
309
634
  IndentationWidth: ~
310
635
 
311
- Layout/IndentationConsistency:
312
- # The difference between `rails` and `normal` is that the `rails` style
313
- # prescribes that in classes and modules the `protected` and `private`
314
- # modifier keywords shall be indented the same as public methods and that
315
- # protected and private members shall be indented one step more than the
316
- # modifiers. Other than that, both styles mean that entities on the same
317
- # logical depth shall have the same indentation.
318
- EnforcedStyle: normal
319
- SupportedStyles:
320
- - normal
321
- - rails
322
-
323
- Layout/IndentationWidth:
324
- # Number of spaces for each indentation level.
325
- Width: 2
326
- IgnoredPatterns: []
327
-
328
- # Checks the indentation of the first element in an array literal.
329
- Layout/IndentArray:
636
+ Layout/FirstArrayElementIndentation:
637
+ Description: >-
638
+ Checks the indentation of the first element in an array
639
+ literal.
640
+ Enabled: true
641
+ VersionAdded: '0.68'
642
+ VersionChanged: '0.77'
330
643
  # The value `special_inside_parentheses` means that array literals with
331
644
  # brackets that have their opening bracket on the same line as a surrounding
332
645
  # opening round parenthesis, shall have their first element indented relative
@@ -347,14 +660,18 @@ Layout/IndentArray:
347
660
  # But it can be overridden by setting this parameter
348
661
  IndentationWidth: ~
349
662
 
350
- # Checks the indentation of assignment RHS, when on a different line from LHS
351
- Layout/IndentAssignment:
352
- # By default, the indentation width from `Layout/IndentationWidth` is used
353
- # But it can be overridden by setting this parameter
354
- IndentationWidth: ~
355
-
356
- # Checks the indentation of the first key in a hash literal.
357
- Layout/IndentHash:
663
+ Layout/FirstArrayElementLineBreak:
664
+ Description: >-
665
+ Checks for a line break before the first element in a
666
+ multi-line array.
667
+ Enabled: false
668
+ VersionAdded: '0.49'
669
+
670
+ Layout/FirstHashElementIndentation:
671
+ Description: 'Checks the indentation of the first key in a hash literal.'
672
+ Enabled: true
673
+ VersionAdded: '0.68'
674
+ VersionChanged: '0.77'
358
675
  # The value `special_inside_parentheses` means that hash literals with braces
359
676
  # that have their opening brace on the same line as a surrounding opening
360
677
  # round parenthesis, shall have their first key indented relative to the
@@ -374,23 +691,231 @@ Layout/IndentHash:
374
691
  # By default, the indentation width from `Layout/IndentationWidth` is used
375
692
  # But it can be overridden by setting this parameter
376
693
  IndentationWidth: ~
377
-
378
- Layout/IndentHeredoc:
379
- EnforcedStyle: auto_detection
694
+
695
+ Layout/FirstHashElementLineBreak:
696
+ Description: >-
697
+ Checks for a line break before the first element in a
698
+ multi-line hash.
699
+ Enabled: false
700
+ VersionAdded: '0.49'
701
+
702
+ Layout/FirstMethodArgumentLineBreak:
703
+ Description: >-
704
+ Checks for a line break before the first argument in a
705
+ multi-line method call.
706
+ Enabled: false
707
+ VersionAdded: '0.49'
708
+
709
+ Layout/FirstMethodParameterLineBreak:
710
+ Description: >-
711
+ Checks for a line break before the first parameter in a
712
+ multi-line method parameter definition.
713
+ Enabled: false
714
+ VersionAdded: '0.49'
715
+
716
+ Layout/FirstParameterIndentation:
717
+ Description: >-
718
+ Checks the indentation of the first parameter in a
719
+ method definition.
720
+ Enabled: true
721
+ VersionAdded: '0.49'
722
+ VersionChanged: '0.77'
723
+ EnforcedStyle: consistent
724
+ SupportedStyles:
725
+ - consistent
726
+ - align_parentheses
727
+ # By default, the indentation width from `Layout/IndentationWidth` is used
728
+ # But it can be overridden by setting this parameter
729
+ IndentationWidth: ~
730
+
731
+ Layout/HashAlignment:
732
+ Description: >-
733
+ Align the elements of a hash literal if they span more than
734
+ one line.
735
+ Enabled: true
736
+ AllowMultipleStyles: true
737
+ VersionAdded: '0.49'
738
+ VersionChanged: '0.77'
739
+ # Alignment of entries using hash rocket as separator. Valid values are:
740
+ #
741
+ # key - left alignment of keys
742
+ # 'a' => 2
743
+ # 'bb' => 3
744
+ # separator - alignment of hash rockets, keys are right aligned
745
+ # 'a' => 2
746
+ # 'bb' => 3
747
+ # table - left alignment of keys, hash rockets, and values
748
+ # 'a' => 2
749
+ # 'bb' => 3
750
+ EnforcedHashRocketStyle: key
751
+ SupportedHashRocketStyles:
752
+ - key
753
+ - separator
754
+ - table
755
+ # Alignment of entries using colon as separator. Valid values are:
756
+ #
757
+ # key - left alignment of keys
758
+ # a: 0
759
+ # bb: 1
760
+ # separator - alignment of colons, keys are right aligned
761
+ # a: 0
762
+ # bb: 1
763
+ # table - left alignment of keys and values
764
+ # a: 0
765
+ # bb: 1
766
+ EnforcedColonStyle: key
767
+ SupportedColonStyles:
768
+ - key
769
+ - separator
770
+ - table
771
+ # Select whether hashes that are the last argument in a method call should be
772
+ # inspected? Valid values are:
773
+ #
774
+ # always_inspect - Inspect both implicit and explicit hashes.
775
+ # Registers an offense for:
776
+ # function(a: 1,
777
+ # b: 2)
778
+ # Registers an offense for:
779
+ # function({a: 1,
780
+ # b: 2})
781
+ # always_ignore - Ignore both implicit and explicit hashes.
782
+ # Accepts:
783
+ # function(a: 1,
784
+ # b: 2)
785
+ # Accepts:
786
+ # function({a: 1,
787
+ # b: 2})
788
+ # ignore_implicit - Ignore only implicit hashes.
789
+ # Accepts:
790
+ # function(a: 1,
791
+ # b: 2)
792
+ # Registers an offense for:
793
+ # function({a: 1,
794
+ # b: 2})
795
+ # ignore_explicit - Ignore only explicit hashes.
796
+ # Accepts:
797
+ # function({a: 1,
798
+ # b: 2})
799
+ # Registers an offense for:
800
+ # function(a: 1,
801
+ # b: 2)
802
+ EnforcedLastArgumentHashStyle: always_inspect
803
+ SupportedLastArgumentHashStyles:
804
+ - always_inspect
805
+ - always_ignore
806
+ - ignore_implicit
807
+ - ignore_explicit
808
+
809
+ Layout/HeredocArgumentClosingParenthesis:
810
+ Description: >-
811
+ Checks for the placement of the closing parenthesis in a
812
+ method call that passes a HEREDOC string as an argument.
813
+ Enabled: false
814
+ StyleGuide: '#heredoc-argument-closing-parentheses'
815
+ VersionAdded: '0.68'
816
+
817
+ Layout/HeredocIndentation:
818
+ Description: 'This cop checks the indentation of the here document bodies.'
819
+ StyleGuide: '#squiggly-heredocs'
820
+ Enabled: true
821
+ VersionAdded: '0.49'
822
+ VersionChanged: '0.85'
823
+
824
+ Layout/IndentationConsistency:
825
+ Description: 'Keep indentation straight.'
826
+ StyleGuide: '#spaces-indentation'
827
+ Enabled: true
828
+ VersionAdded: '0.49'
829
+ # The difference between `indented` and `normal` is that the `indented_internal_methods`
830
+ # style prescribes that in classes and modules the `protected` and `private`
831
+ # modifier keywords shall be indented the same as public methods and that
832
+ # protected and private members shall be indented one step more than the
833
+ # modifiers. Other than that, both styles mean that entities on the same
834
+ # logical depth shall have the same indentation.
835
+ EnforcedStyle: normal
836
+ SupportedStyles:
837
+ - normal
838
+ - indented_internal_methods
839
+ Reference:
840
+ # A reference to `EnforcedStyle: indented_internal_methods`.
841
+ - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions
842
+
843
+ Layout/IndentationStyle:
844
+ Description: 'Consistent indentation either with tabs only or spaces only.'
845
+ StyleGuide: '#spaces-indentation'
846
+ Enabled: true
847
+ VersionAdded: '0.49'
848
+ VersionChanged: '0.82'
849
+ # By default, the indentation width from Layout/IndentationWidth is used
850
+ # But it can be overridden by setting this parameter
851
+ # It is used during auto-correction to determine how many spaces should
852
+ # replace each tab.
853
+ IndentationWidth: ~
854
+ EnforcedStyle: spaces
380
855
  SupportedStyles:
381
- - auto_detection
382
- - squiggly
383
- - active_support
384
- - powerpack
385
- - unindent
856
+ - spaces
857
+ - tabs
386
858
 
387
- Layout/SpaceInLambdaLiteral:
388
- EnforcedStyle: require_no_space
389
- SupportedStyles:
390
- - require_no_space
391
- - require_space
859
+ Layout/IndentationWidth:
860
+ Description: 'Use 2 spaces for indentation.'
861
+ StyleGuide: '#spaces-indentation'
862
+ Enabled: true
863
+ VersionAdded: '0.49'
864
+ # Number of spaces for each indentation level.
865
+ Width: 2
866
+ IgnoredPatterns: []
867
+
868
+ Layout/InitialIndentation:
869
+ Description: >-
870
+ Checks the indentation of the first non-blank non-comment line in a file.
871
+ Enabled: true
872
+ VersionAdded: '0.49'
873
+
874
+ Layout/LeadingCommentSpace:
875
+ Description: 'Comments should start with a space.'
876
+ StyleGuide: '#hash-space'
877
+ Enabled: true
878
+ VersionAdded: '0.49'
879
+ VersionChanged: '0.73'
880
+ AllowDoxygenCommentStyle: false
881
+ AllowGemfileRubyComment: false
882
+
883
+ Layout/LeadingEmptyLines:
884
+ Description: Check for unnecessary blank lines at the beginning of a file.
885
+ Enabled: true
886
+ VersionAdded: '0.57'
887
+ VersionChanged: '0.77'
888
+
889
+ Layout/LineLength:
890
+ Description: 'Checks that line length does not exceed the configured limit.'
891
+ StyleGuide: '#max-line-length'
892
+ Enabled: true
893
+ VersionAdded: '0.25'
894
+ VersionChanged: '0.84'
895
+ AutoCorrect: false
896
+ Max: 120
897
+ # To make it possible to copy or click on URIs in the code, we allow lines
898
+ # containing a URI to be longer than Max.
899
+ AllowHeredoc: true
900
+ AllowURI: true
901
+ URISchemes:
902
+ - http
903
+ - https
904
+ # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
905
+ # directives like '# rubocop: enable ...' when calculating a line's length.
906
+ IgnoreCopDirectives: true
907
+ # The IgnoredPatterns option is a list of !ruby/regexp and/or string
908
+ # elements. Strings will be converted to Regexp objects. A line that matches
909
+ # any regular expression listed in this option will be ignored by LineLength.
910
+ IgnoredPatterns: []
392
911
 
393
912
  Layout/MultilineArrayBraceLayout:
913
+ Description: >-
914
+ Checks that the closing brace in an array literal is
915
+ either on the same line as the last array element, or
916
+ a new line.
917
+ Enabled: true
918
+ VersionAdded: '0.49'
394
919
  EnforcedStyle: symmetrical
395
920
  SupportedStyles:
396
921
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -400,7 +925,18 @@ Layout/MultilineArrayBraceLayout:
400
925
  - new_line
401
926
  - same_line
402
927
 
928
+ Layout/MultilineArrayLineBreaks:
929
+ Description: >-
930
+ Checks that each item in a multi-line array literal
931
+ starts on a separate line.
932
+ Enabled: false
933
+ VersionAdded: '0.67'
934
+
403
935
  Layout/MultilineAssignmentLayout:
936
+ Description: 'Check for a newline after the assignment operator in multi-line assignments.'
937
+ StyleGuide: '#indent-conditional-assignment'
938
+ Enabled: false
939
+ VersionAdded: '0.49'
404
940
  # The types of assignments which are subject to this rule.
405
941
  SupportedTypes:
406
942
  - block
@@ -418,7 +954,18 @@ Layout/MultilineAssignmentLayout:
418
954
  # for the set of supported types.
419
955
  - new_line
420
956
 
957
+ Layout/MultilineBlockLayout:
958
+ Description: 'Ensures newlines after multiline block do statements.'
959
+ Enabled: true
960
+ VersionAdded: '0.49'
961
+
421
962
  Layout/MultilineHashBraceLayout:
963
+ Description: >-
964
+ Checks that the closing brace in a hash literal is
965
+ either on the same line as the last hash element, or
966
+ a new line.
967
+ Enabled: true
968
+ VersionAdded: '0.49'
422
969
  EnforcedStyle: symmetrical
423
970
  SupportedStyles:
424
971
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -428,7 +975,27 @@ Layout/MultilineHashBraceLayout:
428
975
  - new_line
429
976
  - same_line
430
977
 
978
+ Layout/MultilineHashKeyLineBreaks:
979
+ Description: >-
980
+ Checks that each item in a multi-line hash literal
981
+ starts on a separate line.
982
+ Enabled: false
983
+ VersionAdded: '0.67'
984
+
985
+ Layout/MultilineMethodArgumentLineBreaks:
986
+ Description: >-
987
+ Checks that each argument in a multi-line method call
988
+ starts on a separate line.
989
+ Enabled: false
990
+ VersionAdded: '0.67'
991
+
431
992
  Layout/MultilineMethodCallBraceLayout:
993
+ Description: >-
994
+ Checks that the closing brace in a method call is
995
+ either on the same line as the last method argument, or
996
+ a new line.
997
+ Enabled: true
998
+ VersionAdded: '0.49'
432
999
  EnforcedStyle: symmetrical
433
1000
  SupportedStyles:
434
1001
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -439,6 +1006,11 @@ Layout/MultilineMethodCallBraceLayout:
439
1006
  - same_line
440
1007
 
441
1008
  Layout/MultilineMethodCallIndentation:
1009
+ Description: >-
1010
+ Checks indentation of method calls with the dot operator
1011
+ that span more than one line.
1012
+ Enabled: true
1013
+ VersionAdded: '0.49'
442
1014
  EnforcedStyle: aligned
443
1015
  SupportedStyles:
444
1016
  - aligned
@@ -449,6 +1021,12 @@ Layout/MultilineMethodCallIndentation:
449
1021
  IndentationWidth: ~
450
1022
 
451
1023
  Layout/MultilineMethodDefinitionBraceLayout:
1024
+ Description: >-
1025
+ Checks that the closing brace in a method definition is
1026
+ either on the same line as the last method parameter, or
1027
+ a new line.
1028
+ Enabled: true
1029
+ VersionAdded: '0.49'
452
1030
  EnforcedStyle: symmetrical
453
1031
  SupportedStyles:
454
1032
  # symmetrical: closing brace is positioned in same way as opening brace
@@ -459,6 +1037,11 @@ Layout/MultilineMethodDefinitionBraceLayout:
459
1037
  - same_line
460
1038
 
461
1039
  Layout/MultilineOperationIndentation:
1040
+ Description: >-
1041
+ Checks indentation of binary operations that span more than
1042
+ one line.
1043
+ Enabled: true
1044
+ VersionAdded: '0.49'
462
1045
  EnforcedStyle: aligned
463
1046
  SupportedStyles:
464
1047
  - aligned
@@ -467,25 +1050,124 @@ Layout/MultilineOperationIndentation:
467
1050
  # But it can be overridden by setting this parameter
468
1051
  IndentationWidth: ~
469
1052
 
1053
+ Layout/ParameterAlignment:
1054
+ Description: >-
1055
+ Align the parameters of a method definition if they span more
1056
+ than one line.
1057
+ StyleGuide: '#no-double-indent'
1058
+ Enabled: true
1059
+ VersionAdded: '0.49'
1060
+ VersionChanged: '0.77'
1061
+ # Alignment of parameters in multi-line method calls.
1062
+ #
1063
+ # The `with_first_parameter` style aligns the following lines along the same
1064
+ # column as the first parameter.
1065
+ #
1066
+ # def method_foo(a,
1067
+ # b)
1068
+ #
1069
+ # The `with_fixed_indentation` style aligns the following lines with one
1070
+ # level of indentation relative to the start of the line with the method call.
1071
+ #
1072
+ # def method_foo(a,
1073
+ # b)
1074
+ EnforcedStyle: with_first_parameter
1075
+ SupportedStyles:
1076
+ - with_first_parameter
1077
+ - with_fixed_indentation
1078
+ # By default, the indentation width from Layout/IndentationWidth is used
1079
+ # But it can be overridden by setting this parameter
1080
+ IndentationWidth: ~
1081
+
1082
+ Layout/RescueEnsureAlignment:
1083
+ Description: 'Align rescues and ensures correctly.'
1084
+ Enabled: true
1085
+ VersionAdded: '0.49'
1086
+
1087
+ Layout/SpaceAfterColon:
1088
+ Description: 'Use spaces after colons.'
1089
+ StyleGuide: '#spaces-operators'
1090
+ Enabled: true
1091
+ VersionAdded: '0.49'
1092
+
1093
+ Layout/SpaceAfterComma:
1094
+ Description: 'Use spaces after commas.'
1095
+ StyleGuide: '#spaces-operators'
1096
+ Enabled: true
1097
+ VersionAdded: '0.49'
1098
+
1099
+ Layout/SpaceAfterMethodName:
1100
+ Description: >-
1101
+ Do not put a space between a method name and the opening
1102
+ parenthesis in a method definition.
1103
+ StyleGuide: '#parens-no-spaces'
1104
+ Enabled: true
1105
+ VersionAdded: '0.49'
1106
+
1107
+ Layout/SpaceAfterNot:
1108
+ Description: Tracks redundant space after the ! operator.
1109
+ StyleGuide: '#no-space-bang'
1110
+ Enabled: true
1111
+ VersionAdded: '0.49'
1112
+
1113
+ Layout/SpaceAfterSemicolon:
1114
+ Description: 'Use spaces after semicolons.'
1115
+ StyleGuide: '#spaces-operators'
1116
+ Enabled: true
1117
+ VersionAdded: '0.49'
1118
+
470
1119
  Layout/SpaceAroundBlockParameters:
1120
+ Description: 'Checks the spacing inside and after block parameters pipes.'
1121
+ Enabled: true
1122
+ VersionAdded: '0.49'
471
1123
  EnforcedStyleInsidePipes: no_space
472
1124
  SupportedStylesInsidePipes:
473
1125
  - space
474
1126
  - no_space
475
1127
 
476
1128
  Layout/SpaceAroundEqualsInParameterDefault:
1129
+ Description: >-
1130
+ Checks that the equals signs in parameter default assignments
1131
+ have or don't have surrounding space depending on
1132
+ configuration.
1133
+ StyleGuide: '#spaces-around-equals'
1134
+ Enabled: true
1135
+ VersionAdded: '0.49'
477
1136
  EnforcedStyle: space
478
1137
  SupportedStyles:
479
1138
  - space
480
1139
  - no_space
481
1140
 
1141
+ Layout/SpaceAroundKeyword:
1142
+ Description: 'Use a space around keywords if appropriate.'
1143
+ Enabled: true
1144
+ VersionAdded: '0.49'
1145
+
1146
+ Layout/SpaceAroundMethodCallOperator:
1147
+ Description: 'Checks method call operators to not have spaces around them.'
1148
+ Enabled: pending
1149
+ VersionAdded: '0.82'
1150
+
482
1151
  Layout/SpaceAroundOperators:
1152
+ Description: 'Use a single space around operators.'
1153
+ StyleGuide: '#spaces-operators'
1154
+ Enabled: true
1155
+ VersionAdded: '0.49'
483
1156
  # When `true`, allows most uses of extra spacing if the intent is to align
484
1157
  # with an operator on the previous or next line, not counting empty lines
485
1158
  # or comment lines.
486
1159
  AllowForAlignment: true
1160
+ EnforcedStyleForExponentOperator: no_space
1161
+ SupportedStylesForExponentOperator:
1162
+ - space
1163
+ - no_space
487
1164
 
488
1165
  Layout/SpaceBeforeBlockBraces:
1166
+ Description: >-
1167
+ Checks that the left block brace has or doesn't have space
1168
+ before it.
1169
+ Enabled: true
1170
+ VersionAdded: '0.49'
489
1171
  EnforcedStyle: space
490
1172
  SupportedStyles:
491
1173
  - space
@@ -494,14 +1176,49 @@ Layout/SpaceBeforeBlockBraces:
494
1176
  SupportedStylesForEmptyBraces:
495
1177
  - space
496
1178
  - no_space
1179
+ VersionChanged: '0.52.1'
1180
+
1181
+ Layout/SpaceBeforeComma:
1182
+ Description: 'No spaces before commas.'
1183
+ Enabled: true
1184
+ VersionAdded: '0.49'
1185
+
1186
+ Layout/SpaceBeforeComment:
1187
+ Description: >-
1188
+ Checks for missing space between code and a comment on the
1189
+ same line.
1190
+ Enabled: true
1191
+ VersionAdded: '0.49'
497
1192
 
498
1193
  Layout/SpaceBeforeFirstArg:
1194
+ Description: >-
1195
+ Checks that exactly one space is used between a method name
1196
+ and the first argument for method calls without parentheses.
1197
+ Enabled: true
1198
+ VersionAdded: '0.49'
499
1199
  # When `true`, allows most uses of extra spacing if the intent is to align
500
1200
  # things with the previous or next line, not counting empty lines or comment
501
1201
  # lines.
502
1202
  AllowForAlignment: true
503
1203
 
1204
+ Layout/SpaceBeforeSemicolon:
1205
+ Description: 'No spaces before semicolons.'
1206
+ Enabled: true
1207
+ VersionAdded: '0.49'
1208
+
1209
+ Layout/SpaceInLambdaLiteral:
1210
+ Description: 'Checks for spaces in lambda literals.'
1211
+ Enabled: true
1212
+ VersionAdded: '0.49'
1213
+ EnforcedStyle: require_no_space
1214
+ SupportedStyles:
1215
+ - require_no_space
1216
+ - require_space
1217
+
504
1218
  Layout/SpaceInsideArrayLiteralBrackets:
1219
+ Description: 'Checks the spacing inside array literal brackets.'
1220
+ Enabled: true
1221
+ VersionAdded: '0.52'
505
1222
  EnforcedStyle: no_space
506
1223
  SupportedStyles:
507
1224
  - space
@@ -514,7 +1231,18 @@ Layout/SpaceInsideArrayLiteralBrackets:
514
1231
  - space
515
1232
  - no_space
516
1233
 
1234
+ Layout/SpaceInsideArrayPercentLiteral:
1235
+ Description: 'No unnecessary additional spaces between elements in %i/%w literals.'
1236
+ Enabled: true
1237
+ VersionAdded: '0.49'
1238
+
517
1239
  Layout/SpaceInsideBlockBraces:
1240
+ Description: >-
1241
+ Checks that block braces have or don't have surrounding space.
1242
+ For blocks taking parameters, checks that the left brace has
1243
+ or doesn't have trailing space.
1244
+ Enabled: true
1245
+ VersionAdded: '0.49'
518
1246
  EnforcedStyle: space
519
1247
  SupportedStyles:
520
1248
  - space
@@ -527,6 +1255,10 @@ Layout/SpaceInsideBlockBraces:
527
1255
  SpaceBeforeBlockParameters: true
528
1256
 
529
1257
  Layout/SpaceInsideHashLiteralBraces:
1258
+ Description: "Use spaces inside hash literal braces - or don't."
1259
+ StyleGuide: '#spaces-braces'
1260
+ Enabled: true
1261
+ VersionAdded: '0.49'
530
1262
  EnforcedStyle: space
531
1263
  SupportedStyles:
532
1264
  - space
@@ -539,57 +1271,940 @@ Layout/SpaceInsideHashLiteralBraces:
539
1271
  - space
540
1272
  - no_space
541
1273
 
1274
+
1275
+ Layout/SpaceInsideParens:
1276
+ Description: 'No spaces after ( or before ).'
1277
+ StyleGuide: '#spaces-braces'
1278
+ Enabled: true
1279
+ VersionAdded: '0.49'
1280
+ VersionChanged: '0.55'
1281
+ EnforcedStyle: no_space
1282
+ SupportedStyles:
1283
+ - space
1284
+ - no_space
1285
+
1286
+ Layout/SpaceInsidePercentLiteralDelimiters:
1287
+ Description: 'No unnecessary spaces inside delimiters of %i/%w/%x literals.'
1288
+ Enabled: true
1289
+ VersionAdded: '0.49'
1290
+
1291
+ Layout/SpaceInsideRangeLiteral:
1292
+ Description: 'No spaces inside range literals.'
1293
+ StyleGuide: '#no-space-inside-range-literals'
1294
+ Enabled: true
1295
+ VersionAdded: '0.49'
1296
+
542
1297
  Layout/SpaceInsideReferenceBrackets:
1298
+ Description: 'Checks the spacing inside referential brackets.'
1299
+ Enabled: true
1300
+ VersionAdded: '0.52'
1301
+ VersionChanged: '0.53'
543
1302
  EnforcedStyle: no_space
544
1303
  SupportedStyles:
545
1304
  - space
546
1305
  - no_space
1306
+ EnforcedStyleForEmptyBrackets: no_space
1307
+ SupportedStylesForEmptyBrackets:
1308
+ - space
1309
+ - no_space
547
1310
 
548
1311
  Layout/SpaceInsideStringInterpolation:
1312
+ Description: 'Checks for padding/surrounding spaces inside string interpolation.'
1313
+ StyleGuide: '#string-interpolation'
1314
+ Enabled: true
1315
+ VersionAdded: '0.49'
549
1316
  EnforcedStyle: no_space
550
1317
  SupportedStyles:
551
1318
  - space
552
1319
  - no_space
553
1320
 
554
- Layout/ClassStructure:
555
- Categories:
556
- module_inclusion:
557
- - include
558
- - prepend
559
- - extend
560
- ExpectedOrder:
561
- - module_inclusion
562
- - constants
563
- - public_class_methods
564
- - initializer
565
- - public_methods
566
- - protected_methods
567
- - private_methods
568
-
569
- Layout/Tab:
570
- # By default, the indentation width from Layout/IndentationWidth is used
571
- # But it can be overridden by setting this parameter
572
- # It is used during auto-correction to determine how many spaces should
573
- # replace each tab.
574
- IndentationWidth: ~
575
-
576
- Layout/TrailingBlankLines:
1321
+ Layout/TrailingEmptyLines:
1322
+ Description: 'Checks trailing blank lines and final newline.'
1323
+ StyleGuide: '#newline-eof'
1324
+ Enabled: true
1325
+ VersionAdded: '0.49'
1326
+ VersionChanged: '0.77'
577
1327
  EnforcedStyle: final_newline
578
1328
  SupportedStyles:
579
1329
  - final_newline
580
1330
  - final_blank_line
581
1331
 
582
- #################### Naming ##########################
1332
+ Layout/TrailingWhitespace:
1333
+ Description: 'Avoid trailing whitespace.'
1334
+ StyleGuide: '#no-trailing-whitespace'
1335
+ Enabled: true
1336
+ VersionAdded: '0.49'
1337
+ VersionChanged: '0.83'
1338
+ AllowInHeredoc: true
1339
+
1340
+ #################### Lint ##################################
1341
+ ### Warnings
1342
+
1343
+ Lint/AmbiguousBlockAssociation:
1344
+ Description: >-
1345
+ Checks for ambiguous block association with method when param passed without
1346
+ parentheses.
1347
+ StyleGuide: '#syntax'
1348
+ Enabled: true
1349
+ VersionAdded: '0.48'
1350
+
1351
+ Lint/AmbiguousOperator:
1352
+ Description: >-
1353
+ Checks for ambiguous operators in the first argument of a
1354
+ method invocation without parentheses.
1355
+ StyleGuide: '#method-invocation-parens'
1356
+ Enabled: true
1357
+ VersionAdded: '0.17'
1358
+ VersionChanged: '0.83'
1359
+
1360
+ Lint/AmbiguousRegexpLiteral:
1361
+ Description: >-
1362
+ Checks for ambiguous regexp literals in the first argument of
1363
+ a method invocation without parentheses.
1364
+ Enabled: true
1365
+ VersionAdded: '0.17'
1366
+ VersionChanged: '0.83'
1367
+
1368
+ Lint/AssignmentInCondition:
1369
+ Description: "Don't use assignment in conditions."
1370
+ StyleGuide: '#safe-assignment-in-condition'
1371
+ Enabled: true
1372
+ VersionAdded: '0.9'
1373
+ AllowSafeAssignment: true
1374
+
1375
+ Lint/BigDecimalNew:
1376
+ Description: '`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead.'
1377
+ Enabled: true
1378
+ VersionAdded: '0.53'
1379
+
1380
+ Lint/BinaryOperatorWithIdenticalOperands:
1381
+ Description: 'This cop checks for places where binary operator has identical operands.'
1382
+ Enabled: pending
1383
+ Safe: false
1384
+ VersionAdded: '0.89'
1385
+
1386
+ Lint/BooleanSymbol:
1387
+ Description: 'Check for `:true` and `:false` symbols.'
1388
+ Enabled: true
1389
+ Safe: false
1390
+ VersionAdded: '0.50'
1391
+ VersionChanged: '0.83'
1392
+
1393
+ Lint/CircularArgumentReference:
1394
+ Description: "Default values in optional keyword arguments and optional ordinal arguments should not refer back to the name of the argument."
1395
+ Enabled: true
1396
+ VersionAdded: '0.33'
1397
+
1398
+ Lint/ConstantDefinitionInBlock:
1399
+ Description: 'Do not define constants within a block.'
1400
+ StyleGuide: '#no-constant-definition-in-block'
1401
+ Enabled: pending
1402
+ VersionAdded: '0.91'
1403
+
1404
+ Lint/ConstantResolution:
1405
+ Description: 'Check that constants are fully qualified with `::`.'
1406
+ Enabled: false
1407
+ VersionAdded: '0.86'
1408
+ # Restrict this cop to only looking at certain names
1409
+ Only: []
1410
+ # Restrict this cop from only looking at certain names
1411
+ Ignore: []
1412
+
1413
+ Lint/Debugger:
1414
+ Description: 'Check for debugger calls.'
1415
+ Enabled: true
1416
+ VersionAdded: '0.14'
1417
+ VersionChanged: '0.49'
1418
+
1419
+ Lint/DeprecatedClassMethods:
1420
+ Description: 'Check for deprecated class method calls.'
1421
+ Enabled: true
1422
+ VersionAdded: '0.19'
1423
+
1424
+ Lint/DeprecatedOpenSSLConstant:
1425
+ Description: "Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`."
1426
+ Enabled: pending
1427
+ VersionAdded: '0.84'
1428
+
1429
+ Lint/DisjunctiveAssignmentInConstructor:
1430
+ Description: 'In constructor, plain assignment is preferred over disjunctive.'
1431
+ Enabled: true
1432
+ Safe: false
1433
+ VersionAdded: '0.62'
1434
+ VersionChanged: '0.88'
1435
+
1436
+ Lint/DuplicateCaseCondition:
1437
+ Description: 'Do not repeat values in case conditionals.'
1438
+ Enabled: true
1439
+ VersionAdded: '0.45'
1440
+
1441
+ Lint/DuplicateElsifCondition:
1442
+ Description: 'Do not repeat conditions used in if `elsif`.'
1443
+ Enabled: 'pending'
1444
+ VersionAdded: '0.88'
1445
+
1446
+ Lint/DuplicateHashKey:
1447
+ Description: 'Check for duplicate keys in hash literals.'
1448
+ Enabled: true
1449
+ VersionAdded: '0.34'
1450
+ VersionChanged: '0.77'
1451
+
1452
+ Lint/DuplicateMethods:
1453
+ Description: 'Check for duplicate method definitions.'
1454
+ Enabled: true
1455
+ VersionAdded: '0.29'
1456
+
1457
+ Lint/DuplicateRequire:
1458
+ Description: 'Check for duplicate `require`s and `require_relative`s.'
1459
+ Enabled: pending
1460
+ VersionAdded: '0.90'
1461
+
1462
+ Lint/DuplicateRescueException:
1463
+ Description: 'Checks that there are no repeated exceptions used in `rescue` expressions.'
1464
+ Enabled: pending
1465
+ VersionAdded: '0.89'
1466
+
1467
+ Lint/EachWithObjectArgument:
1468
+ Description: 'Check for immutable argument given to each_with_object.'
1469
+ Enabled: true
1470
+ VersionAdded: '0.31'
1471
+
1472
+ Lint/ElseLayout:
1473
+ Description: 'Check for odd code arrangement in an else block.'
1474
+ Enabled: true
1475
+ VersionAdded: '0.17'
1476
+
1477
+ Lint/EmptyConditionalBody:
1478
+ Description: 'This cop checks for the presence of `if`, `elsif` and `unless` branches without a body.'
1479
+ Enabled: 'pending'
1480
+ AllowComments: true
1481
+ VersionAdded: '0.89'
1482
+
1483
+ Lint/EmptyEnsure:
1484
+ Description: 'Checks for empty ensure block.'
1485
+ Enabled: true
1486
+ VersionAdded: '0.10'
1487
+ VersionChanged: '0.48'
1488
+
1489
+ Lint/EmptyExpression:
1490
+ Description: 'Checks for empty expressions.'
1491
+ Enabled: true
1492
+ VersionAdded: '0.45'
1493
+
1494
+ Lint/EmptyFile:
1495
+ Description: 'Enforces that Ruby source files are not empty.'
1496
+ Enabled: pending
1497
+ AllowComments: true
1498
+ VersionAdded: '0.90'
1499
+
1500
+ Lint/EmptyInterpolation:
1501
+ Description: 'Checks for empty string interpolation.'
1502
+ Enabled: true
1503
+ VersionAdded: '0.20'
1504
+ VersionChanged: '0.45'
1505
+
1506
+ Lint/EmptyWhen:
1507
+ Description: 'Checks for `when` branches with empty bodies.'
1508
+ Enabled: true
1509
+ AllowComments: true
1510
+ VersionAdded: '0.45'
1511
+ VersionChanged: '0.83'
1512
+
1513
+ Lint/EnsureReturn:
1514
+ Description: 'Do not use return in an ensure block.'
1515
+ StyleGuide: '#no-return-ensure'
1516
+ Enabled: true
1517
+ VersionAdded: '0.9'
1518
+ VersionChanged: '0.83'
1519
+
1520
+ Lint/ErbNewArguments:
1521
+ Description: 'Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`.'
1522
+ Enabled: true
1523
+ VersionAdded: '0.56'
1524
+
1525
+ Lint/FlipFlop:
1526
+ Description: 'Checks for flip-flops.'
1527
+ StyleGuide: '#no-flip-flops'
1528
+ Enabled: true
1529
+ VersionAdded: '0.16'
1530
+
1531
+ Lint/FloatComparison:
1532
+ Description: 'Checks for the presence of precise comparison of floating point numbers.'
1533
+ StyleGuide: '#float-comparison'
1534
+ Enabled: pending
1535
+ VersionAdded: '0.89'
1536
+
1537
+ Lint/FloatOutOfRange:
1538
+ Description: >-
1539
+ Catches floating-point literals too large or small for Ruby to
1540
+ represent.
1541
+ Enabled: true
1542
+ VersionAdded: '0.36'
1543
+
1544
+ Lint/FormatParameterMismatch:
1545
+ Description: 'The number of parameters to format/sprint must match the fields.'
1546
+ Enabled: true
1547
+ VersionAdded: '0.33'
1548
+
1549
+ Lint/HashCompareByIdentity:
1550
+ Description: 'Prefer using `Hash#compare_by_identity` than using `object_id` for keys.'
1551
+ StyleGuide: '#identity-comparison'
1552
+ Enabled: pending
1553
+ Safe: false
1554
+ VersionAdded: '0.93'
1555
+
1556
+ Lint/HeredocMethodCallPosition:
1557
+ Description: >-
1558
+ Checks for the ordering of a method call where
1559
+ the receiver of the call is a HEREDOC.
1560
+ Enabled: false
1561
+ StyleGuide: '#heredoc-method-calls'
1562
+ VersionAdded: '0.68'
1563
+
1564
+ Lint/IdentityComparison:
1565
+ Description: 'Prefer `equal?` over `==` when comparing `object_id`.'
1566
+ Enabled: pending
1567
+ StyleGuide: '#identity-comparison'
1568
+ VersionAdded: '0.91'
1569
+
1570
+ Lint/ImplicitStringConcatenation:
1571
+ Description: >-
1572
+ Checks for adjacent string literals on the same line, which
1573
+ could better be represented as a single string literal.
1574
+ Enabled: true
1575
+ VersionAdded: '0.36'
1576
+
1577
+ Lint/IneffectiveAccessModifier:
1578
+ Description: >-
1579
+ Checks for attempts to use `private` or `protected` to set
1580
+ the visibility of a class method, which does not work.
1581
+ Enabled: true
1582
+ VersionAdded: '0.36'
1583
+
1584
+ Lint/InheritException:
1585
+ Description: 'Avoid inheriting from the `Exception` class.'
1586
+ Enabled: true
1587
+ VersionAdded: '0.41'
1588
+ # The default base class in favour of `Exception`.
1589
+ EnforcedStyle: runtime_error
1590
+ SupportedStyles:
1591
+ - runtime_error
1592
+ - standard_error
1593
+
1594
+ Lint/InterpolationCheck:
1595
+ Description: 'Raise warning for interpolation in single q strs.'
1596
+ Enabled: true
1597
+ Safe: false
1598
+ VersionAdded: '0.50'
1599
+ VersionChanged: '0.87'
1600
+
1601
+ Lint/LiteralAsCondition:
1602
+ Description: 'Checks of literals used in conditions.'
1603
+ Enabled: true
1604
+ VersionAdded: '0.51'
1605
+
1606
+ Lint/LiteralInInterpolation:
1607
+ Description: 'Checks for literals used in interpolation.'
1608
+ Enabled: true
1609
+ VersionAdded: '0.19'
1610
+ VersionChanged: '0.32'
1611
+
1612
+ Lint/Loop:
1613
+ Description: >-
1614
+ Use Kernel#loop with break rather than begin/end/until or
1615
+ begin/end/while for post-loop tests.
1616
+ StyleGuide: '#loop-with-break'
1617
+ Enabled: true
1618
+ VersionAdded: '0.9'
1619
+ VersionChanged: '0.89'
1620
+
1621
+ Lint/MissingCopEnableDirective:
1622
+ Description: 'Checks for a `# rubocop:enable` after `# rubocop:disable`.'
1623
+ Enabled: true
1624
+ VersionAdded: '0.52'
1625
+ # Maximum number of consecutive lines the cop can be disabled for.
1626
+ # 0 allows only single-line disables
1627
+ # 1 would mean the maximum allowed is the following:
1628
+ # # rubocop:disable SomeCop
1629
+ # a = 1
1630
+ # # rubocop:enable SomeCop
1631
+ # .inf for any size
1632
+ MaximumRangeSize: .inf
1633
+
1634
+ Lint/MissingSuper:
1635
+ Description: >-
1636
+ This cop checks for the presence of constructors and lifecycle callbacks
1637
+ without calls to `super`'.
1638
+ Enabled: pending
1639
+ VersionAdded: '0.89'
1640
+
1641
+ Lint/MixedRegexpCaptureTypes:
1642
+ Description: 'Do not mix named captures and numbered captures in a Regexp literal.'
1643
+ Enabled: pending
1644
+ VersionAdded: '0.85'
1645
+
1646
+ Lint/MultipleComparison:
1647
+ Description: "Use `&&` operator to compare multiple values."
1648
+ Enabled: true
1649
+ VersionAdded: '0.47'
1650
+ VersionChanged: '0.77'
1651
+
1652
+ Lint/NestedMethodDefinition:
1653
+ Description: 'Do not use nested method definitions.'
1654
+ StyleGuide: '#no-nested-methods'
1655
+ Enabled: true
1656
+ VersionAdded: '0.32'
1657
+
1658
+ Lint/NestedPercentLiteral:
1659
+ Description: 'Checks for nested percent literals.'
1660
+ Enabled: true
1661
+ VersionAdded: '0.52'
1662
+
1663
+ Lint/NextWithoutAccumulator:
1664
+ Description: >-
1665
+ Do not omit the accumulator when calling `next`
1666
+ in a `reduce`/`inject` block.
1667
+ Enabled: true
1668
+ VersionAdded: '0.36'
1669
+
1670
+ Lint/NonDeterministicRequireOrder:
1671
+ Description: 'Always sort arrays returned by Dir.glob when requiring files.'
1672
+ Enabled: true
1673
+ VersionAdded: '0.78'
1674
+ Safe: false
1675
+
1676
+ Lint/NonLocalExitFromIterator:
1677
+ Description: 'Do not use return in iterator to cause non-local exit.'
1678
+ Enabled: true
1679
+ VersionAdded: '0.30'
1680
+
1681
+ Lint/NumberConversion:
1682
+ Description: 'Checks unsafe usage of number conversion methods.'
1683
+ Enabled: false
1684
+ VersionAdded: '0.53'
1685
+ VersionChanged: '0.70'
1686
+ SafeAutoCorrect: false
1687
+
1688
+ Lint/OrderedMagicComments:
1689
+ Description: 'Checks the proper ordering of magic comments and whether a magic comment is not placed before a shebang.'
1690
+ Enabled: true
1691
+ VersionAdded: '0.53'
1692
+
1693
+ Lint/OutOfRangeRegexpRef:
1694
+ Description: 'Checks for out of range reference for Regexp because it always returns nil.'
1695
+ Enabled: pending
1696
+ Safe: false
1697
+ VersionAdded: '0.89'
1698
+
1699
+ Lint/ParenthesesAsGroupedExpression:
1700
+ Description: >-
1701
+ Checks for method calls with a space before the opening
1702
+ parenthesis.
1703
+ StyleGuide: '#parens-no-spaces'
1704
+ Enabled: true
1705
+ VersionAdded: '0.12'
1706
+ VersionChanged: '0.83'
1707
+
1708
+ Lint/PercentStringArray:
1709
+ Description: >-
1710
+ Checks for unwanted commas and quotes in %w/%W literals.
1711
+ Enabled: true
1712
+ Safe: false
1713
+ VersionAdded: '0.41'
1714
+
1715
+ Lint/PercentSymbolArray:
1716
+ Description: >-
1717
+ Checks for unwanted commas and colons in %i/%I literals.
1718
+ Enabled: true
1719
+ VersionAdded: '0.41'
1720
+
1721
+ Lint/RaiseException:
1722
+ Description: Checks for `raise` or `fail` statements which are raising `Exception` class.
1723
+ StyleGuide: '#raise-exception'
1724
+ Enabled: pending
1725
+ Safe: false
1726
+ VersionAdded: '0.81'
1727
+ VersionChanged: '0.86'
1728
+ AllowedImplicitNamespaces:
1729
+ - 'Gem'
1730
+
1731
+ Lint/RandOne:
1732
+ Description: >-
1733
+ Checks for `rand(1)` calls. Such calls always return `0`
1734
+ and most likely a mistake.
1735
+ Enabled: true
1736
+ VersionAdded: '0.36'
1737
+
1738
+ Lint/RedundantCopDisableDirective:
1739
+ Description: >-
1740
+ Checks for rubocop:disable comments that can be removed.
1741
+ Note: this cop is not disabled when disabling all cops.
1742
+ It must be explicitly disabled.
1743
+ Enabled: true
1744
+ VersionAdded: '0.76'
1745
+
1746
+ Lint/RedundantCopEnableDirective:
1747
+ Description: Checks for rubocop:enable comments that can be removed.
1748
+ Enabled: true
1749
+ VersionAdded: '0.76'
1750
+
1751
+ Lint/RedundantRequireStatement:
1752
+ Description: 'Checks for unnecessary `require` statement.'
1753
+ Enabled: true
1754
+ VersionAdded: '0.76'
1755
+
1756
+ Lint/RedundantSafeNavigation:
1757
+ Description: 'Checks for redundant safe navigation calls.'
1758
+ Enabled: pending
1759
+ VersionAdded: '0.93'
1760
+ AllowedMethods:
1761
+ - instance_of?
1762
+ - kind_of?
1763
+ - is_a?
1764
+ - eql?
1765
+ - respond_to?
1766
+ - equal?
1767
+ Safe: false
1768
+
1769
+ Lint/RedundantSplatExpansion:
1770
+ Description: 'Checks for splat unnecessarily being called on literals.'
1771
+ Enabled: true
1772
+ VersionAdded: '0.76'
1773
+
1774
+ Lint/RedundantStringCoercion:
1775
+ Description: 'Checks for Object#to_s usage in string interpolation.'
1776
+ StyleGuide: '#no-to-s'
1777
+ Enabled: true
1778
+ VersionAdded: '0.19'
1779
+ VersionChanged: '0.77'
1780
+
1781
+ Lint/RedundantWithIndex:
1782
+ Description: 'Checks for redundant `with_index`.'
1783
+ Enabled: true
1784
+ VersionAdded: '0.50'
1785
+
1786
+ Lint/RedundantWithObject:
1787
+ Description: 'Checks for redundant `with_object`.'
1788
+ Enabled: true
1789
+ VersionAdded: '0.51'
1790
+
1791
+ Lint/RegexpAsCondition:
1792
+ Description: >-
1793
+ Do not use regexp literal as a condition.
1794
+ The regexp literal matches `$_` implicitly.
1795
+ Enabled: true
1796
+ VersionAdded: '0.51'
1797
+ VersionChanged: '0.86'
1798
+
1799
+ Lint/RequireParentheses:
1800
+ Description: >-
1801
+ Use parentheses in the method call to avoid confusion
1802
+ about precedence.
1803
+ Enabled: true
1804
+ VersionAdded: '0.18'
1805
+
1806
+ Lint/RescueException:
1807
+ Description: 'Avoid rescuing the Exception class.'
1808
+ StyleGuide: '#no-blind-rescues'
1809
+ Enabled: true
1810
+ VersionAdded: '0.9'
1811
+ VersionChanged: '0.27.1'
1812
+
1813
+ Lint/RescueType:
1814
+ Description: 'Avoid rescuing from non constants that could result in a `TypeError`.'
1815
+ Enabled: true
1816
+ VersionAdded: '0.49'
1817
+
1818
+ Lint/ReturnInVoidContext:
1819
+ Description: 'Checks for return in void context.'
1820
+ Enabled: true
1821
+ VersionAdded: '0.50'
1822
+
1823
+ Lint/SafeNavigationChain:
1824
+ Description: 'Do not chain ordinary method call after safe navigation operator.'
1825
+ Enabled: true
1826
+ VersionAdded: '0.47'
1827
+ VersionChanged: '0.77'
1828
+ AllowedMethods:
1829
+ - present?
1830
+ - blank?
1831
+ - presence
1832
+ - try
1833
+ - try!
1834
+ - in?
1835
+
1836
+ Lint/SafeNavigationConsistency:
1837
+ Description: >-
1838
+ Check to make sure that if safe navigation is used for a method
1839
+ call in an `&&` or `||` condition that safe navigation is used
1840
+ for all method calls on that same object.
1841
+ Enabled: true
1842
+ VersionAdded: '0.55'
1843
+ VersionChanged: '0.77'
1844
+ AllowedMethods:
1845
+ - present?
1846
+ - blank?
1847
+ - presence
1848
+ - try
1849
+ - try!
1850
+
1851
+ Lint/SafeNavigationWithEmpty:
1852
+ Description: 'Avoid `foo&.empty?` in conditionals.'
1853
+ Enabled: true
1854
+ VersionAdded: '0.62'
1855
+ VersionChanged: '0.87'
1856
+
1857
+ Lint/ScriptPermission:
1858
+ Description: 'Grant script file execute permission.'
1859
+ Enabled: true
1860
+ VersionAdded: '0.49'
1861
+ VersionChanged: '0.50'
1862
+
1863
+ Lint/SelfAssignment:
1864
+ Description: 'Checks for self-assignments.'
1865
+ Enabled: pending
1866
+ VersionAdded: '0.89'
1867
+
1868
+ Lint/SendWithMixinArgument:
1869
+ Description: 'Checks for `send` method when using mixin.'
1870
+ Enabled: true
1871
+ VersionAdded: '0.75'
1872
+
1873
+ Lint/ShadowedArgument:
1874
+ Description: 'Avoid reassigning arguments before they were used.'
1875
+ Enabled: true
1876
+ VersionAdded: '0.52'
1877
+ IgnoreImplicitReferences: false
1878
+
1879
+
1880
+ Lint/ShadowedException:
1881
+ Description: >-
1882
+ Avoid rescuing a higher level exception
1883
+ before a lower level exception.
1884
+ Enabled: true
1885
+ VersionAdded: '0.41'
1886
+
1887
+ Lint/ShadowingOuterLocalVariable:
1888
+ Description: >-
1889
+ Do not use the same name as outer local variable
1890
+ for block arguments or block local variables.
1891
+ Enabled: true
1892
+ VersionAdded: '0.9'
1893
+
1894
+ Lint/StructNewOverride:
1895
+ Description: 'Disallow overriding the `Struct` built-in methods via `Struct.new`.'
1896
+ Enabled: pending
1897
+ VersionAdded: '0.81'
1898
+
1899
+ Lint/SuppressedException:
1900
+ Description: "Don't suppress exceptions."
1901
+ StyleGuide: '#dont-hide-exceptions'
1902
+ Enabled: true
1903
+ AllowComments: true
1904
+ VersionAdded: '0.9'
1905
+ VersionChanged: '0.81'
1906
+
1907
+ Lint/Syntax:
1908
+ Description: 'Checks syntax error.'
1909
+ Enabled: true
1910
+ VersionAdded: '0.9'
1911
+
1912
+
1913
+ Lint/ToJSON:
1914
+ Description: 'Ensure #to_json includes an optional argument.'
1915
+ Enabled: true
1916
+ VersionAdded: '0.66'
1917
+
1918
+ Lint/TopLevelReturnWithArgument:
1919
+ Description: 'This cop detects top level return statements with argument.'
1920
+ Enabled: 'pending'
1921
+ VersionAdded: '0.89'
1922
+
1923
+ Lint/TrailingCommaInAttributeDeclaration:
1924
+ Description: 'This cop checks for trailing commas in attribute declarations.'
1925
+ Enabled: pending
1926
+ VersionAdded: '0.90'
1927
+
1928
+ Lint/UnderscorePrefixedVariableName:
1929
+ Description: 'Do not use prefix `_` for a variable that is used.'
1930
+ Enabled: true
1931
+ VersionAdded: '0.21'
1932
+ AllowKeywordBlockArguments: false
1933
+
1934
+ Lint/UnifiedInteger:
1935
+ Description: 'Use Integer instead of Fixnum or Bignum.'
1936
+ Enabled: true
1937
+ VersionAdded: '0.43'
1938
+
1939
+ Lint/UnreachableCode:
1940
+ Description: 'Unreachable code.'
1941
+ Enabled: true
1942
+ VersionAdded: '0.9'
1943
+
1944
+ Lint/UnreachableLoop:
1945
+ Description: 'This cop checks for loops that will have at most one iteration.'
1946
+ Enabled: pending
1947
+ VersionAdded: '0.89'
1948
+
1949
+ Lint/UnusedBlockArgument:
1950
+ Description: 'Checks for unused block arguments.'
1951
+ StyleGuide: '#underscore-unused-vars'
1952
+ Enabled: true
1953
+ VersionAdded: '0.21'
1954
+ VersionChanged: '0.22'
1955
+ IgnoreEmptyBlocks: true
1956
+ AllowUnusedKeywordArguments: false
1957
+
1958
+ Lint/UnusedMethodArgument:
1959
+ Description: 'Checks for unused method arguments.'
1960
+ StyleGuide: '#underscore-unused-vars'
1961
+ Enabled: true
1962
+ VersionAdded: '0.21'
1963
+ VersionChanged: '0.81'
1964
+ AllowUnusedKeywordArguments: false
1965
+ IgnoreEmptyMethods: true
1966
+ IgnoreNotImplementedMethods: true
1967
+
1968
+ Lint/UriEscapeUnescape:
1969
+ Description: >-
1970
+ `URI.escape` method is obsolete and should not be used. Instead, use
1971
+ `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component`
1972
+ depending on your specific use case.
1973
+ Also `URI.unescape` method is obsolete and should not be used. Instead, use
1974
+ `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component`
1975
+ depending on your specific use case.
1976
+ Enabled: true
1977
+ VersionAdded: '0.50'
1978
+
1979
+ Lint/UriRegexp:
1980
+ Description: 'Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`.'
1981
+ Enabled: true
1982
+ VersionAdded: '0.50'
1983
+
1984
+ Lint/UselessAccessModifier:
1985
+ Description: 'Checks for useless access modifiers.'
1986
+ Enabled: true
1987
+ VersionAdded: '0.20'
1988
+ VersionChanged: '0.83'
1989
+ ContextCreatingMethods: []
1990
+ MethodCreatingMethods: []
1991
+
1992
+ Lint/UselessAssignment:
1993
+ Description: 'Checks for useless assignment to a local variable.'
1994
+ StyleGuide: '#underscore-unused-vars'
1995
+ Enabled: true
1996
+ VersionAdded: '0.11'
1997
+
1998
+ Lint/UselessElseWithoutRescue:
1999
+ Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
2000
+ Enabled: true
2001
+ VersionAdded: '0.17'
2002
+
2003
+ Lint/UselessMethodDefinition:
2004
+ Description: 'Checks for useless method definitions.'
2005
+ Enabled: pending
2006
+ VersionAdded: '0.90'
2007
+ Safe: false
2008
+ AllowComments: true
2009
+
2010
+ Lint/UselessSetterCall:
2011
+ Description: 'Checks for useless setter call to a local variable.'
2012
+ Enabled: true
2013
+ VersionAdded: '0.13'
2014
+ VersionChanged: '0.80'
2015
+ Safe: false
2016
+
2017
+ Lint/UselessTimes:
2018
+ Description: 'Checks for useless `Integer#times` calls.'
2019
+ Enabled: pending
2020
+ VersionAdded: '0.91'
2021
+ Safe: false
2022
+
2023
+ Lint/Void:
2024
+ Description: 'Possible use of operator/literal/variable in void context.'
2025
+ Enabled: true
2026
+ VersionAdded: '0.9'
2027
+ CheckForMethodsWithNoSideEffects: false
2028
+
2029
+ #################### Metrics ###############################
2030
+
2031
+ Metrics/AbcSize:
2032
+ Description: >-
2033
+ A calculated magnitude based on number of assignments,
2034
+ branches, and conditions.
2035
+ Reference:
2036
+ - http://c2.com/cgi/wiki?AbcMetric
2037
+ - https://en.wikipedia.org/wiki/ABC_Software_Metric
2038
+ Enabled: true
2039
+ VersionAdded: '0.27'
2040
+ VersionChanged: '0.81'
2041
+ # The ABC size is a calculated magnitude, so this number can be an Integer or
2042
+ # a Float.
2043
+ IgnoredMethods: []
2044
+ Max: 17
2045
+
2046
+ Metrics/BlockLength:
2047
+ Description: 'Avoid long blocks with many lines.'
2048
+ Enabled: true
2049
+ VersionAdded: '0.44'
2050
+ VersionChanged: '0.87'
2051
+ CountComments: false # count full line comments?
2052
+ Max: 25
2053
+ CountAsOne: []
2054
+ ExcludedMethods:
2055
+ # By default, exclude the `#refine` method, as it tends to have larger
2056
+ # associated blocks.
2057
+ - refine
2058
+ Exclude:
2059
+ - '**/*.gemspec'
2060
+
2061
+ Metrics/BlockNesting:
2062
+ Description: 'Avoid excessive block nesting.'
2063
+ StyleGuide: '#three-is-the-number-thou-shalt-count'
2064
+ Enabled: true
2065
+ VersionAdded: '0.25'
2066
+ VersionChanged: '0.47'
2067
+ CountBlocks: false
2068
+ Max: 3
2069
+
2070
+ Metrics/ClassLength:
2071
+ Description: 'Avoid classes longer than 100 lines of code.'
2072
+ Enabled: true
2073
+ VersionAdded: '0.25'
2074
+ VersionChanged: '0.87'
2075
+ CountComments: false # count full line comments?
2076
+ Max: 100
2077
+ CountAsOne: []
2078
+
2079
+ # Avoid complex methods.
2080
+ Metrics/CyclomaticComplexity:
2081
+ Description: >-
2082
+ A complexity metric that is strongly correlated to the number
2083
+ of test cases needed to validate a method.
2084
+ Enabled: true
2085
+ VersionAdded: '0.25'
2086
+ VersionChanged: '0.81'
2087
+ IgnoredMethods: []
2088
+ Max: 7
2089
+
2090
+ Metrics/MethodLength:
2091
+ Description: 'Avoid methods longer than 10 lines of code.'
2092
+ StyleGuide: '#short-methods'
2093
+ Enabled: true
2094
+ VersionAdded: '0.25'
2095
+ VersionChanged: '0.87'
2096
+ CountComments: false # count full line comments?
2097
+ Max: 10
2098
+ CountAsOne: []
2099
+ ExcludedMethods: []
2100
+
2101
+ Metrics/ModuleLength:
2102
+ Description: 'Avoid modules longer than 100 lines of code.'
2103
+ Enabled: true
2104
+ VersionAdded: '0.31'
2105
+ VersionChanged: '0.87'
2106
+ CountComments: false # count full line comments?
2107
+ Max: 100
2108
+ CountAsOne: []
2109
+
2110
+ Metrics/ParameterLists:
2111
+ Description: 'Avoid parameter lists longer than three or four parameters.'
2112
+ StyleGuide: '#too-many-params'
2113
+ Enabled: true
2114
+ VersionAdded: '0.25'
2115
+ Max: 5
2116
+ CountKeywordArgs: true
2117
+
2118
+ Metrics/PerceivedComplexity:
2119
+ Description: >-
2120
+ A complexity metric geared towards measuring complexity for a
2121
+ human reader.
2122
+ Enabled: true
2123
+ VersionAdded: '0.25'
2124
+ VersionChanged: '0.81'
2125
+ IgnoredMethods: []
2126
+ Max: 8
2127
+
2128
+ ################## Migration #############################
2129
+
2130
+ Migration/DepartmentName:
2131
+ Description: >-
2132
+ Check that cop names in rubocop:disable (etc) comments are
2133
+ given with department name.
2134
+ Enabled: true
2135
+ VersionAdded: '0.75'
2136
+
2137
+ #################### Naming ##############################
2138
+
2139
+ Naming/AccessorMethodName:
2140
+ Description: Check the naming of accessor methods for get_/set_.
2141
+ StyleGuide: '#accessor_mutator_method_names'
2142
+ Enabled: true
2143
+ VersionAdded: '0.50'
2144
+
2145
+ Naming/AsciiIdentifiers:
2146
+ Description: 'Use only ascii symbols in identifiers and constants.'
2147
+ StyleGuide: '#english-identifiers'
2148
+ Enabled: true
2149
+ VersionAdded: '0.50'
2150
+ VersionChanged: '0.87'
2151
+ AsciiConstants: true
2152
+
2153
+ Naming/BinaryOperatorParameterName:
2154
+ Description: 'When defining binary operators, name the argument other.'
2155
+ StyleGuide: '#other-arg'
2156
+ Enabled: true
2157
+ VersionAdded: '0.50'
2158
+
2159
+ Naming/BlockParameterName:
2160
+ Description: >-
2161
+ Checks for block parameter names that contain capital letters,
2162
+ end in numbers, or do not meet a minimal length.
2163
+ Enabled: true
2164
+ VersionAdded: '0.53'
2165
+ VersionChanged: '0.77'
2166
+ # Parameter names may be equal to or greater than this value
2167
+ MinNameLength: 1
2168
+ AllowNamesEndingInNumbers: true
2169
+ # Allowed names that will not register an offense
2170
+ AllowedNames: []
2171
+ # Forbidden names that will register an offense
2172
+ ForbiddenNames: []
2173
+
2174
+ Naming/ClassAndModuleCamelCase:
2175
+ Description: 'Use CamelCase for classes and modules.'
2176
+ StyleGuide: '#camelcase-classes'
2177
+ Enabled: true
2178
+ VersionAdded: '0.50'
2179
+ VersionChanged: '0.85'
2180
+ # Allowed class/module names can be specified here.
2181
+ # These can be full or part of the name.
2182
+ AllowedNames:
2183
+ - module_parent
2184
+
2185
+ Naming/ConstantName:
2186
+ Description: 'Constants should use SCREAMING_SNAKE_CASE.'
2187
+ StyleGuide: '#screaming-snake-case'
2188
+ Enabled: true
2189
+ VersionAdded: '0.50'
583
2190
 
584
2191
  Naming/FileName:
585
- # File names listed in `AllCops:Include` are excluded by default. Add extra
586
- # excludes here.
2192
+ Description: 'Use snake_case for source file names.'
2193
+ StyleGuide: '#snake-case-files'
2194
+ Enabled: true
2195
+ VersionAdded: '0.50'
2196
+ # Camel case file names listed in `AllCops:Include` and all file names listed
2197
+ # in `AllCops:Exclude` are excluded by default. Add extra excludes here.
587
2198
  Exclude: []
588
2199
  # When `true`, requires that each source file should define a class or module
589
2200
  # with a name which matches the file name (converted to ... case).
590
2201
  # It further expects it to be nested inside modules which match the names
591
2202
  # of subdirectories in its path.
592
2203
  ExpectMatchingDefinition: false
2204
+ # When `false`, changes the behavior of ExpectMatchingDefinition to match only
2205
+ # whether each source file's class or module name matches the file name --
2206
+ # not whether the nested module hierarchy matches the subdirectory path.
2207
+ CheckDefinitionPathHierarchy: true
593
2208
  # If non-`nil`, expect all source file names to match the following regex.
594
2209
  # Only the file name itself is matched, not the entire file path.
595
2210
  # Use anchors as necessary if you want to match the entire name rather than
@@ -641,37 +2256,99 @@ Naming/FileName:
641
2256
  - XSRF
642
2257
  - XSS
643
2258
 
644
- Naming/HeredocDelimiterNaming:
645
- Blacklist:
646
- - END
647
- - !ruby/regexp '/EO[A-Z]{1}/'
648
-
649
2259
  Naming/HeredocDelimiterCase:
2260
+ Description: 'Use configured case for heredoc delimiters.'
2261
+ StyleGuide: '#heredoc-delimiters'
2262
+ Enabled: true
2263
+ VersionAdded: '0.50'
650
2264
  EnforcedStyle: uppercase
651
2265
  SupportedStyles:
652
2266
  - lowercase
653
2267
  - uppercase
654
2268
 
2269
+ Naming/HeredocDelimiterNaming:
2270
+ Description: 'Use descriptive heredoc delimiters.'
2271
+ StyleGuide: '#heredoc-delimiters'
2272
+ Enabled: true
2273
+ VersionAdded: '0.50'
2274
+ ForbiddenDelimiters:
2275
+ - !ruby/regexp '/(^|\s)(EO[A-Z]{1}|END)(\s|$)/'
2276
+
2277
+ Naming/MemoizedInstanceVariableName:
2278
+ Description: >-
2279
+ Memoized method name should match memo instance variable name.
2280
+ Enabled: true
2281
+ VersionAdded: '0.53'
2282
+ VersionChanged: '0.58'
2283
+ EnforcedStyleForLeadingUnderscores: disallowed
2284
+ SupportedStylesForLeadingUnderscores:
2285
+ - disallowed
2286
+ - required
2287
+ - optional
2288
+
655
2289
  Naming/MethodName:
2290
+ Description: 'Use the configured style when naming methods.'
2291
+ StyleGuide: '#snake-case-symbols-methods-vars'
2292
+ Enabled: true
2293
+ VersionAdded: '0.50'
656
2294
  EnforcedStyle: snake_case
657
2295
  SupportedStyles:
658
2296
  - snake_case
659
2297
  - camelCase
2298
+ # Method names matching patterns are always allowed.
2299
+ #
2300
+ # IgnoredPatterns:
2301
+ # - '\A\s*onSelectionBulkChange\s*'
2302
+ # - '\A\s*onSelectionCleared\s*'
2303
+ #
2304
+ IgnoredPatterns: []
2305
+
2306
+ Naming/MethodParameterName:
2307
+ Description: >-
2308
+ Checks for method parameter names that contain capital letters,
2309
+ end in numbers, or do not meet a minimal length.
2310
+ Enabled: true
2311
+ VersionAdded: '0.53'
2312
+ VersionChanged: '0.77'
2313
+ # Parameter names may be equal to or greater than this value
2314
+ MinNameLength: 3
2315
+ AllowNamesEndingInNumbers: true
2316
+ # Allowed names that will not register an offense
2317
+ AllowedNames:
2318
+ - at
2319
+ - by
2320
+ - db
2321
+ - id
2322
+ - in
2323
+ - io
2324
+ - ip
2325
+ - of
2326
+ - 'on'
2327
+ - os
2328
+ - pp
2329
+ - to
2330
+ # Forbidden names that will register an offense
2331
+ ForbiddenNames: []
660
2332
 
661
2333
  Naming/PredicateName:
2334
+ Description: 'Check the names of predicate methods.'
2335
+ StyleGuide: '#bool-methods-qmark'
2336
+ Enabled: true
2337
+ VersionAdded: '0.50'
2338
+ VersionChanged: '0.77'
662
2339
  # Predicate name prefixes.
663
2340
  NamePrefix:
664
2341
  - is_
665
2342
  - has_
666
2343
  - have_
667
2344
  # Predicate name prefixes that should be removed.
668
- NamePrefixBlacklist:
2345
+ ForbiddenPrefixes:
669
2346
  - is_
670
2347
  - has_
671
2348
  - have_
672
- # Predicate names which, despite having a blacklisted prefix, or no `?`,
2349
+ # Predicate names which, despite having a forbidden prefix, or no `?`,
673
2350
  # should still be accepted
674
- NameWhitelist:
2351
+ AllowedMethods:
675
2352
  - is_a?
676
2353
  # Method definition macros for dynamically generated methods.
677
2354
  MethodDefinitionMacros:
@@ -682,46 +2359,199 @@ Naming/PredicateName:
682
2359
  Exclude:
683
2360
  - 'spec/**/*'
684
2361
 
2362
+ Naming/RescuedExceptionsVariableName:
2363
+ Description: 'Use consistent rescued exceptions variables naming.'
2364
+ Enabled: true
2365
+ VersionAdded: '0.67'
2366
+ VersionChanged: '0.68'
2367
+ PreferredName: e
2368
+
685
2369
  Naming/VariableName:
2370
+ Description: 'Use the configured style when naming variables.'
2371
+ StyleGuide: '#snake-case-symbols-methods-vars'
2372
+ Enabled: true
2373
+ VersionAdded: '0.50'
686
2374
  EnforcedStyle: snake_case
687
2375
  SupportedStyles:
688
2376
  - snake_case
689
2377
  - camelCase
690
2378
 
691
2379
  Naming/VariableNumber:
2380
+ Description: 'Use the configured style when numbering variables.'
2381
+ Enabled: true
2382
+ VersionAdded: '0.50'
692
2383
  EnforcedStyle: normalcase
693
2384
  SupportedStyles:
694
2385
  - snake_case
695
2386
  - normalcase
696
2387
  - non_integer
697
2388
 
698
- #################### Style ###########################
2389
+ #################### Security ##############################
2390
+
2391
+ Security/Eval:
2392
+ Description: 'The use of eval represents a serious security risk.'
2393
+ Enabled: true
2394
+ VersionAdded: '0.47'
2395
+
2396
+ Security/JSONLoad:
2397
+ Description: >-
2398
+ Prefer usage of `JSON.parse` over `JSON.load` due to potential
2399
+ security issues. See reference for more information.
2400
+ Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load'
2401
+ Enabled: true
2402
+ VersionAdded: '0.43'
2403
+ VersionChanged: '0.44'
2404
+ # Autocorrect here will change to a method that may cause crashes depending
2405
+ # on the value of the argument.
2406
+ AutoCorrect: false
2407
+ SafeAutoCorrect: false
2408
+
2409
+ Security/MarshalLoad:
2410
+ Description: >-
2411
+ Avoid using of `Marshal.load` or `Marshal.restore` due to potential
2412
+ security issues. See reference for more information.
2413
+ Reference: 'https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations'
2414
+ Enabled: true
2415
+ VersionAdded: '0.47'
2416
+
2417
+ Security/Open:
2418
+ Description: 'The use of Kernel#open represents a serious security risk.'
2419
+ Enabled: true
2420
+ VersionAdded: '0.53'
2421
+ Safe: false
2422
+
2423
+ Security/YAMLLoad:
2424
+ Description: >-
2425
+ Prefer usage of `YAML.safe_load` over `YAML.load` due to potential
2426
+ security issues. See reference for more information.
2427
+ Reference: 'https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security'
2428
+ Enabled: true
2429
+ VersionAdded: '0.47'
2430
+ SafeAutoCorrect: false
2431
+
2432
+ #################### Style ###############################
2433
+
2434
+ Style/AccessModifierDeclarations:
2435
+ Description: 'Checks style of how access modifiers are used.'
2436
+ Enabled: true
2437
+ VersionAdded: '0.57'
2438
+ VersionChanged: '0.81'
2439
+ EnforcedStyle: group
2440
+ SupportedStyles:
2441
+ - inline
2442
+ - group
2443
+ AllowModifiersOnSymbols: true
2444
+
2445
+ Style/AccessorGrouping:
2446
+ Description: 'Checks for grouping of accessors in `class` and `module` bodies.'
2447
+ Enabled: 'pending'
2448
+ VersionAdded: '0.87'
2449
+ EnforcedStyle: grouped
2450
+ SupportedStyles:
2451
+ # separated: each accessor goes in a separate statement.
2452
+ # grouped: accessors are grouped into a single statement.
2453
+ - separated
2454
+ - grouped
699
2455
 
700
2456
  Style/Alias:
2457
+ Description: 'Use alias instead of alias_method.'
2458
+ StyleGuide: '#alias-method-lexically'
2459
+ Enabled: true
2460
+ VersionAdded: '0.9'
2461
+ VersionChanged: '0.36'
701
2462
  EnforcedStyle: prefer_alias
702
2463
  SupportedStyles:
703
2464
  - prefer_alias
704
2465
  - prefer_alias_method
705
2466
 
706
2467
  Style/AndOr:
2468
+ Description: 'Use &&/|| instead of and/or.'
2469
+ StyleGuide: '#no-and-or-or'
2470
+ Enabled: true
2471
+ VersionAdded: '0.9'
2472
+ VersionChanged: '0.25'
707
2473
  # Whether `and` and `or` are banned only in conditionals (conditionals)
708
2474
  # or completely (always).
709
- EnforcedStyle: always
2475
+ EnforcedStyle: conditionals
710
2476
  SupportedStyles:
711
2477
  - always
712
2478
  - conditionals
713
2479
 
2480
+ Style/ArrayCoercion:
2481
+ Description: >-
2482
+ Use Array() instead of explicit Array check or [*var], when dealing
2483
+ with a variable you want to treat as an Array, but you're not certain it's an array.
2484
+ StyleGuide: '#array-coercion'
2485
+ Safe: false
2486
+ Enabled: false
2487
+ VersionAdded: '0.88'
2488
+
2489
+ Style/ArrayJoin:
2490
+ Description: 'Use Array#join instead of Array#*.'
2491
+ StyleGuide: '#array-join'
2492
+ Enabled: true
2493
+ VersionAdded: '0.20'
2494
+ VersionChanged: '0.31'
2495
+
714
2496
  Style/AsciiComments:
2497
+ Description: 'Use only ascii symbols in comments.'
2498
+ StyleGuide: '#english-comments'
2499
+ Enabled: true
2500
+ VersionAdded: '0.9'
2501
+ VersionChanged: '0.52'
715
2502
  AllowedChars: []
716
2503
 
717
- # Checks if usage of `%()` or `%Q()` matches configuration.
2504
+ Style/Attr:
2505
+ Description: 'Checks for uses of Module#attr.'
2506
+ StyleGuide: '#attr'
2507
+ Enabled: true
2508
+ VersionAdded: '0.9'
2509
+ VersionChanged: '0.12'
2510
+
2511
+ Style/AutoResourceCleanup:
2512
+ Description: 'Suggests the usage of an auto resource cleanup version of a method (if available).'
2513
+ Enabled: false
2514
+ VersionAdded: '0.30'
2515
+
718
2516
  Style/BarePercentLiterals:
2517
+ Description: 'Checks if usage of %() or %Q() matches configuration.'
2518
+ StyleGuide: '#percent-q-shorthand'
2519
+ Enabled: true
2520
+ VersionAdded: '0.25'
719
2521
  EnforcedStyle: bare_percent
720
2522
  SupportedStyles:
721
2523
  - percent_q
722
2524
  - bare_percent
723
2525
 
2526
+ Style/BeginBlock:
2527
+ Description: 'Avoid the use of BEGIN blocks.'
2528
+ StyleGuide: '#no-BEGIN-blocks'
2529
+ Enabled: true
2530
+ VersionAdded: '0.9'
2531
+
2532
+ Style/BisectedAttrAccessor:
2533
+ Description: >-
2534
+ Checks for places where `attr_reader` and `attr_writer`
2535
+ for the same method can be combined into single `attr_accessor`.
2536
+ Enabled: 'pending'
2537
+ VersionAdded: '0.87'
2538
+
2539
+ Style/BlockComments:
2540
+ Description: 'Do not use block comments.'
2541
+ StyleGuide: '#no-block-comments'
2542
+ Enabled: true
2543
+ VersionAdded: '0.9'
2544
+ VersionChanged: '0.23'
2545
+
724
2546
  Style/BlockDelimiters:
2547
+ Description: >-
2548
+ Avoid using {...} for multi-line blocks (multiline chaining is
2549
+ always ugly).
2550
+ Prefer {...} over do...end for single-line blocks.
2551
+ StyleGuide: '#single-line-blocks'
2552
+ Enabled: true
2553
+ VersionAdded: '0.30'
2554
+ VersionChanged: '0.35'
725
2555
  EnforcedStyle: line_count_based
726
2556
  SupportedStyles:
727
2557
  # The `line_count_based` style enforces braces around single line blocks and
@@ -729,8 +2559,9 @@ Style/BlockDelimiters:
729
2559
  - line_count_based
730
2560
  # The `semantic` style enforces braces around functional blocks, where the
731
2561
  # primary purpose of the block is to return a value and do..end for
732
- # procedural blocks, where the primary purpose of the block is its
733
- # side-effects.
2562
+ # multi-line procedural blocks, where the primary purpose of the block is
2563
+ # its side-effects. Single-line procedural blocks may only use do-end,
2564
+ # unless AllowBracesOnProceduralOneLiners has a truthy value (see below).
734
2565
  #
735
2566
  # This looks at the usage of a block's method to determine its type (e.g. is
736
2567
  # the result of a `map` assigned to a variable or passed to another
@@ -742,6 +2573,8 @@ Style/BlockDelimiters:
742
2573
  # return value is being chained with another method (in which case braces
743
2574
  # are enforced).
744
2575
  - braces_for_chaining
2576
+ # The `always_braces` style always enforces braces.
2577
+ - always_braces
745
2578
  ProceduralMethods:
746
2579
  # Methods that are known to be procedural in nature but look functional from
747
2580
  # their usage, e.g.
@@ -791,23 +2624,75 @@ Style/BlockDelimiters:
791
2624
  - lambda
792
2625
  - proc
793
2626
  - it
794
-
795
- Style/BracesAroundHashParameters:
796
- EnforcedStyle: no_braces
797
- SupportedStyles:
798
- # The `braces` style enforces braces around all method parameters that are
799
- # hashes.
800
- - braces
801
- # The `no_braces` style checks that the last parameter doesn't have braces
802
- # around it.
803
- - no_braces
804
- # The `context_dependent` style checks that the last parameter doesn't have
805
- # braces around it, but requires braces if the second to last parameter is
806
- # also a hash literal.
807
- - context_dependent
2627
+ # The AllowBracesOnProceduralOneLiners option is ignored unless the
2628
+ # EnforcedStyle is set to `semantic`. If so:
2629
+ #
2630
+ # If AllowBracesOnProceduralOneLiners is unspecified, or set to any
2631
+ # falsey value, then semantic purity is maintained, so one-line
2632
+ # procedural blocks must use do-end, not braces.
2633
+ #
2634
+ # # bad
2635
+ # collection.each { |element| puts element }
2636
+ #
2637
+ # # good
2638
+ # collection.each do |element| puts element end
2639
+ #
2640
+ # If AllowBracesOnProceduralOneLiners is set to any truthy value,
2641
+ # then one-line procedural blocks may use either style.
2642
+ #
2643
+ # # good
2644
+ # collection.each { |element| puts element }
2645
+ #
2646
+ # # also good
2647
+ # collection.each do |element| puts element end
2648
+ AllowBracesOnProceduralOneLiners: false
2649
+ # The BracesRequiredMethods overrides all other configurations except
2650
+ # IgnoredMethods. It can be used to enforce that all blocks for specific
2651
+ # methods use braces. For example, you can use this to enforce Sorbet
2652
+ # signatures use braces even when the rest of your codebase enforces
2653
+ # the `line_count_based` style.
2654
+ BracesRequiredMethods: []
2655
+
2656
+ Style/CaseEquality:
2657
+ Description: 'Avoid explicit use of the case equality operator(===).'
2658
+ StyleGuide: '#no-case-equality'
2659
+ Enabled: true
2660
+ VersionAdded: '0.9'
2661
+ VersionChanged: '0.89'
2662
+ # If AllowOnConstant is enabled, the cop will ignore violations when the receiver of
2663
+ # the case equality operator is a constant.
2664
+ #
2665
+ # # bad
2666
+ # /string/ === "string"
2667
+ #
2668
+ # # good
2669
+ # String === "string"
2670
+ AllowOnConstant: false
2671
+
2672
+ Style/CaseLikeIf:
2673
+ Description: 'This cop identifies places where `if-elsif` constructions can be replaced with `case-when`.'
2674
+ StyleGuide: '#case-vs-if-else'
2675
+ Enabled: 'pending'
2676
+ Safe: false
2677
+ VersionAdded: '0.88'
2678
+
2679
+ Style/CharacterLiteral:
2680
+ Description: 'Checks for uses of character literals.'
2681
+ StyleGuide: '#no-character-literals'
2682
+ Enabled: true
2683
+ VersionAdded: '0.9'
808
2684
 
809
2685
  Style/ClassAndModuleChildren:
810
- # Checks the style of children definitions at classes and modules.
2686
+ Description: 'Checks style of children classes and modules.'
2687
+ StyleGuide: '#namespace-definition'
2688
+ # Moving from compact to nested children requires knowledge of whether the
2689
+ # outer parent is a module or a class. Moving from nested to compact requires
2690
+ # verification that the outer parent is defined elsewhere. Rubocop does not
2691
+ # have the knowledge to perform either operation safely and thus requires
2692
+ # manual oversight.
2693
+ SafeAutoCorrect: false
2694
+ Enabled: true
2695
+ VersionAdded: '0.19'
811
2696
  #
812
2697
  # Basically there are two different styles:
813
2698
  #
@@ -828,17 +2713,60 @@ Style/ClassAndModuleChildren:
828
2713
  - compact
829
2714
 
830
2715
  Style/ClassCheck:
2716
+ Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
2717
+ StyleGuide: '#is-a-vs-kind-of'
2718
+ Enabled: true
2719
+ VersionAdded: '0.24'
831
2720
  EnforcedStyle: is_a?
832
2721
  SupportedStyles:
833
2722
  - is_a?
834
2723
  - kind_of?
835
2724
 
2725
+ Style/ClassEqualityComparison:
2726
+ Description: 'Enforces the use of `Object#instance_of?` instead of class comparison for equality.'
2727
+ StyleGuide: '#instance-of-vs-class-comparison'
2728
+ Enabled: pending
2729
+ VersionAdded: '0.93'
2730
+ IgnoredMethods:
2731
+ - ==
2732
+ - equal?
2733
+ - eql?
2734
+
2735
+ Style/ClassMethods:
2736
+ Description: 'Use self when defining module/class methods.'
2737
+ StyleGuide: '#def-self-class-methods'
2738
+ Enabled: true
2739
+ VersionAdded: '0.9'
2740
+ VersionChanged: '0.20'
2741
+
2742
+ Style/ClassMethodsDefinitions:
2743
+ Description: 'Enforces using `def self.method_name` or `class << self` to define class methods.'
2744
+ StyleGuide: '#def-self-class-methods'
2745
+ Enabled: false
2746
+ VersionAdded: '0.89'
2747
+ EnforcedStyle: def_self
2748
+ SupportedStyles:
2749
+ - def_self
2750
+ - self_class
2751
+
2752
+ Style/ClassVars:
2753
+ Description: 'Avoid the use of class variables.'
2754
+ StyleGuide: '#no-class-vars'
2755
+ Enabled: true
2756
+ VersionAdded: '0.13'
2757
+
836
2758
  # Align with the style guide.
837
2759
  Style/CollectionMethods:
838
- # Mapping from undesired method to desired_method
2760
+ Description: 'Preferred collection methods.'
2761
+ StyleGuide: '#map-find-select-reduce-include-size'
2762
+ Enabled: false
2763
+ VersionAdded: '0.9'
2764
+ VersionChanged: '0.27'
2765
+ Safe: false
2766
+ # Mapping from undesired method to desired method
839
2767
  # e.g. to use `detect` over `find`:
840
2768
  #
841
- # CollectionMethods:
2769
+ # Style/CollectionMethods:
842
2770
  # PreferredMethods:
843
2771
  # find: detect
844
2772
  PreferredMethods:
@@ -847,9 +2775,33 @@ Style/CollectionMethods:
847
2775
  inject: 'reduce'
848
2776
  detect: 'find'
849
2777
  find_all: 'select'
2778
+ member?: 'include?'
2779
+
2780
+ Style/ColonMethodCall:
2781
+ Description: 'Do not use :: for method call.'
2782
+ StyleGuide: '#double-colons'
2783
+ Enabled: true
2784
+ VersionAdded: '0.9'
2785
+
2786
+ Style/ColonMethodDefinition:
2787
+ Description: 'Do not use :: for defining class methods.'
2788
+ StyleGuide: '#colon-method-definition'
2789
+ Enabled: true
2790
+ VersionAdded: '0.52'
2791
+
2792
+ Style/CombinableLoops:
2793
+ Description: >-
2794
+ Checks for places where multiple consecutive loops over the same data
2795
+ can be combined into a single loop.
2796
+ Enabled: pending
2797
+ Safe: false
2798
+ VersionAdded: '0.90'
850
2799
 
851
- # Use '`' or '%x' around command literals.
852
2800
  Style/CommandLiteral:
2801
+ Description: 'Use `` or %x around command literals.'
2802
+ StyleGuide: '#percent-x'
2803
+ Enabled: true
2804
+ VersionAdded: '0.30'
853
2805
  EnforcedStyle: backticks
854
2806
  # backticks: Always use backticks.
855
2807
  # percent_x: Always use `%x`.
@@ -864,6 +2816,13 @@ Style/CommandLiteral:
864
2816
 
865
2817
  # Checks formatting of special comments
866
2818
  Style/CommentAnnotation:
2819
+ Description: >-
2820
+ Checks formatting of special comments
2821
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
2822
+ StyleGuide: '#annotate-keywords'
2823
+ Enabled: true
2824
+ VersionAdded: '0.10'
2825
+ VersionChanged: '0.31'
867
2826
  Keywords:
868
2827
  - TODO
869
2828
  - FIXME
@@ -871,7 +2830,19 @@ Style/CommentAnnotation:
871
2830
  - HACK
872
2831
  - REVIEW
873
2832
 
2833
+ Style/CommentedKeyword:
2834
+ Description: 'Do not place comments on the same line as certain keywords.'
2835
+ Enabled: true
2836
+ VersionAdded: '0.51'
2837
+
874
2838
  Style/ConditionalAssignment:
2839
+ Description: >-
2840
+ Use the return value of `if` and `case` statements for
2841
+ assignment to a variable and variable comparison instead
2842
+ of assigning that variable inside of each branch.
2843
+ Enabled: true
2844
+ VersionAdded: '0.36'
2845
+ VersionChanged: '0.47'
875
2846
  EnforcedStyle: assign_to_condition
876
2847
  SupportedStyles:
877
2848
  - assign_to_condition
@@ -885,12 +2856,19 @@ Style/ConditionalAssignment:
885
2856
  SingleLineConditionsOnly: true
886
2857
  IncludeTernaryExpressions: true
887
2858
 
2859
+ Style/ConstantVisibility:
2860
+ Description: >-
2861
+ Check that class- and module constants have
2862
+ visibility declarations.
2863
+ Enabled: false
2864
+ VersionAdded: '0.66'
2865
+
888
2866
  # Checks that you have put a copyright in a comment before any code.
889
2867
  #
890
2868
  # You can override the default Notice in your .rubocop.yml file.
891
2869
  #
892
2870
  # In order to use autocorrect, you must supply a value for the
893
- # `AutocorrectNotice` key that matches the regexp Notice. A blank
2871
+ # `AutocorrectNotice` key that matches the regexp Notice. A blank
894
2872
  # `AutocorrectNotice` will cause an error during autocorrect.
895
2873
  #
896
2874
  # Autocorrect will add a copyright notice in a comment at the top
@@ -904,46 +2882,225 @@ Style/ConditionalAssignment:
904
2882
  # AutocorrectNotice: '# Copyright (c) 2015 Yahoo! Inc.'
905
2883
  #
906
2884
  Style/Copyright:
2885
+ Description: 'Include a copyright notice in each file before any code.'
2886
+ Enabled: false
2887
+ VersionAdded: '0.30'
907
2888
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
908
2889
  AutocorrectNotice: ''
909
2890
 
2891
+ Style/DateTime:
2892
+ Description: 'Use Time over DateTime.'
2893
+ StyleGuide: '#date--time'
2894
+ Enabled: false
2895
+ VersionAdded: '0.51'
2896
+ VersionChanged: '0.92'
2897
+ SafeAutoCorrect: false
2898
+ AllowCoercion: false
2899
+
2900
+ Style/DefWithParentheses:
2901
+ Description: 'Use def with parentheses when there are arguments.'
2902
+ StyleGuide: '#method-parens'
2903
+ Enabled: true
2904
+ VersionAdded: '0.9'
2905
+ VersionChanged: '0.12'
2906
+
2907
+ Style/Dir:
2908
+ Description: >-
2909
+ Use the `__dir__` method to retrieve the canonicalized
2910
+ absolute path to the current file.
2911
+ Enabled: true
2912
+ VersionAdded: '0.50'
2913
+
2914
+ Style/DisableCopsWithinSourceCodeDirective:
2915
+ Description: >-
2916
+ Forbids disabling/enabling cops within source code.
2917
+ Enabled: false
2918
+ VersionAdded: '0.82'
2919
+
2920
+ Style/Documentation:
2921
+ Description: 'Document classes and non-namespace modules.'
2922
+ Enabled: true
2923
+ VersionAdded: '0.9'
2924
+ Exclude:
2925
+ - 'spec/**/*'
2926
+ - 'test/**/*'
2927
+
910
2928
  Style/DocumentationMethod:
2929
+ Description: 'Checks for missing documentation comment for public methods.'
2930
+ Enabled: false
2931
+ VersionAdded: '0.43'
2932
+ Exclude:
2933
+ - 'spec/**/*'
2934
+ - 'test/**/*'
911
2935
  RequireForNonPublicMethods: false
912
2936
 
913
- # Warn on empty else statements
914
- # empty - warn only on empty `else`
915
- # nil - warn on `else` with nil in it
916
- # both - warn on empty `else` and `else` with `nil` in it
2937
+ Style/DoubleCopDisableDirective:
2938
+ Description: 'Checks for double rubocop:disable comments on a single line.'
2939
+ Enabled: true
2940
+ VersionAdded: '0.73'
2941
+
2942
+ Style/DoubleNegation:
2943
+ Description: 'Checks for uses of double negation (!!).'
2944
+ StyleGuide: '#no-bang-bang'
2945
+ Enabled: true
2946
+ VersionAdded: '0.19'
2947
+ VersionChanged: '0.84'
2948
+ EnforcedStyle: allowed_in_returns
2949
+ SafeAutoCorrect: false
2950
+ SupportedStyles:
2951
+ - allowed_in_returns
2952
+ - forbidden
2953
+
2954
+ Style/EachForSimpleLoop:
2955
+ Description: >-
2956
+ Use `Integer#times` for a simple loop which iterates a fixed
2957
+ number of times.
2958
+ Enabled: true
2959
+ VersionAdded: '0.41'
2960
+
2961
+ Style/EachWithObject:
2962
+ Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
2963
+ Enabled: true
2964
+ VersionAdded: '0.22'
2965
+ VersionChanged: '0.42'
2966
+
2967
+ Style/EmptyBlockParameter:
2968
+ Description: 'Omit pipes for empty block parameters.'
2969
+ Enabled: true
2970
+ VersionAdded: '0.52'
2971
+
2972
+ Style/EmptyCaseCondition:
2973
+ Description: 'Avoid empty condition in case statements.'
2974
+ Enabled: true
2975
+ VersionAdded: '0.40'
2976
+
917
2977
  Style/EmptyElse:
2978
+ Description: 'Avoid empty else-clauses.'
2979
+ Enabled: true
2980
+ VersionAdded: '0.28'
2981
+ VersionChanged: '0.32'
918
2982
  EnforcedStyle: both
2983
+ # empty - warn only on empty `else`
2984
+ # nil - warn on `else` with nil in it
2985
+ # both - warn on empty `else` and `else` with `nil` in it
919
2986
  SupportedStyles:
920
2987
  - empty
921
2988
  - nil
922
2989
  - both
923
2990
 
2991
+ Style/EmptyLambdaParameter:
2992
+ Description: 'Omit parens for empty lambda parameters.'
2993
+ Enabled: true
2994
+ VersionAdded: '0.52'
2995
+
2996
+ Style/EmptyLiteral:
2997
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
2998
+ StyleGuide: '#literal-array-hash'
2999
+ Enabled: true
3000
+ VersionAdded: '0.9'
3001
+ VersionChanged: '0.12'
3002
+
924
3003
  Style/EmptyMethod:
3004
+ Description: 'Checks the formatting of empty method definitions.'
3005
+ StyleGuide: '#no-single-line-methods'
3006
+ Enabled: true
3007
+ VersionAdded: '0.46'
925
3008
  EnforcedStyle: compact
926
3009
  SupportedStyles:
927
3010
  - compact
928
3011
  - expanded
929
3012
 
930
- # Checks use of for or each in multiline loops.
3013
+ Style/Encoding:
3014
+ Description: 'Use UTF-8 as the source file encoding.'
3015
+ StyleGuide: '#utf-8'
3016
+ Enabled: true
3017
+ VersionAdded: '0.9'
3018
+ VersionChanged: '0.50'
3019
+
3020
+ Style/EndBlock:
3021
+ Description: 'Avoid the use of END blocks.'
3022
+ StyleGuide: '#no-END-blocks'
3023
+ Enabled: true
3024
+ VersionAdded: '0.9'
3025
+ VersionChanged: '0.81'
3026
+
3027
+ Style/EvalWithLocation:
3028
+ Description: 'Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by backtraces.'
3029
+ Enabled: true
3030
+ VersionAdded: '0.52'
3031
+
3032
+ Style/EvenOdd:
3033
+ Description: 'Favor the use of `Integer#even?` && `Integer#odd?`.'
3034
+ StyleGuide: '#predicate-methods'
3035
+ Enabled: true
3036
+ VersionAdded: '0.12'
3037
+ VersionChanged: '0.29'
3038
+
3039
+ Style/ExpandPathArguments:
3040
+ Description: "Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`."
3041
+ Enabled: true
3042
+ VersionAdded: '0.53'
3043
+
3044
+ Style/ExplicitBlockArgument:
3045
+ Description: >-
3046
+ Consider using explicit block argument to avoid writing block literal
3047
+ that just passes its arguments to another block.
3048
+ StyleGuide: '#block-argument'
3049
+ Enabled: pending
3050
+ # May change the yielding arity.
3051
+ Safe: false
3052
+ VersionAdded: '0.89'
3053
+
3054
+ Style/ExponentialNotation:
3055
+ Description: 'When using exponential notation, favor a mantissa between 1 (inclusive) and 10 (exclusive).'
3056
+ StyleGuide: '#exponential-notation'
3057
+ Enabled: pending
3058
+ VersionAdded: '0.82'
3059
+ EnforcedStyle: scientific
3060
+ SupportedStyles:
3061
+ - scientific
3062
+ - engineering
3063
+ - integral
3064
+
3065
+ Style/FloatDivision:
3066
+ Description: 'For performing float division, coerce one side only.'
3067
+ StyleGuide: '#float-division'
3068
+ Reference: 'https://github.com/rubocop-hq/ruby-style-guide/issues/628'
3069
+ Enabled: true
3070
+ VersionAdded: '0.72'
3071
+ EnforcedStyle: single_coerce
3072
+ SupportedStyles:
3073
+ - left_coerce
3074
+ - right_coerce
3075
+ - single_coerce
3076
+ - fdiv
3077
+
931
3078
  Style/For:
3079
+ Description: 'Checks use of for or each in multiline loops.'
3080
+ StyleGuide: '#no-for-loops'
3081
+ Enabled: true
3082
+ VersionAdded: '0.13'
3083
+ VersionChanged: '0.59'
932
3084
  EnforcedStyle: each
933
3085
  SupportedStyles:
934
- - for
935
3086
  - each
3087
+ - for
936
3088
 
937
- # Enforce the method used for string formatting.
938
3089
  Style/FormatString:
3090
+ Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
3091
+ StyleGuide: '#sprintf'
3092
+ Enabled: true
3093
+ VersionAdded: '0.19'
3094
+ VersionChanged: '0.49'
939
3095
  EnforcedStyle: format
940
3096
  SupportedStyles:
941
3097
  - format
942
3098
  - sprintf
943
3099
  - percent
944
3100
 
945
- # Enforce using either `%<token>s` or `%{token}`
946
3101
  Style/FormatStringToken:
3102
+ Description: 'Use a consistent style for format string tokens.'
3103
+ Enabled: true
947
3104
  EnforcedStyle: annotated
948
3105
  SupportedStyles:
949
3106
  # Prefer tokens which contain a sprintf like type annotation like
@@ -952,32 +3109,94 @@ Style/FormatStringToken:
952
3109
  # Prefer simple looking "template" style tokens like `%{name}`, `%{age}`
953
3110
  - template
954
3111
  - unannotated
3112
+ VersionAdded: '0.49'
3113
+ VersionChanged: '0.75'
955
3114
 
956
3115
  Style/FrozenStringLiteralComment:
957
- EnforcedStyle: when_needed
3116
+ Description: >-
3117
+ Add the frozen_string_literal comment to the top of files
3118
+ to help transition to frozen string literals by default.
3119
+ Enabled: true
3120
+ VersionAdded: '0.36'
3121
+ VersionChanged: '0.79'
3122
+ EnforcedStyle: always
958
3123
  SupportedStyles:
959
- # `when_needed` will add the frozen string literal comment to files
960
- # only when the `TargetRubyVersion` is set to 2.3+.
961
- - when_needed
962
3124
  # `always` will always add the frozen string literal comment to a file
963
3125
  # regardless of the Ruby version or if `freeze` or `<<` are called on a
964
- # string literal. If you run code against multiple versions of Ruby, it is
965
- # possible that this will create errors in Ruby 2.3.0+.
3126
+ # string literal. It is possible that this will create errors.
966
3127
  - always
3128
+ # `always_true` will add the frozen string literal comment to a file,
3129
+ # similarly to the `always` style, but will also change any disabled
3130
+ # comments (e.g. `# frozen_string_literal: false`) to be enabled.
3131
+ - always_true
967
3132
  # `never` will enforce that the frozen string literal comment does not
968
3133
  # exist in a file.
969
3134
  - never
3135
+ SafeAutoCorrect: false
3136
+
3137
+ Style/GlobalStdStream:
3138
+ Description: 'Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`.'
3139
+ StyleGuide: '#global-stdout'
3140
+ Enabled: pending
3141
+ VersionAdded: '0.89'
3142
+ SafeAutoCorrect: false
970
3143
 
971
- # Built-in global variables are allowed by default.
972
3144
  Style/GlobalVars:
3145
+ Description: 'Do not introduce global variables.'
3146
+ StyleGuide: '#instance-vars'
3147
+ Reference: 'https://www.zenspider.com/ruby/quickref.html'
3148
+ Enabled: true
3149
+ VersionAdded: '0.13'
3150
+ # Built-in global variables are allowed by default.
973
3151
  AllowedVariables: []
974
3152
 
975
- # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
976
- # needs to have to trigger this cop
977
3153
  Style/GuardClause:
3154
+ Description: 'Check for conditionals that can be replaced with guard clauses.'
3155
+ StyleGuide: '#no-nested-conditionals'
3156
+ Enabled: true
3157
+ VersionAdded: '0.20'
3158
+ VersionChanged: '0.22'
3159
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
3160
+ # needs to have to trigger this cop
978
3161
  MinBodyLength: 1
979
3162
 
3163
+ Style/HashAsLastArrayItem:
3164
+ Description: >-
3165
+ Checks for presence or absence of braces around hash literal as a last
3166
+ array item depending on configuration.
3167
+ StyleGuide: '#hash-literal-as-last-array-item'
3168
+ Enabled: 'pending'
3169
+ VersionAdded: '0.88'
3170
+ EnforcedStyle: braces
3171
+ SupportedStyles:
3172
+ - braces
3173
+ - no_braces
3174
+
3175
+ Style/HashEachMethods:
3176
+ Description: 'Use Hash#each_key and Hash#each_value.'
3177
+ StyleGuide: '#hash-each'
3178
+ Enabled: pending
3179
+ VersionAdded: '0.80'
3180
+ Safe: false
3181
+
3182
+ Style/HashLikeCase:
3183
+ Description: >-
3184
+ Checks for places where `case-when` represents a simple 1:1
3185
+ mapping and can be replaced with a hash lookup.
3186
+ Enabled: 'pending'
3187
+ VersionAdded: '0.88'
3188
+ # `MinBranchesCount` defines the number of branches `case` needs to have
3189
+ # to trigger this cop
3190
+ MinBranchesCount: 3
3191
+
980
3192
  Style/HashSyntax:
3193
+ Description: >-
3194
+ Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
3195
+ { :a => 1, :b => 2 }.
3196
+ StyleGuide: '#hash-literals'
3197
+ Enabled: true
3198
+ VersionAdded: '0.9'
3199
+ VersionChanged: '0.43'
981
3200
  EnforcedStyle: ruby19
982
3201
  SupportedStyles:
983
3202
  # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
@@ -993,7 +3212,84 @@ Style/HashSyntax:
993
3212
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
994
3213
  PreferHashRocketsForNonAlnumEndingSymbols: false
995
3214
 
3215
+ Style/HashTransformKeys:
3216
+ Description: 'Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`.'
3217
+ Enabled: 'pending'
3218
+ VersionAdded: '0.80'
3219
+ VersionChanged: '0.90'
3220
+ Safe: false
3221
+
3222
+ Style/HashTransformValues:
3223
+ Description: 'Prefer `transform_values` over `each_with_object`, `map`, or `to_h`.'
3224
+ Enabled: 'pending'
3225
+ VersionAdded: '0.80'
3226
+ VersionChanged: '0.90'
3227
+ Safe: false
3228
+
3229
+ Style/IdenticalConditionalBranches:
3230
+ Description: >-
3231
+ Checks that conditional statements do not have an identical
3232
+ line at the end of each branch, which can validly be moved
3233
+ out of the conditional.
3234
+ Enabled: true
3235
+ VersionAdded: '0.36'
3236
+
3237
+ Style/IfInsideElse:
3238
+ Description: 'Finds if nodes inside else, which can be converted to elsif.'
3239
+ Enabled: true
3240
+ AllowIfModifier: false
3241
+ VersionAdded: '0.36'
3242
+
3243
+ Style/IfUnlessModifier:
3244
+ Description: >-
3245
+ Favor modifier if/unless usage when you have a
3246
+ single-line body.
3247
+ StyleGuide: '#if-as-a-modifier'
3248
+ Enabled: true
3249
+ VersionAdded: '0.9'
3250
+ VersionChanged: '0.30'
3251
+
3252
+ Style/IfUnlessModifierOfIfUnless:
3253
+ Description: >-
3254
+ Avoid modifier if/unless usage on conditionals.
3255
+ Enabled: true
3256
+ VersionAdded: '0.39'
3257
+ VersionChanged: '0.87'
3258
+
3259
+ Style/IfWithSemicolon:
3260
+ Description: 'Do not use if x; .... Use the ternary operator instead.'
3261
+ StyleGuide: '#no-semicolon-ifs'
3262
+ Enabled: true
3263
+ VersionAdded: '0.9'
3264
+ VersionChanged: '0.83'
3265
+
3266
+ Style/ImplicitRuntimeError:
3267
+ Description: >-
3268
+ Use `raise` or `fail` with an explicit exception class and
3269
+ message, rather than just a message.
3270
+ Enabled: false
3271
+ VersionAdded: '0.41'
3272
+
3273
+ Style/InfiniteLoop:
3274
+ Description: 'Use Kernel#loop for infinite loops.'
3275
+ StyleGuide: '#infinite-loop'
3276
+ Enabled: true
3277
+ VersionAdded: '0.26'
3278
+ VersionChanged: '0.61'
3279
+ SafeAutoCorrect: true
3280
+
3281
+ Style/InlineComment:
3282
+ Description: 'Avoid trailing inline comments.'
3283
+ Enabled: false
3284
+ VersionAdded: '0.23'
3285
+
996
3286
  Style/InverseMethods:
3287
+ Description: >-
3288
+ Use the inverse method instead of `!.method`
3289
+ if an inverse method is defined.
3290
+ Enabled: true
3291
+ Safe: false
3292
+ VersionAdded: '0.48'
997
3293
  # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
998
3294
  # The relationship of inverse methods only needs to be defined in one direction.
999
3295
  # Keys and values both need to be defined as symbols.
@@ -1014,7 +3310,33 @@ Style/InverseMethods:
1014
3310
  :select: :reject
1015
3311
  :select!: :reject!
1016
3312
 
3313
+ Style/IpAddresses:
3314
+ Description: "Don't include literal IP addresses in code."
3315
+ Enabled: false
3316
+ VersionAdded: '0.58'
3317
+ VersionChanged: '0.91'
3318
+ # Allow addresses to be permitted
3319
+ AllowedAddresses:
3320
+ - "::"
3321
+ # :: is a valid IPv6 address, but could potentially be legitimately in code
3322
+ Exclude:
3323
+ - '**/*.gemfile'
3324
+ - '**/Gemfile'
3325
+ - '**/gems.rb'
3326
+ - '**/*.gemspec'
3327
+
3328
+ Style/KeywordParametersOrder:
3329
+ Description: 'Enforces that optional keyword parameters are placed at the end of the parameters list.'
3330
+ StyleGuide: '#keyword-parameters-order'
3331
+ Enabled: pending
3332
+ VersionAdded: '0.90'
3333
+
1017
3334
  Style/Lambda:
3335
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
3336
+ StyleGuide: '#lambda-multi-line'
3337
+ Enabled: true
3338
+ VersionAdded: '0.9'
3339
+ VersionChanged: '0.40'
1018
3340
  EnforcedStyle: line_count_dependent
1019
3341
  SupportedStyles:
1020
3342
  - line_count_dependent
@@ -1022,25 +3344,111 @@ Style/Lambda:
1022
3344
  - literal
1023
3345
 
1024
3346
  Style/LambdaCall:
3347
+ Description: 'Use lambda.call(...) instead of lambda.(...).'
3348
+ StyleGuide: '#proc-call'
3349
+ Enabled: true
3350
+ VersionAdded: '0.13'
3351
+ VersionChanged: '0.14'
1025
3352
  EnforcedStyle: call
1026
3353
  SupportedStyles:
1027
3354
  - call
1028
3355
  - braces
1029
3356
 
3357
+ Style/LineEndConcatenation:
3358
+ Description: >-
3359
+ Use \ instead of + or << to concatenate two string literals at
3360
+ line end.
3361
+ Enabled: true
3362
+ SafeAutoCorrect: false
3363
+ VersionAdded: '0.18'
3364
+ VersionChanged: '0.64'
3365
+
1030
3366
  Style/MethodCallWithArgsParentheses:
3367
+ Description: 'Use parentheses for method calls with arguments.'
3368
+ StyleGuide: '#method-invocation-parens'
3369
+ Enabled: false
3370
+ VersionAdded: '0.47'
3371
+ VersionChanged: '0.61'
1031
3372
  IgnoreMacros: true
1032
3373
  IgnoredMethods: []
3374
+ IgnoredPatterns: []
3375
+ IncludedMacros: []
3376
+ AllowParenthesesInMultilineCall: false
3377
+ AllowParenthesesInChaining: false
3378
+ AllowParenthesesInCamelCaseMethod: false
3379
+ EnforcedStyle: require_parentheses
3380
+ SupportedStyles:
3381
+ - require_parentheses
3382
+ - omit_parentheses
3383
+
3384
+ Style/MethodCallWithoutArgsParentheses:
3385
+ Description: 'Do not use parentheses for method calls with no arguments.'
3386
+ StyleGuide: '#method-invocation-parens'
3387
+ Enabled: true
3388
+ IgnoredMethods: []
3389
+ VersionAdded: '0.47'
3390
+ VersionChanged: '0.55'
3391
+
3392
+ Style/MethodCalledOnDoEndBlock:
3393
+ Description: 'Avoid chaining a method call on a do...end block.'
3394
+ StyleGuide: '#single-line-blocks'
3395
+ Enabled: false
3396
+ VersionAdded: '0.14'
1033
3397
 
1034
3398
  Style/MethodDefParentheses:
3399
+ Description: >-
3400
+ Checks if the method definitions have or don't have
3401
+ parentheses.
3402
+ StyleGuide: '#method-parens'
3403
+ Enabled: true
3404
+ VersionAdded: '0.16'
3405
+ VersionChanged: '0.35'
1035
3406
  EnforcedStyle: require_parentheses
1036
3407
  SupportedStyles:
1037
3408
  - require_parentheses
1038
3409
  - require_no_parentheses
1039
3410
  - require_no_parentheses_except_multiline
1040
3411
 
1041
- # Checks the grouping of mixins (`include`, `extend`, `prepend`) in `class` and
1042
- # `module` bodies.
3412
+ Style/MinMax:
3413
+ Description: >-
3414
+ Use `Enumerable#minmax` instead of `Enumerable#min`
3415
+ and `Enumerable#max` in conjunction.
3416
+ Enabled: true
3417
+ VersionAdded: '0.50'
3418
+
3419
+ Style/MissingElse:
3420
+ Description: >-
3421
+ Require if/case expressions to have an else branches.
3422
+ If enabled, it is recommended that
3423
+ Style/UnlessElse and Style/EmptyElse be enabled.
3424
+ This will conflict with Style/EmptyElse if
3425
+ Style/EmptyElse is configured to style "both".
3426
+ Enabled: false
3427
+ VersionAdded: '0.30'
3428
+ VersionChanged: '0.38'
3429
+ EnforcedStyle: both
3430
+ SupportedStyles:
3431
+ # if - warn when an if expression is missing an else branch
3432
+ # case - warn when a case expression is missing an else branch
3433
+ # both - warn when an if or case expression is missing an else branch
3434
+ - if
3435
+ - case
3436
+ - both
3437
+
3438
+ Style/MissingRespondToMissing:
3439
+ Description: >-
3440
+ Checks if `method_missing` is implemented
3441
+ without implementing `respond_to_missing`.
3442
+ StyleGuide: '#no-method-missing'
3443
+ Enabled: true
3444
+ VersionAdded: '0.56'
3445
+
1043
3446
  Style/MixinGrouping:
3447
+ Description: 'Checks for grouping of mixins in `class` and `module` bodies.'
3448
+ StyleGuide: '#mixin-grouping'
3449
+ Enabled: true
3450
+ VersionAdded: '0.48'
3451
+ VersionChanged: '0.49'
1044
3452
  EnforcedStyle: separated
1045
3453
  SupportedStyles:
1046
3454
  # separated: each mixed in module goes in a separate statement.
@@ -1048,19 +3456,105 @@ Style/MixinGrouping:
1048
3456
  - separated
1049
3457
  - grouped
1050
3458
 
3459
+ Style/MixinUsage:
3460
+ Description: 'Checks that `include`, `extend` and `prepend` exists at the top level.'
3461
+ Enabled: true
3462
+ VersionAdded: '0.51'
3463
+
1051
3464
  Style/ModuleFunction:
3465
+ Description: 'Checks for usage of `extend self` in modules.'
3466
+ StyleGuide: '#module-function'
3467
+ Enabled: true
3468
+ VersionAdded: '0.11'
3469
+ VersionChanged: '0.65'
1052
3470
  EnforcedStyle: module_function
1053
3471
  SupportedStyles:
1054
3472
  - module_function
1055
3473
  - extend_self
3474
+ - forbidden
3475
+ Autocorrect: false
3476
+ SafeAutoCorrect: false
3477
+
3478
+ Style/MultilineBlockChain:
3479
+ Description: 'Avoid multi-line chains of blocks.'
3480
+ StyleGuide: '#single-line-blocks'
3481
+ Enabled: true
3482
+ VersionAdded: '0.13'
3483
+
3484
+ Style/MultilineIfModifier:
3485
+ Description: 'Only use if/unless modifiers on single line statements.'
3486
+ StyleGuide: '#no-multiline-if-modifiers'
3487
+ Enabled: true
3488
+ VersionAdded: '0.45'
3489
+
3490
+ Style/MultilineIfThen:
3491
+ Description: 'Do not use then for multi-line if/unless.'
3492
+ StyleGuide: '#no-then'
3493
+ Enabled: true
3494
+ VersionAdded: '0.9'
3495
+ VersionChanged: '0.26'
1056
3496
 
1057
3497
  Style/MultilineMemoization:
3498
+ Description: 'Wrap multiline memoizations in a `begin` and `end` block.'
3499
+ Enabled: true
3500
+ VersionAdded: '0.44'
3501
+ VersionChanged: '0.48'
1058
3502
  EnforcedStyle: keyword
1059
3503
  SupportedStyles:
1060
3504
  - keyword
1061
3505
  - braces
1062
3506
 
3507
+ Style/MultilineMethodSignature:
3508
+ Description: 'Avoid multi-line method signatures.'
3509
+ Enabled: false
3510
+ VersionAdded: '0.59'
3511
+
3512
+ Style/MultilineTernaryOperator:
3513
+ Description: >-
3514
+ Avoid multi-line ?: (the ternary operator);
3515
+ use if/unless instead.
3516
+ StyleGuide: '#no-multiline-ternary'
3517
+ Enabled: true
3518
+ VersionAdded: '0.9'
3519
+ VersionChanged: '0.86'
3520
+
3521
+ Style/MultilineWhenThen:
3522
+ Description: 'Do not use then for multi-line when statement.'
3523
+ StyleGuide: '#no-then'
3524
+ Enabled: true
3525
+ VersionAdded: '0.73'
3526
+
3527
+ Style/MultipleComparison:
3528
+ Description: >-
3529
+ Avoid comparing a variable with multiple items in a conditional,
3530
+ use Array#include? instead.
3531
+ Enabled: true
3532
+ VersionAdded: '0.49'
3533
+
3534
+ Style/MutableConstant:
3535
+ Description: 'Do not assign mutable objects to constants.'
3536
+ Enabled: true
3537
+ VersionAdded: '0.34'
3538
+ VersionChanged: '0.65'
3539
+ EnforcedStyle: literals
3540
+ SupportedStyles:
3541
+ # literals: freeze literals assigned to constants
3542
+ # strict: freeze all constants
3543
+ # Strict mode is considered an experimental feature. It has not been updated
3544
+ # with an exhaustive list of all methods that will produce frozen objects so
3545
+ # there is a decent chance of getting some false positives. Luckily, there is
3546
+ # no harm in freezing an already frozen object.
3547
+ - literals
3548
+ - strict
3549
+
1063
3550
  Style/NegatedIf:
3551
+ Description: >-
3552
+ Favor unless over if for negative conditions
3553
+ (or control flow or).
3554
+ StyleGuide: '#unless-for-negatives'
3555
+ Enabled: true
3556
+ VersionAdded: '0.20'
3557
+ VersionChanged: '0.48'
1064
3558
  EnforcedStyle: both
1065
3559
  SupportedStyles:
1066
3560
  # both: prefix and postfix negated `if` should both use `unless`
@@ -1070,8 +3564,40 @@ Style/NegatedIf:
1070
3564
  - prefix
1071
3565
  - postfix
1072
3566
 
3567
+ Style/NegatedUnless:
3568
+ Description: 'Favor if over unless for negative conditions.'
3569
+ StyleGuide: '#if-for-negatives'
3570
+ Enabled: true
3571
+ VersionAdded: '0.69'
3572
+ EnforcedStyle: both
3573
+ SupportedStyles:
3574
+ # both: prefix and postfix negated `unless` should both use `if`
3575
+ # prefix: only use `if` for negated `unless` statements positioned before the body of the statement
3576
+ # postfix: only use `if` for negated `unless` statements positioned after the body of the statement
3577
+ - both
3578
+ - prefix
3579
+ - postfix
3580
+
3581
+ Style/NegatedWhile:
3582
+ Description: 'Favor until over while for negative conditions.'
3583
+ StyleGuide: '#until-for-negatives'
3584
+ Enabled: true
3585
+ VersionAdded: '0.20'
3586
+
3587
+ Style/NestedModifier:
3588
+ Description: 'Avoid using nested modifiers.'
3589
+ StyleGuide: '#no-nested-modifiers'
3590
+ Enabled: true
3591
+ VersionAdded: '0.35'
3592
+
1073
3593
  Style/NestedParenthesizedCalls:
1074
- Whitelist:
3594
+ Description: >-
3595
+ Parenthesize method calls which are nested inside the
3596
+ argument list of another parenthesized method call.
3597
+ Enabled: true
3598
+ VersionAdded: '0.36'
3599
+ VersionChanged: '0.77'
3600
+ AllowedMethods:
1075
3601
  - be
1076
3602
  - be_a
1077
3603
  - be_an
@@ -1090,7 +3616,19 @@ Style/NestedParenthesizedCalls:
1090
3616
  - respond_to
1091
3617
  - start_with
1092
3618
 
3619
+ Style/NestedTernaryOperator:
3620
+ Description: 'Use one expression per branch in a ternary operator.'
3621
+ StyleGuide: '#no-nested-ternary'
3622
+ Enabled: true
3623
+ VersionAdded: '0.9'
3624
+ VersionChanged: '0.86'
3625
+
1093
3626
  Style/Next:
3627
+ Description: 'Use `next` to skip iteration instead of a condition at the end.'
3628
+ StyleGuide: '#no-nested-conditionals'
3629
+ Enabled: true
3630
+ VersionAdded: '0.22'
3631
+ VersionChanged: '0.35'
1094
3632
  # With `always` all conditions at the end of an iteration needs to be
1095
3633
  # replaced by next - with `skip_modifier_ifs` the modifier if like this one
1096
3634
  # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
@@ -1102,7 +3640,23 @@ Style/Next:
1102
3640
  - skip_modifier_ifs
1103
3641
  - always
1104
3642
 
3643
+ Style/NilComparison:
3644
+ Description: 'Prefer x.nil? to x == nil.'
3645
+ StyleGuide: '#predicate-methods'
3646
+ Enabled: true
3647
+ VersionAdded: '0.12'
3648
+ VersionChanged: '0.59'
3649
+ EnforcedStyle: predicate
3650
+ SupportedStyles:
3651
+ - predicate
3652
+ - comparison
3653
+
1105
3654
  Style/NonNilCheck:
3655
+ Description: 'Checks for redundant nil checks.'
3656
+ StyleGuide: '#no-non-nil-checks'
3657
+ Enabled: true
3658
+ VersionAdded: '0.20'
3659
+ VersionChanged: '0.22'
1106
3660
  # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
1107
3661
  # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
1108
3662
  # **usually** OK, but might change behavior.
@@ -1111,27 +3665,73 @@ Style/NonNilCheck:
1111
3665
  # offenses for `!x.nil?` and does no changes that might change behavior.
1112
3666
  IncludeSemanticChanges: false
1113
3667
 
1114
- Style/NumericLiterals:
1115
- MinDigits: 5
1116
- Strict: false
3668
+ Style/Not:
3669
+ Description: 'Use ! instead of not.'
3670
+ StyleGuide: '#bang-not-not'
3671
+ Enabled: true
3672
+ VersionAdded: '0.9'
3673
+ VersionChanged: '0.20'
1117
3674
 
1118
3675
  Style/NumericLiteralPrefix:
3676
+ Description: 'Use smallcase prefixes for numeric literals.'
3677
+ StyleGuide: '#numeric-literal-prefixes'
3678
+ Enabled: true
3679
+ VersionAdded: '0.41'
1119
3680
  EnforcedOctalStyle: zero_with_o
1120
3681
  SupportedOctalStyles:
1121
3682
  - zero_with_o
1122
3683
  - zero_only
1123
3684
 
3685
+
3686
+ Style/NumericLiterals:
3687
+ Description: >-
3688
+ Add underscores to large numeric literals to improve their
3689
+ readability.
3690
+ StyleGuide: '#underscores-in-numerics'
3691
+ Enabled: true
3692
+ VersionAdded: '0.9'
3693
+ VersionChanged: '0.48'
3694
+ MinDigits: 5
3695
+ Strict: false
3696
+
1124
3697
  Style/NumericPredicate:
3698
+ Description: >-
3699
+ Checks for the use of predicate- or comparison methods for
3700
+ numeric comparisons.
3701
+ StyleGuide: '#predicate-methods'
3702
+ Safe: false
3703
+ # This will change to a new method call which isn't guaranteed to be on the
3704
+ # object. Switching these methods has to be done with knowledge of the types
3705
+ # of the variables which rubocop doesn't have.
3706
+ SafeAutoCorrect: false
3707
+ Enabled: true
3708
+ VersionAdded: '0.42'
3709
+ VersionChanged: '0.59'
1125
3710
  EnforcedStyle: predicate
1126
3711
  SupportedStyles:
1127
3712
  - predicate
1128
3713
  - comparison
3714
+ IgnoredMethods: []
1129
3715
  # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
1130
3716
  # false positives.
1131
3717
  Exclude:
1132
3718
  - 'spec/**/*'
1133
3719
 
3720
+ Style/OneLineConditional:
3721
+ Description: >-
3722
+ Favor the ternary operator (?:) or multi-line constructs over
3723
+ single-line if/then/else/end constructs.
3724
+ StyleGuide: '#ternary-operator'
3725
+ Enabled: true
3726
+ AlwaysCorrectToMultiline: false
3727
+ VersionAdded: '0.9'
3728
+ VersionChanged: '0.90'
3729
+
1134
3730
  Style/OptionHash:
3731
+ Description: "Don't use option hashes when you can use keyword arguments."
3732
+ Enabled: false
3733
+ VersionAdded: '0.33'
3734
+ VersionChanged: '0.34'
1135
3735
  # A list of parameter names that will be flagged by this cop.
1136
3736
  SuspiciousParamNames:
1137
3737
  - options
@@ -1140,11 +3740,56 @@ Style/OptionHash:
1140
3740
  - params
1141
3741
  - parameters
1142
3742
 
1143
- # Allow safe assignment in conditions.
3743
+ Style/OptionalArguments:
3744
+ Description: >-
3745
+ Checks for optional arguments that do not appear at the end
3746
+ of the argument list.
3747
+ StyleGuide: '#optional-arguments'
3748
+ Enabled: true
3749
+ Safe: false
3750
+ VersionAdded: '0.33'
3751
+ VersionChanged: '0.83'
3752
+
3753
+ Style/OptionalBooleanParameter:
3754
+ Description: 'Use keyword arguments when defining method with boolean argument.'
3755
+ StyleGuide: '#boolean-keyword-arguments'
3756
+ Enabled: pending
3757
+ Safe: false
3758
+ VersionAdded: '0.89'
3759
+ AllowedMethods:
3760
+ - respond_to_missing?
3761
+
3762
+ Style/OrAssignment:
3763
+ Description: 'Recommend usage of double pipe equals (||=) where applicable.'
3764
+ StyleGuide: '#double-pipe-for-uninit'
3765
+ Enabled: true
3766
+ VersionAdded: '0.50'
3767
+
3768
+ Style/ParallelAssignment:
3769
+ Description: >-
3770
+ Check for simple usages of parallel assignment.
3771
+ It will only warn when the number of variables
3772
+ matches on both sides of the assignment.
3773
+ StyleGuide: '#parallel-assignment'
3774
+ Enabled: true
3775
+ VersionAdded: '0.32'
3776
+
1144
3777
  Style/ParenthesesAroundCondition:
3778
+ Description: >-
3779
+ Don't use parentheses around the condition of an
3780
+ if/unless/while.
3781
+ StyleGuide: '#no-parens-around-condition'
3782
+ Enabled: true
3783
+ VersionAdded: '0.9'
3784
+ VersionChanged: '0.56'
1145
3785
  AllowSafeAssignment: true
3786
+ AllowInMultilineConditions: false
1146
3787
 
1147
3788
  Style/PercentLiteralDelimiters:
3789
+ Description: 'Use `%`-literal delimiters consistently.'
3790
+ StyleGuide: '#percent-literal-braces'
3791
+ Enabled: true
3792
+ VersionAdded: '0.19'
1148
3793
  # Specify the default preferred delimiter for all types with the 'default' key
1149
3794
  # Override individual delimiters (even with default specified) by specifying
1150
3795
  # an individual key
@@ -1155,31 +3800,188 @@ Style/PercentLiteralDelimiters:
1155
3800
  '%r': '{}'
1156
3801
  '%w': '[]'
1157
3802
  '%W': '[]'
3803
+ VersionChanged: '0.48.1'
1158
3804
 
1159
3805
  Style/PercentQLiterals:
3806
+ Description: 'Checks if uses of %Q/%q match the configured preference.'
3807
+ Enabled: true
3808
+ VersionAdded: '0.25'
1160
3809
  EnforcedStyle: lower_case_q
1161
3810
  SupportedStyles:
1162
3811
  - lower_case_q # Use `%q` when possible, `%Q` when necessary
1163
3812
  - upper_case_q # Always use `%Q`
1164
3813
 
3814
+ Style/PerlBackrefs:
3815
+ Description: 'Avoid Perl-style regex back references.'
3816
+ StyleGuide: '#no-perl-regexp-last-matchers'
3817
+ Enabled: true
3818
+ VersionAdded: '0.13'
3819
+
1165
3820
  Style/PreferredHashMethods:
3821
+ Description: 'Checks use of `has_key?` and `has_value?` Hash methods.'
3822
+ StyleGuide: '#hash-key'
3823
+ Enabled: true
3824
+ Safe: false
3825
+ VersionAdded: '0.41'
3826
+ VersionChanged: '0.70'
1166
3827
  EnforcedStyle: short
1167
3828
  SupportedStyles:
1168
3829
  - short
1169
3830
  - verbose
1170
3831
 
3832
+ Style/Proc:
3833
+ Description: 'Use proc instead of Proc.new.'
3834
+ StyleGuide: '#proc'
3835
+ Enabled: true
3836
+ VersionAdded: '0.9'
3837
+ VersionChanged: '0.18'
3838
+
1171
3839
  Style/RaiseArgs:
3840
+ Description: 'Checks the arguments passed to raise/fail.'
3841
+ StyleGuide: '#exception-class-messages'
3842
+ Enabled: true
3843
+ VersionAdded: '0.14'
3844
+ VersionChanged: '0.40'
1172
3845
  EnforcedStyle: exploded
1173
3846
  SupportedStyles:
1174
3847
  - compact # raise Exception.new(msg)
1175
3848
  - exploded # raise Exception, msg
1176
3849
 
3850
+ Style/RandomWithOffset:
3851
+ Description: >-
3852
+ Prefer to use ranges when generating random numbers instead of
3853
+ integers with offsets.
3854
+ StyleGuide: '#random-numbers'
3855
+ Enabled: true
3856
+ VersionAdded: '0.52'
3857
+
3858
+ Style/RedundantAssignment:
3859
+ Description: 'Checks for redundant assignment before returning.'
3860
+ Enabled: 'pending'
3861
+ VersionAdded: '0.87'
3862
+
3863
+ Style/RedundantBegin:
3864
+ Description: "Don't use begin blocks when they are not needed."
3865
+ StyleGuide: '#begin-implicit'
3866
+ Enabled: true
3867
+ VersionAdded: '0.10'
3868
+ VersionChanged: '0.21'
3869
+
3870
+ Style/RedundantCapitalW:
3871
+ Description: 'Checks for %W when interpolation is not needed.'
3872
+ Enabled: true
3873
+ VersionAdded: '0.76'
3874
+
3875
+ Style/RedundantCondition:
3876
+ Description: 'Checks for unnecessary conditional expressions.'
3877
+ Enabled: true
3878
+ VersionAdded: '0.76'
3879
+
3880
+ Style/RedundantConditional:
3881
+ Description: "Don't return true/false from a conditional."
3882
+ Enabled: true
3883
+ VersionAdded: '0.50'
3884
+
3885
+ Style/RedundantException:
3886
+ Description: "Checks for an obsolete RuntimeException argument in raise/fail."
3887
+ StyleGuide: '#no-explicit-runtimeerror'
3888
+ Enabled: true
3889
+ VersionAdded: '0.14'
3890
+ VersionChanged: '0.29'
3891
+
3892
+ Style/RedundantFetchBlock:
3893
+ Description: >-
3894
+ Use `fetch(key, value)` instead of `fetch(key) { value }`
3895
+ when value has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or is a constant.
3896
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code'
3897
+ Enabled: 'pending'
3898
+ Safe: false
3899
+ # If enabled, this cop will autocorrect usages of
3900
+ # `fetch` being called with block returning a constant.
3901
+ # This can be dangerous since constants will not be defined at that moment.
3902
+ SafeForConstants: false
3903
+ VersionAdded: '0.86'
3904
+
3905
+ Style/RedundantFileExtensionInRequire:
3906
+ Description: >-
3907
+ Checks for the presence of superfluous `.rb` extension in
3908
+ the filename provided to `require` and `require_relative`.
3909
+ StyleGuide: '#no-explicit-rb-to-require'
3910
+ Enabled: 'pending'
3911
+ VersionAdded: '0.88'
3912
+
3913
+ Style/RedundantFreeze:
3914
+ Description: "Checks usages of Object#freeze on immutable objects."
3915
+ Enabled: true
3916
+ VersionAdded: '0.34'
3917
+ VersionChanged: '0.66'
3918
+
3919
+ Style/RedundantInterpolation:
3920
+ Description: 'Checks for strings that are just an interpolated expression.'
3921
+ Enabled: true
3922
+ VersionAdded: '0.76'
3923
+
3924
+ Style/RedundantParentheses:
3925
+ Description: "Checks for parentheses that seem not to serve any purpose."
3926
+ Enabled: true
3927
+ VersionAdded: '0.36'
3928
+
3929
+ Style/RedundantPercentQ:
3930
+ Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
3931
+ StyleGuide: '#percent-q'
3932
+ Enabled: true
3933
+ VersionAdded: '0.76'
3934
+
3935
+ Style/RedundantRegexpCharacterClass:
3936
+ Description: 'Checks for unnecessary single-element Regexp character classes.'
3937
+ Enabled: pending
3938
+ VersionAdded: '0.85'
3939
+
3940
+ Style/RedundantRegexpEscape:
3941
+ Description: 'Checks for redundant escapes in Regexps.'
3942
+ Enabled: pending
3943
+ VersionAdded: '0.85'
3944
+
1177
3945
  Style/RedundantReturn:
3946
+ Description: "Don't use return where it's not required."
3947
+ StyleGuide: '#no-explicit-return'
3948
+ Enabled: true
3949
+ VersionAdded: '0.10'
3950
+ VersionChanged: '0.14'
1178
3951
  # When `true` allows code like `return x, y`.
1179
3952
  AllowMultipleReturnValues: false
1180
3953
 
1181
- # Use `/` or `%r` around regular expressions.
3954
+ Style/RedundantSelf:
3955
+ Description: "Don't use self where it's not needed."
3956
+ StyleGuide: '#no-self-unless-required'
3957
+ Enabled: true
3958
+ VersionAdded: '0.10'
3959
+ VersionChanged: '0.13'
3960
+
3961
+ Style/RedundantSelfAssignment:
3962
+ Description: 'Checks for places where redundant assignments are made for in place modification methods.'
3963
+ Enabled: pending
3964
+ Safe: false
3965
+ VersionAdded: '0.90'
3966
+
3967
+ Style/RedundantSort:
3968
+ Description: >-
3969
+ Use `min` instead of `sort.first`,
3970
+ `max_by` instead of `sort_by...last`, etc.
3971
+ Enabled: true
3972
+ VersionAdded: '0.76'
3973
+
3974
+ Style/RedundantSortBy:
3975
+ Description: 'Use `sort` instead of `sort_by { |x| x }`.'
3976
+ Enabled: true
3977
+ VersionAdded: '0.36'
3978
+
1182
3979
  Style/RegexpLiteral:
3980
+ Description: 'Use / or %r around regular expressions.'
3981
+ StyleGuide: '#percent-r'
3982
+ Enabled: true
3983
+ VersionAdded: '0.9'
3984
+ VersionChanged: '0.30'
1183
3985
  EnforcedStyle: slashes
1184
3986
  # slashes: Always use slashes.
1185
3987
  # percent_r: Always use `%r`.
@@ -1192,7 +3994,17 @@ Style/RegexpLiteral:
1192
3994
  # are found in the regexp string.
1193
3995
  AllowInnerSlashes: false
1194
3996
 
3997
+ Style/RescueModifier:
3998
+ Description: 'Avoid using rescue in its modifier form.'
3999
+ StyleGuide: '#no-rescue-modifiers'
4000
+ Enabled: true
4001
+ VersionAdded: '0.9'
4002
+ VersionChanged: '0.34'
4003
+
1195
4004
  Style/RescueStandardError:
4005
+ Description: 'Avoid rescuing without specifying an error class.'
4006
+ Enabled: true
4007
+ VersionAdded: '0.52'
1196
4008
  EnforcedStyle: explicit
1197
4009
  # implicit: Do not include the error class, `rescue`
1198
4010
  # explicit: Require an error class `rescue StandardError`
@@ -1201,28 +4013,90 @@ Style/RescueStandardError:
1201
4013
  - explicit
1202
4014
 
1203
4015
  Style/ReturnNil:
4016
+ Description: 'Use return instead of return nil.'
4017
+ Enabled: false
1204
4018
  EnforcedStyle: return
1205
4019
  SupportedStyles:
1206
4020
  - return
1207
4021
  - return_nil
4022
+ VersionAdded: '0.50'
1208
4023
 
1209
4024
  Style/SafeNavigation:
4025
+ Description: >-
4026
+ This cop transforms usages of a method call safeguarded by
4027
+ a check for the existence of the object to
4028
+ safe navigation (`&.`).
4029
+ Auto-correction is unsafe as it assumes the object will
4030
+ be `nil` or truthy, but never `false`.
4031
+ Enabled: true
4032
+ VersionAdded: '0.43'
4033
+ VersionChanged: '0.77'
1210
4034
  # Safe navigation may cause a statement to start returning `nil` in addition
1211
4035
  # to whatever it used to return.
1212
4036
  ConvertCodeThatCanStartToReturnNil: false
4037
+ AllowedMethods:
4038
+ - present?
4039
+ - blank?
4040
+ - presence
4041
+ - try
4042
+ - try!
4043
+ SafeAutoCorrect: false
4044
+
4045
+ Style/Sample:
4046
+ Description: >-
4047
+ Use `sample` instead of `shuffle.first`,
4048
+ `shuffle.last`, and `shuffle[Integer]`.
4049
+ Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
4050
+ Enabled: true
4051
+ VersionAdded: '0.30'
4052
+
4053
+ Style/SelfAssignment:
4054
+ Description: >-
4055
+ Checks for places where self-assignment shorthand should have
4056
+ been used.
4057
+ StyleGuide: '#self-assignment'
4058
+ Enabled: true
4059
+ VersionAdded: '0.19'
4060
+ VersionChanged: '0.29'
1213
4061
 
1214
4062
  Style/Semicolon:
4063
+ Description: "Don't use semicolons to terminate expressions."
4064
+ StyleGuide: '#no-semicolon'
4065
+ Enabled: true
4066
+ VersionAdded: '0.9'
4067
+ VersionChanged: '0.19'
1215
4068
  # Allow `;` to separate several expressions on the same line.
1216
4069
  AllowAsExpressionSeparator: false
1217
4070
 
4071
+ Style/Send:
4072
+ Description: 'Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.'
4073
+ StyleGuide: '#prefer-public-send'
4074
+ Enabled: false
4075
+ VersionAdded: '0.33'
4076
+
1218
4077
  Style/SignalException:
4078
+ Description: 'Checks for proper usage of fail and raise.'
4079
+ StyleGuide: '#prefer-raise-over-fail'
4080
+ Enabled: true
4081
+ VersionAdded: '0.11'
4082
+ VersionChanged: '0.37'
1219
4083
  EnforcedStyle: only_raise
1220
4084
  SupportedStyles:
1221
4085
  - only_raise
1222
4086
  - only_fail
1223
4087
  - semantic
1224
4088
 
4089
+ Style/SingleArgumentDig:
4090
+ Description: 'Avoid using single argument dig method.'
4091
+ Enabled: pending
4092
+ VersionAdded: '0.89'
4093
+ Safe: false
4094
+
1225
4095
  Style/SingleLineBlockParams:
4096
+ Description: 'Enforces the names of some block params.'
4097
+ Enabled: false
4098
+ VersionAdded: '0.16'
4099
+ VersionChanged: '0.47'
1226
4100
  Methods:
1227
4101
  - reduce:
1228
4102
  - acc
@@ -1232,21 +4106,76 @@ Style/SingleLineBlockParams:
1232
4106
  - elem
1233
4107
 
1234
4108
  Style/SingleLineMethods:
4109
+ Description: 'Avoid single-line methods.'
4110
+ StyleGuide: '#no-single-line-methods'
4111
+ Enabled: true
4112
+ VersionAdded: '0.9'
4113
+ VersionChanged: '0.19'
1235
4114
  AllowIfMethodIsEmpty: true
1236
4115
 
4116
+ Style/SlicingWithRange:
4117
+ Description: 'Checks array slicing is done with endless ranges when suitable.'
4118
+ Enabled: pending
4119
+ VersionAdded: '0.83'
4120
+ Safe: false
4121
+
4122
+ Style/SoleNestedConditional:
4123
+ Description: >-
4124
+ Finds sole nested conditional nodes
4125
+ which can be merged into outer conditional node.
4126
+ Enabled: pending
4127
+ VersionAdded: '0.89'
4128
+ AllowModifier: false
4129
+
1237
4130
  Style/SpecialGlobalVars:
4131
+ Description: 'Avoid Perl-style global variables.'
4132
+ StyleGuide: '#no-cryptic-perlisms'
4133
+ Enabled: true
4134
+ VersionAdded: '0.13'
4135
+ VersionChanged: '0.36'
4136
+ SafeAutoCorrect: false
1238
4137
  EnforcedStyle: use_english_names
1239
4138
  SupportedStyles:
1240
4139
  - use_perl_names
1241
4140
  - use_english_names
1242
4141
 
1243
4142
  Style/StabbyLambdaParentheses:
4143
+ Description: 'Check for the usage of parentheses around stabby lambda arguments.'
4144
+ StyleGuide: '#stabby-lambda-with-args'
4145
+ Enabled: true
4146
+ VersionAdded: '0.35'
1244
4147
  EnforcedStyle: require_parentheses
1245
4148
  SupportedStyles:
1246
4149
  - require_parentheses
1247
4150
  - require_no_parentheses
1248
4151
 
4152
+ Style/StderrPuts:
4153
+ Description: 'Use `warn` instead of `$stderr.puts`.'
4154
+ StyleGuide: '#warn'
4155
+ Enabled: true
4156
+ VersionAdded: '0.51'
4157
+
4158
+ Style/StringConcatenation:
4159
+ Description: 'Checks for places where string concatenation can be replaced with string interpolation.'
4160
+ StyleGuide: '#string-interpolation'
4161
+ Enabled: pending
4162
+ Safe: false
4163
+ VersionAdded: '0.89'
4164
+
4165
+ Style/StringHashKeys:
4166
+ Description: 'Prefer symbols instead of strings as hash keys.'
4167
+ StyleGuide: '#symbols-as-keys'
4168
+ Enabled: false
4169
+ VersionAdded: '0.52'
4170
+ VersionChanged: '0.75'
4171
+ Safe: false
4172
+
1249
4173
  Style/StringLiterals:
4174
+ Description: 'Checks if uses of quotes match the configured preference.'
4175
+ StyleGuide: '#consistent-string-literals'
4176
+ Enabled: true
4177
+ VersionAdded: '0.9'
4178
+ VersionChanged: '0.36'
1250
4179
  EnforcedStyle: single_quotes
1251
4180
  SupportedStyles:
1252
4181
  - single_quotes
@@ -1256,12 +4185,21 @@ Style/StringLiterals:
1256
4185
  ConsistentQuotesInMultiline: false
1257
4186
 
1258
4187
  Style/StringLiteralsInInterpolation:
4188
+ Description: >-
4189
+ Checks if uses of quotes inside expressions in interpolated
4190
+ strings match the configured preference.
4191
+ Enabled: true
4192
+ VersionAdded: '0.27'
1259
4193
  EnforcedStyle: single_quotes
1260
4194
  SupportedStyles:
1261
4195
  - single_quotes
1262
4196
  - double_quotes
1263
4197
 
1264
4198
  Style/StringMethods:
4199
+ Description: 'Checks if configured preferred methods are used over non-preferred.'
4200
+ Enabled: false
4201
+ VersionAdded: '0.34'
4202
+ VersionChanged: '0.34.2'
1265
4203
  # Mapping from undesired method to desired_method
1266
4204
  # e.g. to use `to_sym` over `intern`:
1267
4205
  #
@@ -1271,14 +4209,41 @@ Style/StringMethods:
1271
4209
  PreferredMethods:
1272
4210
  intern: to_sym
1273
4211
 
4212
+ Style/Strip:
4213
+ Description: 'Use `strip` instead of `lstrip.rstrip`.'
4214
+ Enabled: true
4215
+ VersionAdded: '0.36'
4216
+
4217
+ Style/StructInheritance:
4218
+ Description: 'Checks for inheritance from Struct.new.'
4219
+ StyleGuide: '#no-extend-struct-new'
4220
+ Enabled: true
4221
+ VersionAdded: '0.29'
4222
+ VersionChanged: '0.86'
4223
+
1274
4224
  Style/SymbolArray:
4225
+ Description: 'Use %i or %I for arrays of symbols.'
4226
+ StyleGuide: '#percent-i'
4227
+ Enabled: true
4228
+ VersionAdded: '0.9'
4229
+ VersionChanged: '0.49'
1275
4230
  EnforcedStyle: percent
1276
- MinSize: 0
4231
+ MinSize: 2
1277
4232
  SupportedStyles:
1278
4233
  - percent
1279
4234
  - brackets
1280
4235
 
4236
+ Style/SymbolLiteral:
4237
+ Description: 'Use plain symbols instead of string symbols when possible.'
4238
+ Enabled: true
4239
+ VersionAdded: '0.30'
4240
+
1281
4241
  Style/SymbolProc:
4242
+ Description: 'Use symbols as procs instead of blocks when possible.'
4243
+ Enabled: true
4244
+ Safe: false
4245
+ VersionAdded: '0.26'
4246
+ VersionChanged: '0.64'
1282
4247
  # A list of method names to be ignored by the check.
1283
4248
  # The names should be fairly unique, otherwise you'll end up ignoring lots of code.
1284
4249
  IgnoredMethods:
@@ -1286,6 +4251,10 @@ Style/SymbolProc:
1286
4251
  - define_method
1287
4252
 
1288
4253
  Style/TernaryParentheses:
4254
+ Description: 'Checks for use of parentheses around ternary conditions.'
4255
+ Enabled: true
4256
+ VersionAdded: '0.42'
4257
+ VersionChanged: '0.46'
1289
4258
  EnforcedStyle: require_no_parentheses
1290
4259
  SupportedStyles:
1291
4260
  - require_parentheses
@@ -1293,7 +4262,26 @@ Style/TernaryParentheses:
1293
4262
  - require_parentheses_when_complex
1294
4263
  AllowSafeAssignment: true
1295
4264
 
4265
+ Style/TrailingBodyOnClass:
4266
+ Description: 'Class body goes below class statement.'
4267
+ Enabled: true
4268
+ VersionAdded: '0.53'
4269
+
4270
+ Style/TrailingBodyOnMethodDefinition:
4271
+ Description: 'Method body goes below definition.'
4272
+ Enabled: true
4273
+ VersionAdded: '0.52'
4274
+
4275
+ Style/TrailingBodyOnModule:
4276
+ Description: 'Module body goes below module statement.'
4277
+ Enabled: true
4278
+ VersionAdded: '0.53'
4279
+
1296
4280
  Style/TrailingCommaInArguments:
4281
+ Description: 'Checks for trailing comma in argument lists.'
4282
+ StyleGuide: '#no-trailing-params-comma'
4283
+ Enabled: true
4284
+ VersionAdded: '0.36'
1297
4285
  # If `comma`, the cop requires a comma after the last argument, but only for
1298
4286
  # parenthesized method calls where each argument is on its own line.
1299
4287
  # If `consistent_comma`, the cop requires a comma after the last argument,
@@ -1304,20 +4292,63 @@ Style/TrailingCommaInArguments:
1304
4292
  - consistent_comma
1305
4293
  - no_comma
1306
4294
 
1307
- Style/TrailingCommaInLiteral:
1308
- # If `comma`, the cop requires a comma after the last item in an array or
1309
- # hash, but only when each item is on its own line.
4295
+ Style/TrailingCommaInArrayLiteral:
4296
+ Description: 'Checks for trailing comma in array literals.'
4297
+ StyleGuide: '#no-trailing-array-commas'
4298
+ Enabled: true
4299
+ VersionAdded: '0.53'
4300
+ # If `comma`, the cop requires a comma after the last item in an array,
4301
+ # but only when each item is on its own line.
4302
+ # If `consistent_comma`, the cop requires a comma after the last item of all
4303
+ # non-empty, multiline array literals.
4304
+ EnforcedStyleForMultiline: no_comma
4305
+ SupportedStylesForMultiline:
4306
+ - comma
4307
+ - consistent_comma
4308
+ - no_comma
4309
+
4310
+ Style/TrailingCommaInBlockArgs:
4311
+ Description: 'Checks for useless trailing commas in block arguments.'
4312
+ Enabled: false
4313
+ Safe: false
4314
+ VersionAdded: '0.81'
4315
+
4316
+ Style/TrailingCommaInHashLiteral:
4317
+ Description: 'Checks for trailing comma in hash literals.'
4318
+ Enabled: true
4319
+ # If `comma`, the cop requires a comma after the last item in a hash,
4320
+ # but only when each item is on its own line.
1310
4321
  # If `consistent_comma`, the cop requires a comma after the last item of all
1311
- # non-empty array and hash literals.
4322
+ # non-empty, multiline hash literals.
1312
4323
  EnforcedStyleForMultiline: no_comma
1313
4324
  SupportedStylesForMultiline:
1314
4325
  - comma
1315
4326
  - consistent_comma
1316
4327
  - no_comma
4328
+ VersionAdded: '0.53'
4329
+
4330
+ Style/TrailingMethodEndStatement:
4331
+ Description: 'Checks for trailing end statement on line of method body.'
4332
+ Enabled: true
4333
+ VersionAdded: '0.52'
4334
+
4335
+ Style/TrailingUnderscoreVariable:
4336
+ Description: >-
4337
+ Checks for the usage of unneeded trailing underscores at the
4338
+ end of parallel variable assignment.
4339
+ AllowNamedUnderscoreVariables: true
4340
+ Enabled: true
4341
+ VersionAdded: '0.31'
4342
+ VersionChanged: '0.35'
1317
4343
 
1318
4344
  # `TrivialAccessors` requires exact name matches and doesn't allow
1319
4345
  # predicated methods by default.
1320
4346
  Style/TrivialAccessors:
4347
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
4348
+ StyleGuide: '#attr_family'
4349
+ Enabled: true
4350
+ VersionAdded: '0.9'
4351
+ VersionChanged: '0.77'
1321
4352
  # When set to `false` the cop will suggest the use of accessor methods
1322
4353
  # in situations like:
1323
4354
  #
@@ -1338,7 +4369,7 @@ Style/TrivialAccessors:
1338
4369
  # Commonly used in DSLs
1339
4370
  AllowDSLWriters: false
1340
4371
  IgnoreClassMethods: false
1341
- Whitelist:
4372
+ AllowedMethods:
1342
4373
  - to_ary
1343
4374
  - to_a
1344
4375
  - to_c
@@ -1357,8 +4388,57 @@ Style/TrivialAccessors:
1357
4388
  - to_s
1358
4389
  - to_sym
1359
4390
 
1360
- # `WordArray` enforces how array literals of word-like strings should be expressed.
4391
+ Style/UnlessElse:
4392
+ Description: >-
4393
+ Do not use unless with else. Rewrite these with the positive
4394
+ case first.
4395
+ StyleGuide: '#no-else-with-unless'
4396
+ Enabled: true
4397
+ VersionAdded: '0.9'
4398
+
4399
+ Style/UnpackFirst:
4400
+ Description: >-
4401
+ Checks for accessing the first element of `String#unpack`
4402
+ instead of using `unpack1`.
4403
+ Enabled: true
4404
+ VersionAdded: '0.54'
4405
+
4406
+ Style/VariableInterpolation:
4407
+ Description: >-
4408
+ Don't interpolate global, instance and class variables
4409
+ directly in strings.
4410
+ StyleGuide: '#curlies-interpolate'
4411
+ Enabled: true
4412
+ VersionAdded: '0.9'
4413
+ VersionChanged: '0.20'
4414
+
4415
+ Style/WhenThen:
4416
+ Description: 'Use when x then ... for one-line cases.'
4417
+ StyleGuide: '#one-line-cases'
4418
+ Enabled: true
4419
+ VersionAdded: '0.9'
4420
+
4421
+ Style/WhileUntilDo:
4422
+ Description: 'Checks for redundant do after while or until.'
4423
+ StyleGuide: '#no-multiline-while-do'
4424
+ Enabled: true
4425
+ VersionAdded: '0.9'
4426
+
4427
+ Style/WhileUntilModifier:
4428
+ Description: >-
4429
+ Favor modifier while/until usage when you have a
4430
+ single-line body.
4431
+ StyleGuide: '#while-as-a-modifier'
4432
+ Enabled: true
4433
+ VersionAdded: '0.9'
4434
+ VersionChanged: '0.30'
4435
+
1361
4436
  Style/WordArray:
4437
+ Description: 'Use %w or %W for arrays of words.'
4438
+ StyleGuide: '#percent-w'
4439
+ Enabled: true
4440
+ VersionAdded: '0.9'
4441
+ VersionChanged: '0.36'
1362
4442
  EnforcedStyle: percent
1363
4443
  SupportedStyles:
1364
4444
  # percent style: %w(word1 word2)
@@ -1366,319 +4446,33 @@ Style/WordArray:
1366
4446
  # bracket style: ['word1', 'word2']
1367
4447
  - brackets
1368
4448
  # The `MinSize` option causes the `WordArray` rule to be ignored for arrays
1369
- # smaller than a certain size. The rule is only applied to arrays
4449
+ # smaller than a certain size. The rule is only applied to arrays
1370
4450
  # whose element count is greater than or equal to `MinSize`.
1371
- MinSize: 0
4451
+ MinSize: 2
1372
4452
  # The regular expression `WordRegex` decides what is considered a word.
1373
- WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
4453
+ WordRegex: !ruby/regexp '/\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/'
1374
4454
 
1375
4455
  Style/YodaCondition:
1376
- EnforcedStyle: all_comparison_operators
4456
+ Description: 'Forbid or enforce yoda conditions.'
4457
+ Reference: 'https://en.wikipedia.org/wiki/Yoda_conditions'
4458
+ Enabled: true
4459
+ EnforcedStyle: forbid_for_all_comparison_operators
1377
4460
  SupportedStyles:
1378
4461
  # check all comparison operators
1379
- - all_comparison_operators
4462
+ - forbid_for_all_comparison_operators
1380
4463
  # check only equality operators: `!=` and `==`
1381
- - equality_operators_only
1382
-
1383
- #################### Metrics ###############################
1384
-
1385
- Metrics/AbcSize:
1386
- # The ABC size is a calculated magnitude, so this number can be an Integer or
1387
- # a Float.
1388
- Max: 15
1389
-
1390
- Metrics/BlockLength:
1391
- CountComments: false # count full line comments?
1392
- Max: 25
1393
- ExcludedMethods: []
1394
-
1395
- Metrics/BlockNesting:
1396
- CountBlocks: false
1397
- Max: 3
1398
-
1399
- Metrics/ClassLength:
1400
- CountComments: false # count full line comments?
1401
- Max: 100
1402
-
1403
- # Avoid complex methods.
1404
- Metrics/CyclomaticComplexity:
1405
- Max: 6
1406
-
1407
- Metrics/LineLength:
1408
- Max: 80
1409
- # To make it possible to copy or click on URIs in the code, we allow lines
1410
- # containing a URI to be longer than Max.
1411
- AllowHeredoc: true
1412
- AllowURI: true
1413
- URISchemes:
1414
- - http
1415
- - https
1416
- # The IgnoreCopDirectives option causes the LineLength rule to ignore cop
1417
- # directives like '# rubocop: enable ...' when calculating a line's length.
1418
- IgnoreCopDirectives: false
1419
- # The IgnoredPatterns option is a list of !ruby/regexp and/or string
1420
- # elements. Strings will be converted to Regexp objects. A line that matches
1421
- # any regular expression listed in this option will be ignored by LineLength.
1422
- IgnoredPatterns: []
1423
-
1424
- Metrics/MethodLength:
1425
- CountComments: false # count full line comments?
1426
- Max: 10
1427
-
1428
- Metrics/ModuleLength:
1429
- CountComments: false # count full line comments?
1430
- Max: 100
1431
-
1432
- Metrics/ParameterLists:
1433
- Max: 5
1434
- CountKeywordArgs: true
1435
-
1436
- Metrics/PerceivedComplexity:
1437
- Max: 7
1438
-
1439
- #################### Lint ##################################
1440
-
1441
- # Allow safe assignment in conditions.
1442
- Lint/AssignmentInCondition:
1443
- AllowSafeAssignment: true
1444
-
1445
- # checks whether the end keywords are aligned properly for `do` `end` blocks.
1446
- Lint/BlockAlignment:
1447
- # The value `start_of_block` means that the `end` should be aligned with line
1448
- # where the `do` keyword appears.
1449
- # The value `start_of_line` means it should be aligned with the whole
1450
- # expression's starting line.
1451
- # The value `either` means both are allowed.
1452
- EnforcedStyleAlignWith: either
1453
- SupportedStylesAlignWith:
1454
- - either
1455
- - start_of_block
1456
- - start_of_line
1457
-
1458
- Lint/DefEndAlignment:
1459
- # The value `def` means that `end` should be aligned with the def keyword.
1460
- # The value `start_of_line` means that `end` should be aligned with method
1461
- # calls like `private`, `public`, etc, if present in front of the `def`
1462
- # keyword on the same line.
1463
- EnforcedStyleAlignWith: start_of_line
1464
- SupportedStylesAlignWith:
1465
- - start_of_line
1466
- - def
1467
- AutoCorrect: false
1468
-
1469
- # Align ends correctly.
1470
- Lint/EndAlignment:
1471
- # The value `keyword` means that `end` should be aligned with the matching
1472
- # keyword (`if`, `while`, etc.).
1473
- # The value `variable` means that in assignments, `end` should be aligned
1474
- # with the start of the variable on the left hand side of `=`. In all other
1475
- # situations, `end` should still be aligned with the keyword.
1476
- # The value `start_of_line` means that `end` should be aligned with the start
1477
- # of the line which the matching keyword appears on.
1478
- EnforcedStyleAlignWith: keyword
1479
- SupportedStylesAlignWith:
1480
- - keyword
1481
- - variable
1482
- - start_of_line
1483
- AutoCorrect: false
1484
-
1485
- Lint/InheritException:
1486
- # The default base class in favour of `Exception`.
1487
- EnforcedStyle: runtime_error
1488
- SupportedStyles:
1489
- - runtime_error
1490
- - standard_error
1491
-
1492
- Lint/MissingCopEnableDirective:
1493
- # Maximum number of consecutive lines the cop can be disabled for.
1494
- # 0 allows only single-line disables
1495
- # 1 would mean the maximum allowed is the following:
1496
- # # rubocop:disable SomeCop
1497
- # a = 1
1498
- # # rubocop:enable SomeCop
1499
- # .inf for any size
1500
- MaximumRangeSize: .inf
1501
-
1502
- Lint/SafeNavigationChain:
1503
- Whitelist:
1504
- - present?
1505
- - blank?
1506
- - presence
1507
- - try
1508
-
1509
- # Checks for shadowed arguments
1510
- Lint/ShadowedArgument:
1511
- IgnoreImplicitReferences: false
1512
-
1513
- # Checks for unused block arguments
1514
- Lint/UnusedBlockArgument:
1515
- IgnoreEmptyBlocks: true
1516
- AllowUnusedKeywordArguments: false
1517
-
1518
- # Checks for unused method arguments.
1519
- Lint/UnusedMethodArgument:
1520
- AllowUnusedKeywordArguments: false
1521
- IgnoreEmptyMethods: true
1522
-
1523
- #################### Performance ###########################
1524
-
1525
- Performance/DoubleStartEndWith:
1526
- # Used to check for `starts_with?` and `ends_with?`.
1527
- # These methods are defined by `ActiveSupport`.
1528
- IncludeActiveSupportAliases: false
1529
-
1530
- Performance/RedundantMerge:
1531
- # Max number of key-value pairs to consider an offense
1532
- MaxKeyValuePairs: 2
1533
-
1534
- #################### Rails #################################
1535
-
1536
- Rails/ActionFilter:
1537
- EnforcedStyle: action
1538
- SupportedStyles:
1539
- - action
1540
- - filter
1541
- Include:
1542
- - app/controllers/**/*.rb
1543
-
1544
- Rails/CreateTableWithTimestamps:
1545
- Include:
1546
- - db/migrate/*.rb
1547
-
1548
- Rails/Date:
1549
- # The value `strict` disallows usage of `Date.today`, `Date.current`,
1550
- # `Date#to_time` etc.
1551
- # The value `flexible` allows usage of `Date.current`, `Date.yesterday`, etc
1552
- # (but not `Date.today`) which are overridden by ActiveSupport to handle current
1553
- # time zone.
1554
- EnforcedStyle: flexible
1555
- SupportedStyles:
1556
- - strict
1557
- - flexible
1558
-
1559
- Rails/Delegate:
1560
- # When set to true, using the target object as a prefix of the
1561
- # method name without using the `delegate` method will be a
1562
- # violation. When set to false, this case is legal.
1563
- EnforceForPrefixed: true
1564
-
1565
- Rails/DynamicFindBy:
1566
- Whitelist:
1567
- - find_by_sql
1568
-
1569
- Rails/EnumUniqueness:
1570
- Include:
1571
- - app/models/**/*.rb
1572
-
1573
- Rails/Exit:
1574
- Include:
1575
- - app/**/*.rb
1576
- - config/**/*.rb
1577
- - lib/**/*.rb
1578
- Exclude:
1579
- - lib/**/*.rake
1580
-
1581
- Rails/FindBy:
1582
- Include:
1583
- - app/models/**/*.rb
1584
-
1585
- Rails/FindEach:
1586
- Include:
1587
- - app/models/**/*.rb
1588
-
1589
- Rails/HasAndBelongsToMany:
1590
- Include:
1591
- - app/models/**/*.rb
1592
-
1593
- Rails/HasManyOrHasOneDependent:
1594
- Include:
1595
- - app/models/**/*.rb
1596
-
1597
- Rails/InverseOf:
1598
- Include:
1599
- - app/models/**/*.rb
1600
-
1601
- Rails/LexicallyScopedActionFilter:
1602
- Include:
1603
- - app/controllers/**/*.rb
1604
-
1605
- Rails/NotNullColumn:
1606
- Include:
1607
- - db/migrate/*.rb
1608
-
1609
- Rails/Output:
1610
- Include:
1611
- - app/**/*.rb
1612
- - config/**/*.rb
1613
- - db/**/*.rb
1614
- - lib/**/*.rb
1615
-
1616
- Rails/ReadWriteAttribute:
1617
- Include:
1618
- - app/models/**/*.rb
1619
-
1620
- Rails/RequestReferer:
1621
- EnforcedStyle: referer
1622
- SupportedStyles:
1623
- - referer
1624
- - referrer
1625
-
1626
- Rails/ReversibleMigration:
1627
- Include:
1628
- - db/migrate/*.rb
1629
-
1630
- Rails/SafeNavigation:
1631
- # This will convert usages of `try` to use safe navigation as well as `try!`.
1632
- # `try` and `try!` work slightly differently. `try!` and safe navigation will
1633
- # both raise a `NoMethodError` if the receiver of the method call does not
1634
- # implement the intended method. `try` will not raise an exception for this.
1635
- ConvertTry: false
1636
-
1637
- Rails/ScopeArgs:
1638
- Include:
1639
- - app/models/**/*.rb
1640
-
1641
- Rails/TimeZone:
1642
- # The value `strict` means that `Time` should be used with `zone`.
1643
- # The value `flexible` allows usage of `in_time_zone` instead of `zone`.
1644
- EnforcedStyle: flexible
1645
- SupportedStyles:
1646
- - strict
1647
- - flexible
1648
-
1649
- Rails/UniqBeforePluck:
1650
- EnforcedStyle: conservative
1651
- SupportedStyles:
1652
- - conservative
1653
- - aggressive
1654
- AutoCorrect: false
1655
-
1656
- Rails/UnknownEnv:
1657
- Environments:
1658
- - development
1659
- - test
1660
- - production
1661
-
1662
- Rails/SkipsModelValidations:
1663
- Blacklist:
1664
- - decrement!
1665
- - decrement_counter
1666
- - increment!
1667
- - increment_counter
1668
- - toggle!
1669
- - touch
1670
- - update_all
1671
- - update_attribute
1672
- - update_column
1673
- - update_columns
1674
- - update_counters
1675
-
1676
- Rails/Validation:
1677
- Include:
1678
- - app/models/**/*.rb
1679
-
1680
- Bundler/OrderedGems:
1681
- TreatCommentsAsGroupSeparators: true
1682
-
1683
- Gemspec/OrderedDependencies:
1684
- TreatCommentsAsGroupSeparators: true
4464
+ - forbid_for_equality_operators_only
4465
+ # enforce yoda for all comparison operators
4466
+ - require_for_all_comparison_operators
4467
+ # enforce yoda only for equality operators: `!=` and `==`
4468
+ - require_for_equality_operators_only
4469
+ Safe: false
4470
+ VersionAdded: '0.49'
4471
+ VersionChanged: '0.75'
4472
+
4473
+ Style/ZeroLengthPredicate:
4474
+ Description: 'Use #empty? when testing for objects of length 0.'
4475
+ Enabled: true
4476
+ Safe: false
4477
+ VersionAdded: '0.37'
4478
+ VersionChanged: '0.39'