rubocop 0.68.1 → 0.69.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (472) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/config/default.yml +25 -9
  4. data/lib/rubocop.rb +1 -0
  5. data/lib/rubocop/ast/node.rb +6 -2
  6. data/lib/rubocop/ast/node/array_node.rb +2 -2
  7. data/lib/rubocop/ast/node/block_node.rb +2 -2
  8. data/lib/rubocop/ast/node/for_node.rb +1 -1
  9. data/lib/rubocop/ast/node/hash_node.rb +1 -1
  10. data/lib/rubocop/ast/node/if_node.rb +1 -1
  11. data/lib/rubocop/ast/node/keyword_splat_node.rb +1 -1
  12. data/lib/rubocop/ast/node/mixin/method_dispatch_node.rb +3 -3
  13. data/lib/rubocop/ast/node/mixin/method_identifier_predicates.rb +2 -2
  14. data/lib/rubocop/ast/node/mixin/parameterized_node.rb +1 -1
  15. data/lib/rubocop/ast/node/mixin/predicate_operator_node.rb +4 -4
  16. data/lib/rubocop/ast/node/pair_node.rb +4 -4
  17. data/lib/rubocop/ast/node/until_node.rb +1 -1
  18. data/lib/rubocop/ast/node/when_node.rb +1 -1
  19. data/lib/rubocop/ast/node/while_node.rb +1 -1
  20. data/lib/rubocop/cli.rb +6 -6
  21. data/lib/rubocop/comment_config.rb +6 -6
  22. data/lib/rubocop/config.rb +8 -6
  23. data/lib/rubocop/config_loader.rb +3 -3
  24. data/lib/rubocop/cop/badge.rb +1 -1
  25. data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
  26. data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
  27. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +1 -1
  28. data/lib/rubocop/cop/bundler/ordered_gems.rb +1 -1
  29. data/lib/rubocop/cop/correctors/alignment_corrector.rb +2 -2
  30. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +2 -2
  31. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +1 -1
  32. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +5 -5
  33. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +1 -1
  34. data/lib/rubocop/cop/correctors/parentheses_corrector.rb +1 -1
  35. data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +1 -1
  36. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +0 -1
  37. data/lib/rubocop/cop/gemspec/required_ruby_version.rb +7 -7
  38. data/lib/rubocop/cop/generator.rb +6 -6
  39. data/lib/rubocop/cop/generator/configuration_injector.rb +5 -5
  40. data/lib/rubocop/cop/internal_affairs/node_destructuring.rb +1 -1
  41. data/lib/rubocop/cop/internal_affairs/node_type_predicate.rb +1 -1
  42. data/lib/rubocop/cop/internal_affairs/offense_location_keyword.rb +1 -1
  43. data/lib/rubocop/cop/internal_affairs/redundant_location_argument.rb +1 -1
  44. data/lib/rubocop/cop/internal_affairs/redundant_message_argument.rb +1 -1
  45. data/lib/rubocop/cop/internal_affairs/useless_message_assertion.rb +1 -1
  46. data/lib/rubocop/cop/layout/access_modifier_indentation.rb +2 -2
  47. data/lib/rubocop/cop/layout/align_arguments.rb +2 -2
  48. data/lib/rubocop/cop/layout/align_array.rb +1 -1
  49. data/lib/rubocop/cop/layout/align_hash.rb +3 -3
  50. data/lib/rubocop/cop/layout/align_parameters.rb +2 -2
  51. data/lib/rubocop/cop/layout/block_alignment.rb +4 -4
  52. data/lib/rubocop/cop/layout/block_end_newline.rb +0 -1
  53. data/lib/rubocop/cop/layout/case_indentation.rb +1 -1
  54. data/lib/rubocop/cop/layout/class_structure.rb +2 -2
  55. data/lib/rubocop/cop/layout/closing_heredoc_indentation.rb +4 -4
  56. data/lib/rubocop/cop/layout/closing_parenthesis_indentation.rb +3 -3
  57. data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
  58. data/lib/rubocop/cop/layout/condition_position.rb +1 -1
  59. data/lib/rubocop/cop/layout/def_end_alignment.rb +1 -1
  60. data/lib/rubocop/cop/layout/else_alignment.rb +2 -2
  61. data/lib/rubocop/cop/layout/empty_comment.rb +1 -1
  62. data/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb +5 -5
  63. data/lib/rubocop/cop/layout/empty_line_after_magic_comment.rb +1 -1
  64. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -2
  65. data/lib/rubocop/cop/layout/empty_lines.rb +1 -1
  66. data/lib/rubocop/cop/layout/empty_lines_around_access_modifier.rb +2 -2
  67. data/lib/rubocop/cop/layout/empty_lines_around_arguments.rb +1 -1
  68. data/lib/rubocop/cop/layout/empty_lines_around_begin_body.rb +1 -1
  69. data/lib/rubocop/cop/layout/empty_lines_around_block_body.rb +1 -1
  70. data/lib/rubocop/cop/layout/empty_lines_around_class_body.rb +1 -1
  71. data/lib/rubocop/cop/layout/empty_lines_around_exception_handling_keywords.rb +1 -1
  72. data/lib/rubocop/cop/layout/empty_lines_around_method_body.rb +1 -1
  73. data/lib/rubocop/cop/layout/empty_lines_around_module_body.rb +1 -1
  74. data/lib/rubocop/cop/layout/end_of_line.rb +2 -2
  75. data/lib/rubocop/cop/layout/extra_spacing.rb +5 -5
  76. data/lib/rubocop/cop/layout/first_array_element_line_break.rb +1 -1
  77. data/lib/rubocop/cop/layout/first_hash_element_line_break.rb +1 -1
  78. data/lib/rubocop/cop/layout/first_method_argument_line_break.rb +1 -1
  79. data/lib/rubocop/cop/layout/first_method_parameter_line_break.rb +1 -1
  80. data/lib/rubocop/cop/layout/heredoc_argument_closing_parenthesis.rb +3 -10
  81. data/lib/rubocop/cop/layout/indent_assignment.rb +1 -1
  82. data/lib/rubocop/cop/layout/indent_first_argument.rb +1 -1
  83. data/lib/rubocop/cop/layout/indent_first_array_element.rb +1 -1
  84. data/lib/rubocop/cop/layout/indent_first_hash_element.rb +1 -1
  85. data/lib/rubocop/cop/layout/indent_first_parameter.rb +2 -2
  86. data/lib/rubocop/cop/layout/indent_heredoc.rb +9 -47
  87. data/lib/rubocop/cop/layout/indentation_consistency.rb +1 -1
  88. data/lib/rubocop/cop/layout/indentation_width.rb +2 -2
  89. data/lib/rubocop/cop/layout/initial_indentation.rb +1 -1
  90. data/lib/rubocop/cop/layout/leading_blank_lines.rb +1 -1
  91. data/lib/rubocop/cop/layout/leading_comment_space.rb +1 -1
  92. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +4 -4
  93. data/lib/rubocop/cop/layout/multiline_array_line_breaks.rb +1 -1
  94. data/lib/rubocop/cop/layout/multiline_assignment_layout.rb +2 -2
  95. data/lib/rubocop/cop/layout/multiline_block_layout.rb +2 -2
  96. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +4 -4
  97. data/lib/rubocop/cop/layout/multiline_hash_key_line_breaks.rb +1 -1
  98. data/lib/rubocop/cop/layout/multiline_method_argument_line_breaks.rb +1 -1
  99. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +4 -4
  100. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +2 -2
  101. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +4 -4
  102. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +2 -2
  103. data/lib/rubocop/cop/layout/space_after_colon.rb +1 -1
  104. data/lib/rubocop/cop/layout/space_after_method_name.rb +2 -2
  105. data/lib/rubocop/cop/layout/space_after_not.rb +1 -1
  106. data/lib/rubocop/cop/layout/space_around_equals_in_parameter_default.rb +1 -1
  107. data/lib/rubocop/cop/layout/space_around_keyword.rb +9 -9
  108. data/lib/rubocop/cop/layout/space_around_operators.rb +1 -1
  109. data/lib/rubocop/cop/layout/space_before_block_braces.rb +2 -2
  110. data/lib/rubocop/cop/layout/space_before_comment.rb +1 -1
  111. data/lib/rubocop/cop/layout/space_before_first_arg.rb +1 -1
  112. data/lib/rubocop/cop/layout/space_in_lambda_literal.rb +4 -3
  113. data/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb +2 -2
  114. data/lib/rubocop/cop/layout/space_inside_array_percent_literal.rb +1 -1
  115. data/lib/rubocop/cop/layout/space_inside_block_braces.rb +1 -1
  116. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +1 -1
  117. data/lib/rubocop/cop/layout/space_inside_parens.rb +2 -2
  118. data/lib/rubocop/cop/layout/space_inside_percent_literal_delimiters.rb +1 -1
  119. data/lib/rubocop/cop/layout/space_inside_range_literal.rb +1 -1
  120. data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +2 -2
  121. data/lib/rubocop/cop/layout/space_inside_string_interpolation.rb +2 -2
  122. data/lib/rubocop/cop/layout/tab.rb +1 -1
  123. data/lib/rubocop/cop/layout/trailing_blank_lines.rb +1 -1
  124. data/lib/rubocop/cop/layout/trailing_whitespace.rb +1 -1
  125. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +1 -1
  126. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  127. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +1 -1
  128. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -2
  129. data/lib/rubocop/cop/lint/big_decimal_new.rb +1 -1
  130. data/lib/rubocop/cop/lint/boolean_symbol.rb +1 -1
  131. data/lib/rubocop/cop/lint/circular_argument_reference.rb +1 -1
  132. data/lib/rubocop/cop/lint/debugger.rb +1 -1
  133. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +1 -1
  134. data/lib/rubocop/cop/lint/disjunctive_assignment_in_constructor.rb +1 -1
  135. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
  136. data/lib/rubocop/cop/lint/duplicate_methods.rb +1 -1
  137. data/lib/rubocop/cop/lint/duplicated_key.rb +1 -1
  138. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
  139. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  140. data/lib/rubocop/cop/lint/empty_ensure.rb +1 -1
  141. data/lib/rubocop/cop/lint/empty_expression.rb +1 -1
  142. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  143. data/lib/rubocop/cop/lint/empty_when.rb +1 -1
  144. data/lib/rubocop/cop/lint/end_in_method.rb +1 -1
  145. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  146. data/lib/rubocop/cop/lint/flip_flop.rb +1 -1
  147. data/lib/rubocop/cop/lint/float_out_of_range.rb +1 -1
  148. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +7 -8
  149. data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -1
  150. data/lib/rubocop/cop/lint/heredoc_method_call_position.rb +5 -6
  151. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +5 -5
  152. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +4 -4
  153. data/lib/rubocop/cop/lint/inherit_exception.rb +22 -1
  154. data/lib/rubocop/cop/lint/interpolation_check.rb +1 -1
  155. data/lib/rubocop/cop/lint/literal_as_condition.rb +1 -1
  156. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  157. data/lib/rubocop/cop/lint/loop.rb +1 -1
  158. data/lib/rubocop/cop/lint/missing_cop_enable_directive.rb +2 -2
  159. data/lib/rubocop/cop/lint/multiple_compare.rb +1 -1
  160. data/lib/rubocop/cop/lint/nested_method_definition.rb +1 -1
  161. data/lib/rubocop/cop/lint/nested_percent_literal.rb +1 -1
  162. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  163. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +1 -1
  164. data/lib/rubocop/cop/lint/number_conversion.rb +16 -1
  165. data/lib/rubocop/cop/lint/ordered_magic_comments.rb +1 -1
  166. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +2 -2
  167. data/lib/rubocop/cop/lint/percent_string_array.rb +1 -1
  168. data/lib/rubocop/cop/lint/percent_symbol_array.rb +1 -1
  169. data/lib/rubocop/cop/lint/rand_one.rb +1 -1
  170. data/lib/rubocop/cop/lint/redundant_with_index.rb +2 -2
  171. data/lib/rubocop/cop/lint/redundant_with_object.rb +2 -2
  172. data/lib/rubocop/cop/lint/regexp_as_condition.rb +1 -1
  173. data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
  174. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -1
  175. data/lib/rubocop/cop/lint/rescue_type.rb +1 -1
  176. data/lib/rubocop/cop/lint/return_in_void_context.rb +2 -2
  177. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -4
  178. data/lib/rubocop/cop/lint/safe_navigation_consistency.rb +2 -2
  179. data/lib/rubocop/cop/lint/safe_navigation_with_empty.rb +1 -1
  180. data/lib/rubocop/cop/lint/script_permission.rb +2 -2
  181. data/lib/rubocop/cop/lint/shadowed_argument.rb +1 -1
  182. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -1
  183. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
  184. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +2 -2
  185. data/lib/rubocop/cop/lint/to_json.rb +1 -1
  186. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +1 -1
  187. data/lib/rubocop/cop/lint/unified_integer.rb +3 -1
  188. data/lib/rubocop/cop/lint/unneeded_cop_disable_directive.rb +1 -1
  189. data/lib/rubocop/cop/lint/unneeded_cop_enable_directive.rb +1 -1
  190. data/lib/rubocop/cop/lint/unneeded_require_statement.rb +1 -1
  191. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +7 -7
  192. data/lib/rubocop/cop/lint/unreachable_code.rb +1 -1
  193. data/lib/rubocop/cop/lint/unused_method_argument.rb +1 -1
  194. data/lib/rubocop/cop/lint/uri_escape_unescape.rb +1 -1
  195. data/lib/rubocop/cop/lint/uri_regexp.rb +1 -1
  196. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
  197. data/lib/rubocop/cop/lint/useless_assignment.rb +1 -1
  198. data/lib/rubocop/cop/lint/useless_comparison.rb +1 -1
  199. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +1 -1
  200. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  201. data/lib/rubocop/cop/lint/void.rb +6 -6
  202. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  203. data/lib/rubocop/cop/metrics/block_length.rb +2 -2
  204. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +1 -1
  205. data/lib/rubocop/cop/metrics/line_length.rb +1 -1
  206. data/lib/rubocop/cop/metrics/method_length.rb +1 -1
  207. data/lib/rubocop/cop/metrics/parameter_lists.rb +1 -1
  208. data/lib/rubocop/cop/metrics/perceived_complexity.rb +1 -1
  209. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  210. data/lib/rubocop/cop/mixin/check_assignment.rb +1 -1
  211. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +3 -3
  212. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
  213. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +3 -4
  214. data/lib/rubocop/cop/mixin/min_body_length.rb +1 -1
  215. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +4 -4
  216. data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
  217. data/lib/rubocop/cop/mixin/percent_array.rb +2 -2
  218. data/lib/rubocop/cop/mixin/range_help.rb +1 -1
  219. data/lib/rubocop/cop/mixin/rescue_node.rb +1 -2
  220. data/lib/rubocop/cop/mixin/safe_mode.rb +1 -1
  221. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  222. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
  223. data/lib/rubocop/cop/mixin/surrounding_space.rb +3 -3
  224. data/lib/rubocop/cop/mixin/too_many_lines.rb +2 -2
  225. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
  226. data/lib/rubocop/cop/mixin/uncommunicative_name.rb +4 -4
  227. data/lib/rubocop/cop/naming/accessor_method_name.rb +2 -2
  228. data/lib/rubocop/cop/naming/ascii_identifiers.rb +1 -1
  229. data/lib/rubocop/cop/naming/binary_operator_parameter_name.rb +1 -1
  230. data/lib/rubocop/cop/naming/class_and_module_camel_case.rb +1 -1
  231. data/lib/rubocop/cop/naming/constant_name.rb +4 -4
  232. data/lib/rubocop/cop/naming/file_name.rb +3 -3
  233. data/lib/rubocop/cop/naming/heredoc_delimiter_case.rb +1 -1
  234. data/lib/rubocop/cop/naming/heredoc_delimiter_naming.rb +1 -1
  235. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +2 -2
  236. data/lib/rubocop/cop/naming/method_name.rb +1 -1
  237. data/lib/rubocop/cop/naming/rescued_exceptions_variable_name.rb +1 -1
  238. data/lib/rubocop/cop/naming/variable_name.rb +1 -1
  239. data/lib/rubocop/cop/naming/variable_number.rb +1 -1
  240. data/lib/rubocop/cop/rails/action_filter.rb +1 -1
  241. data/lib/rubocop/cop/rails/active_record_aliases.rb +1 -1
  242. data/lib/rubocop/cop/rails/active_record_override.rb +1 -1
  243. data/lib/rubocop/cop/rails/active_support_aliases.rb +1 -1
  244. data/lib/rubocop/cop/rails/application_job.rb +3 -3
  245. data/lib/rubocop/cop/rails/application_record.rb +3 -3
  246. data/lib/rubocop/cop/rails/assert_not.rb +1 -1
  247. data/lib/rubocop/cop/rails/belongs_to.rb +2 -2
  248. data/lib/rubocop/cop/rails/blank.rb +3 -3
  249. data/lib/rubocop/cop/rails/bulk_change_table.rb +4 -4
  250. data/lib/rubocop/cop/rails/create_table_with_timestamps.rb +1 -1
  251. data/lib/rubocop/cop/rails/date.rb +11 -6
  252. data/lib/rubocop/cop/rails/delegate.rb +1 -1
  253. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +1 -1
  254. data/lib/rubocop/cop/rails/dynamic_find_by.rb +1 -1
  255. data/lib/rubocop/cop/rails/enum_uniqueness.rb +1 -1
  256. data/lib/rubocop/cop/rails/environment_comparison.rb +2 -2
  257. data/lib/rubocop/cop/rails/exit.rb +1 -1
  258. data/lib/rubocop/cop/rails/file_path.rb +2 -2
  259. data/lib/rubocop/cop/rails/find_by.rb +1 -1
  260. data/lib/rubocop/cop/rails/find_each.rb +2 -3
  261. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -1
  262. data/lib/rubocop/cop/rails/has_many_or_has_one_dependent.rb +1 -1
  263. data/lib/rubocop/cop/rails/http_positional_arguments.rb +1 -1
  264. data/lib/rubocop/cop/rails/http_status.rb +4 -4
  265. data/lib/rubocop/cop/rails/ignored_skip_action_filter_option.rb +1 -1
  266. data/lib/rubocop/cop/rails/inverse_of.rb +2 -2
  267. data/lib/rubocop/cop/rails/lexically_scoped_action_filter.rb +1 -1
  268. data/lib/rubocop/cop/rails/link_to_blank.rb +9 -2
  269. data/lib/rubocop/cop/rails/not_null_column.rb +1 -1
  270. data/lib/rubocop/cop/rails/output.rb +1 -1
  271. data/lib/rubocop/cop/rails/output_safety.rb +2 -2
  272. data/lib/rubocop/cop/rails/pluralization_grammar.rb +1 -1
  273. data/lib/rubocop/cop/rails/presence.rb +1 -1
  274. data/lib/rubocop/cop/rails/present.rb +3 -3
  275. data/lib/rubocop/cop/rails/read_write_attribute.rb +1 -1
  276. data/lib/rubocop/cop/rails/redundant_allow_nil.rb +2 -2
  277. data/lib/rubocop/cop/rails/redundant_receiver_in_with_options.rb +1 -1
  278. data/lib/rubocop/cop/rails/reflection_class_name.rb +1 -1
  279. data/lib/rubocop/cop/rails/refute_methods.rb +1 -1
  280. data/lib/rubocop/cop/rails/relative_date_constant.rb +2 -2
  281. data/lib/rubocop/cop/rails/request_referer.rb +1 -1
  282. data/lib/rubocop/cop/rails/reversible_migration.rb +4 -4
  283. data/lib/rubocop/cop/rails/safe_navigation.rb +2 -6
  284. data/lib/rubocop/cop/rails/save_bang.rb +8 -8
  285. data/lib/rubocop/cop/rails/scope_args.rb +1 -1
  286. data/lib/rubocop/cop/rails/skips_model_validations.rb +1 -1
  287. data/lib/rubocop/cop/rails/time_zone.rb +53 -39
  288. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +3 -3
  289. data/lib/rubocop/cop/rails/unknown_env.rb +2 -2
  290. data/lib/rubocop/cop/rails/validation.rb +1 -1
  291. data/lib/rubocop/cop/registry.rb +1 -1
  292. data/lib/rubocop/cop/security/eval.rb +1 -1
  293. data/lib/rubocop/cop/security/json_load.rb +1 -1
  294. data/lib/rubocop/cop/security/marshal_load.rb +1 -1
  295. data/lib/rubocop/cop/security/open.rb +1 -1
  296. data/lib/rubocop/cop/security/yaml_load.rb +1 -1
  297. data/lib/rubocop/cop/style/alias.rb +3 -3
  298. data/lib/rubocop/cop/style/and_or.rb +1 -1
  299. data/lib/rubocop/cop/style/array_join.rb +1 -1
  300. data/lib/rubocop/cop/style/ascii_comments.rb +1 -1
  301. data/lib/rubocop/cop/style/attr.rb +1 -1
  302. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +1 -1
  303. data/lib/rubocop/cop/style/bare_percent_literals.rb +1 -1
  304. data/lib/rubocop/cop/style/begin_block.rb +1 -1
  305. data/lib/rubocop/cop/style/block_comments.rb +1 -1
  306. data/lib/rubocop/cop/style/block_delimiters.rb +0 -1
  307. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
  308. data/lib/rubocop/cop/style/case_equality.rb +1 -1
  309. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  310. data/lib/rubocop/cop/style/class_and_module_children.rb +5 -5
  311. data/lib/rubocop/cop/style/class_check.rb +1 -1
  312. data/lib/rubocop/cop/style/class_methods.rb +1 -1
  313. data/lib/rubocop/cop/style/class_vars.rb +1 -1
  314. data/lib/rubocop/cop/style/collection_methods.rb +1 -1
  315. data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
  316. data/lib/rubocop/cop/style/colon_method_definition.rb +1 -1
  317. data/lib/rubocop/cop/style/command_literal.rb +2 -2
  318. data/lib/rubocop/cop/style/comment_annotation.rb +2 -2
  319. data/lib/rubocop/cop/style/commented_keyword.rb +1 -1
  320. data/lib/rubocop/cop/style/conditional_assignment.rb +14 -14
  321. data/lib/rubocop/cop/style/constant_visibility.rb +1 -1
  322. data/lib/rubocop/cop/style/copyright.rb +2 -2
  323. data/lib/rubocop/cop/style/date_time.rb +2 -2
  324. data/lib/rubocop/cop/style/def_with_parentheses.rb +1 -1
  325. data/lib/rubocop/cop/style/dir.rb +1 -1
  326. data/lib/rubocop/cop/style/documentation.rb +2 -2
  327. data/lib/rubocop/cop/style/documentation_method.rb +1 -1
  328. data/lib/rubocop/cop/style/double_negation.rb +1 -1
  329. data/lib/rubocop/cop/style/each_for_simple_loop.rb +1 -1
  330. data/lib/rubocop/cop/style/each_with_object.rb +3 -3
  331. data/lib/rubocop/cop/style/empty_block_parameter.rb +1 -1
  332. data/lib/rubocop/cop/style/empty_case_condition.rb +1 -1
  333. data/lib/rubocop/cop/style/empty_else.rb +2 -2
  334. data/lib/rubocop/cop/style/empty_lambda_parameter.rb +1 -1
  335. data/lib/rubocop/cop/style/empty_literal.rb +3 -3
  336. data/lib/rubocop/cop/style/empty_method.rb +2 -2
  337. data/lib/rubocop/cop/style/encoding.rb +2 -2
  338. data/lib/rubocop/cop/style/end_block.rb +1 -1
  339. data/lib/rubocop/cop/style/eval_with_location.rb +3 -3
  340. data/lib/rubocop/cop/style/even_odd.rb +1 -1
  341. data/lib/rubocop/cop/style/expand_path_arguments.rb +3 -3
  342. data/lib/rubocop/cop/style/for.rb +2 -2
  343. data/lib/rubocop/cop/style/format_string.rb +1 -1
  344. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +5 -21
  345. data/lib/rubocop/cop/style/global_vars.rb +1 -1
  346. data/lib/rubocop/cop/style/guard_clause.rb +3 -3
  347. data/lib/rubocop/cop/style/hash_syntax.rb +3 -3
  348. data/lib/rubocop/cop/style/identical_conditional_branches.rb +1 -1
  349. data/lib/rubocop/cop/style/if_inside_else.rb +2 -2
  350. data/lib/rubocop/cop/style/if_unless_modifier.rb +1 -1
  351. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +1 -1
  352. data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -2
  353. data/lib/rubocop/cop/style/implicit_runtime_error.rb +1 -1
  354. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  355. data/lib/rubocop/cop/style/inline_comment.rb +1 -1
  356. data/lib/rubocop/cop/style/inverse_methods.rb +7 -1
  357. data/lib/rubocop/cop/style/ip_addresses.rb +1 -1
  358. data/lib/rubocop/cop/style/lambda.rb +2 -2
  359. data/lib/rubocop/cop/style/line_end_concatenation.rb +2 -2
  360. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +3 -3
  361. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +1 -1
  362. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +2 -2
  363. data/lib/rubocop/cop/style/method_def_parentheses.rb +2 -2
  364. data/lib/rubocop/cop/style/method_missing_super.rb +1 -1
  365. data/lib/rubocop/cop/style/min_max.rb +1 -1
  366. data/lib/rubocop/cop/style/missing_else.rb +3 -3
  367. data/lib/rubocop/cop/style/missing_respond_to_missing.rb +1 -1
  368. data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
  369. data/lib/rubocop/cop/style/mixin_usage.rb +1 -1
  370. data/lib/rubocop/cop/style/module_function.rb +3 -3
  371. data/lib/rubocop/cop/style/multiline_block_chain.rb +2 -2
  372. data/lib/rubocop/cop/style/multiline_if_modifier.rb +1 -1
  373. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  374. data/lib/rubocop/cop/style/multiline_memoization.rb +1 -1
  375. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
  376. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +1 -1
  377. data/lib/rubocop/cop/style/multiple_comparison.rb +1 -1
  378. data/lib/rubocop/cop/style/mutable_constant.rb +3 -3
  379. data/lib/rubocop/cop/style/negated_if.rb +1 -1
  380. data/lib/rubocop/cop/style/negated_unless.rb +89 -0
  381. data/lib/rubocop/cop/style/nested_modifier.rb +4 -4
  382. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +1 -1
  383. data/lib/rubocop/cop/style/nested_ternary_operator.rb +1 -1
  384. data/lib/rubocop/cop/style/next.rb +5 -5
  385. data/lib/rubocop/cop/style/nil_comparison.rb +2 -2
  386. data/lib/rubocop/cop/style/not.rb +1 -1
  387. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +5 -5
  388. data/lib/rubocop/cop/style/numeric_literals.rb +2 -2
  389. data/lib/rubocop/cop/style/numeric_predicate.rb +2 -10
  390. data/lib/rubocop/cop/style/one_line_conditional.rb +1 -1
  391. data/lib/rubocop/cop/style/option_hash.rb +1 -1
  392. data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
  393. data/lib/rubocop/cop/style/or_assignment.rb +1 -1
  394. data/lib/rubocop/cop/style/parallel_assignment.rb +2 -2
  395. data/lib/rubocop/cop/style/percent_q_literals.rb +2 -2
  396. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  397. data/lib/rubocop/cop/style/preferred_hash_methods.rb +1 -1
  398. data/lib/rubocop/cop/style/proc.rb +1 -1
  399. data/lib/rubocop/cop/style/raise_args.rb +2 -2
  400. data/lib/rubocop/cop/style/random_with_offset.rb +1 -1
  401. data/lib/rubocop/cop/style/redundant_begin.rb +2 -2
  402. data/lib/rubocop/cop/style/redundant_conditional.rb +1 -1
  403. data/lib/rubocop/cop/style/redundant_exception.rb +2 -2
  404. data/lib/rubocop/cop/style/redundant_freeze.rb +1 -1
  405. data/lib/rubocop/cop/style/redundant_parentheses.rb +6 -6
  406. data/lib/rubocop/cop/style/redundant_return.rb +3 -3
  407. data/lib/rubocop/cop/style/redundant_self.rb +2 -2
  408. data/lib/rubocop/cop/style/redundant_sort_by.rb +1 -1
  409. data/lib/rubocop/cop/style/regexp_literal.rb +2 -2
  410. data/lib/rubocop/cop/style/rescue_modifier.rb +1 -1
  411. data/lib/rubocop/cop/style/rescue_standard_error.rb +2 -2
  412. data/lib/rubocop/cop/style/return_nil.rb +2 -2
  413. data/lib/rubocop/cop/style/safe_navigation.rb +2 -7
  414. data/lib/rubocop/cop/style/sample.rb +1 -1
  415. data/lib/rubocop/cop/style/self_assignment.rb +1 -1
  416. data/lib/rubocop/cop/style/semicolon.rb +1 -1
  417. data/lib/rubocop/cop/style/send.rb +1 -1
  418. data/lib/rubocop/cop/style/signal_exception.rb +2 -2
  419. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  420. data/lib/rubocop/cop/style/single_line_methods.rb +1 -1
  421. data/lib/rubocop/cop/style/special_global_vars.rb +5 -5
  422. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -2
  423. data/lib/rubocop/cop/style/stderr_puts.rb +0 -1
  424. data/lib/rubocop/cop/style/string_hash_keys.rb +2 -1
  425. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  426. data/lib/rubocop/cop/style/string_methods.rb +1 -1
  427. data/lib/rubocop/cop/style/strip.rb +1 -1
  428. data/lib/rubocop/cop/style/struct_inheritance.rb +1 -1
  429. data/lib/rubocop/cop/style/symbol_array.rb +2 -2
  430. data/lib/rubocop/cop/style/symbol_literal.rb +1 -1
  431. data/lib/rubocop/cop/style/symbol_proc.rb +1 -1
  432. data/lib/rubocop/cop/style/ternary_parentheses.rb +2 -2
  433. data/lib/rubocop/cop/style/trailing_body_on_class.rb +1 -1
  434. data/lib/rubocop/cop/style/trailing_body_on_method_definition.rb +1 -1
  435. data/lib/rubocop/cop/style/trailing_body_on_module.rb +1 -1
  436. data/lib/rubocop/cop/style/trailing_method_end_statement.rb +1 -1
  437. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +2 -2
  438. data/lib/rubocop/cop/style/trivial_accessors.rb +2 -2
  439. data/lib/rubocop/cop/style/unless_else.rb +2 -2
  440. data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
  441. data/lib/rubocop/cop/style/unneeded_condition.rb +4 -4
  442. data/lib/rubocop/cop/style/unneeded_interpolation.rb +3 -3
  443. data/lib/rubocop/cop/style/unneeded_percent_q.rb +7 -7
  444. data/lib/rubocop/cop/style/unneeded_sort.rb +2 -2
  445. data/lib/rubocop/cop/style/unpack_first.rb +1 -1
  446. data/lib/rubocop/cop/style/variable_interpolation.rb +1 -1
  447. data/lib/rubocop/cop/style/when_then.rb +1 -1
  448. data/lib/rubocop/cop/style/while_until_do.rb +1 -1
  449. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  450. data/lib/rubocop/cop/style/word_array.rb +2 -2
  451. data/lib/rubocop/cop/style/yoda_condition.rb +1 -1
  452. data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -2
  453. data/lib/rubocop/cop/util.rb +2 -2
  454. data/lib/rubocop/cop/variable_force/variable_table.rb +1 -1
  455. data/lib/rubocop/core_ext/string.rb +1 -1
  456. data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
  457. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
  458. data/lib/rubocop/formatter/fuubar_style_formatter.rb +1 -1
  459. data/lib/rubocop/formatter/html_formatter.rb +1 -1
  460. data/lib/rubocop/formatter/progress_formatter.rb +1 -1
  461. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  462. data/lib/rubocop/magic_comment.rb +4 -4
  463. data/lib/rubocop/node_pattern.rb +9 -9
  464. data/lib/rubocop/options.rb +2 -2
  465. data/lib/rubocop/processed_source.rb +3 -5
  466. data/lib/rubocop/rspec/cop_helper.rb +2 -2
  467. data/lib/rubocop/rspec/expect_offense.rb +5 -5
  468. data/lib/rubocop/rspec/shared_contexts.rb +0 -4
  469. data/lib/rubocop/runner.rb +1 -1
  470. data/lib/rubocop/string_interpreter.rb +7 -7
  471. data/lib/rubocop/version.rb +2 -2
  472. metadata +11 -16
@@ -31,10 +31,10 @@ module RuboCop
31
31
  include NilMethods
32
32
 
33
33
  MSG = 'Ensure that safe navigation is used consistently ' \
34
- 'inside of `&&` and `||`.'.freeze
34
+ 'inside of `&&` and `||`.'
35
35
 
36
36
  def on_csend(node)
37
- return unless node.parent && node.parent.operator_keyword?
37
+ return unless node.parent&.operator_keyword?
38
38
 
39
39
  check(node)
40
40
  end
@@ -21,7 +21,7 @@ module RuboCop
21
21
  #
22
22
  class SafeNavigationWithEmpty < Cop
23
23
  MSG = 'Avoid calling `empty?` with the safe navigation operator ' \
24
- 'in conditionals.'.freeze
24
+ 'in conditionals.'
25
25
 
26
26
  def_node_matcher :safe_navigation_empty_in_conditional?, <<-PATTERN
27
27
  (if (csend (send ...) :empty?) ...)
@@ -31,8 +31,8 @@ module RuboCop
31
31
  # puts 'hello, world'
32
32
  #
33
33
  class ScriptPermission < Cop
34
- MSG = "Script file %<file>s doesn't have execute permission.".freeze
35
- SHEBANG = '#!'.freeze
34
+ MSG = "Script file %<file>s doesn't have execute permission."
35
+ SHEBANG = '#!'
36
36
 
37
37
  def investigate(processed_source)
38
38
  return if @options.key?(:stdin)
@@ -65,7 +65,7 @@ module RuboCop
65
65
  #
66
66
  class ShadowedArgument < Cop
67
67
  MSG = 'Argument `%<argument>s` was shadowed by a local variable ' \
68
- 'before it was used.'.freeze
68
+ 'before it was used.'
69
69
 
70
70
  def_node_search :uses_var?, '(lvar %)'
71
71
 
@@ -47,7 +47,7 @@ module RuboCop
47
47
  include RescueNode
48
48
  include RangeHelp
49
49
 
50
- MSG = 'Do not shadow rescued Exceptions.'.freeze
50
+ MSG = 'Do not shadow rescued Exceptions.'
51
51
 
52
52
  def on_rescue(node)
53
53
  return if rescue_modifier?(node)
@@ -32,7 +32,7 @@ module RuboCop
32
32
  # end
33
33
  # end
34
34
  class ShadowingOuterLocalVariable < Cop
35
- MSG = 'Shadowing outer local variable - `%<variable>s`.'.freeze
35
+ MSG = 'Shadowing outer local variable - `%<variable>s`.'
36
36
 
37
37
  def join_force?(force_class)
38
38
  force_class == VariableForce
@@ -18,9 +18,9 @@ module RuboCop
18
18
  #
19
19
  # "result is #{something}"
20
20
  class StringConversionInInterpolation < Cop
21
- MSG_DEFAULT = 'Redundant use of `Object#to_s` in interpolation.'.freeze
21
+ MSG_DEFAULT = 'Redundant use of `Object#to_s` in interpolation.'
22
22
  MSG_SELF = 'Use `self` instead of `Object#to_s` in ' \
23
- 'interpolation.'.freeze
23
+ 'interpolation.'
24
24
 
25
25
  def_node_matcher :to_s_without_args?, '(send _ :to_s)'
26
26
 
@@ -19,7 +19,7 @@ module RuboCop
19
19
  #
20
20
  class ToJSON < Cop
21
21
  MSG = ' `#to_json` requires an optional argument to be parsable ' \
22
- 'via JSON.generate(obj).'.freeze
22
+ 'via JSON.generate(obj).'
23
23
 
24
24
  def on_def(node)
25
25
  return unless node.method?(:to_json) && node.arguments.empty?
@@ -41,7 +41,7 @@ module RuboCop
41
41
  # end
42
42
  #
43
43
  class UnderscorePrefixedVariableName < Cop
44
- MSG = 'Do not use prefix `_` for a variable that is used.'.freeze
44
+ MSG = 'Do not use prefix `_` for a variable that is used.'
45
45
 
46
46
  def join_force?(force_class)
47
47
  force_class == VariableForce
@@ -18,7 +18,7 @@ module RuboCop
18
18
  #
19
19
  # 1.is_a?(Integer)
20
20
  class UnifiedInteger < Cop
21
- MSG = 'Use `Integer` instead of `%<klass>s`.'.freeze
21
+ MSG = 'Use `Integer` instead of `%<klass>s`.'
22
22
 
23
23
  def_node_matcher :fixnum_or_bignum_const, <<-PATTERN
24
24
  (:const {nil? (:cbase)} ${:Fixnum :Bignum})
@@ -33,6 +33,8 @@ module RuboCop
33
33
  end
34
34
 
35
35
  def autocorrect(node)
36
+ return false if target_ruby_version <= 2.3
37
+
36
38
  lambda do |corrector|
37
39
  corrector.replace(node.loc.name, 'Integer')
38
40
  end
@@ -29,7 +29,7 @@ module RuboCop
29
29
  include NameSimilarity
30
30
  include RangeHelp
31
31
 
32
- COP_NAME = 'Lint/UnneededCopDisableDirective'.freeze
32
+ COP_NAME = 'Lint/UnneededCopDisableDirective'
33
33
 
34
34
  def check(offenses, cop_disabled_line_ranges, comments)
35
35
  unneeded_cops = Hash.new { |h, k| h[k] = Set.new }
@@ -36,7 +36,7 @@ module RuboCop
36
36
  include RangeHelp
37
37
  include SurroundingSpace
38
38
 
39
- MSG = 'Unnecessary enabling of %<cop>s.'.freeze
39
+ MSG = 'Unnecessary enabling of %<cop>s.'
40
40
 
41
41
  def investigate(processed_source)
42
42
  return if processed_source.blank?
@@ -24,7 +24,7 @@ module RuboCop
24
24
  class UnneededRequireStatement < Cop
25
25
  include RangeHelp
26
26
 
27
- MSG = 'Remove unnecessary `require` statement.'.freeze
27
+ MSG = 'Remove unnecessary `require` statement.'
28
28
 
29
29
  def_node_matcher :unnecessary_require_statement?, <<-PATTERN
30
30
  (send nil? :require
@@ -50,12 +50,12 @@ module RuboCop
50
50
  # baz
51
51
  # end
52
52
  class UnneededSplatExpansion < Cop
53
- MSG = 'Replace splat expansion with comma separated values.'.freeze
54
- ARRAY_PARAM_MSG = 'Pass array contents as separate arguments.'.freeze
55
- PERCENT_W = '%w'.freeze
56
- PERCENT_CAPITAL_W = '%W'.freeze
57
- PERCENT_I = '%i'.freeze
58
- PERCENT_CAPITAL_I = '%I'.freeze
53
+ MSG = 'Replace splat expansion with comma separated values.'
54
+ ARRAY_PARAM_MSG = 'Pass array contents as separate arguments.'
55
+ PERCENT_W = '%w'
56
+ PERCENT_CAPITAL_W = '%W'
57
+ PERCENT_I = '%i'
58
+ PERCENT_CAPITAL_I = '%I'
59
59
  ASSIGNMENT_TYPES = %i[lvasgn ivasgn cvasgn gvasgn].freeze
60
60
 
61
61
  def_node_matcher :array_new?, '$(send (const nil? :Array) :new ...)'
@@ -141,7 +141,7 @@ module RuboCop
141
141
  grandparent = node.parent.parent
142
142
 
143
143
  parent.when_type? || parent.send_type? || part_of_an_array?(node) ||
144
- (grandparent && grandparent.resbody_type?)
144
+ (grandparent&.resbody_type?)
145
145
  end
146
146
 
147
147
  def remove_brackets(array)
@@ -35,7 +35,7 @@ module RuboCop
35
35
  # do_something
36
36
  # end
37
37
  class UnreachableCode < Cop
38
- MSG = 'Unreachable code detected.'.freeze
38
+ MSG = 'Unreachable code detected.'
39
39
 
40
40
  def on_begin(node)
41
41
  expressions = *node
@@ -44,7 +44,7 @@ module RuboCop
44
44
  end
45
45
 
46
46
  def message(variable)
47
- message = String.new("Unused method argument - `#{variable.name}`.")
47
+ message = +"Unused method argument - `#{variable.name}`."
48
48
 
49
49
  unless variable.keyword_argument?
50
50
  message << " If it's necessary, use `_` or `_#{variable.name}` " \
@@ -43,7 +43,7 @@ module RuboCop
43
43
 
44
44
  MSG = '`%<uri_method>s` method is obsolete and should not be used. ' \
45
45
  'Instead, use %<replacements>s depending on your specific use ' \
46
- 'case.'.freeze
46
+ 'case.'
47
47
 
48
48
  def_node_matcher :uri_escape_unescape?, <<-PATTERN
49
49
  (send
@@ -16,7 +16,7 @@ module RuboCop
16
16
  class UriRegexp < Cop
17
17
  MSG = '`%<top_level>sURI.regexp%<arg>s` is obsolete and should not ' \
18
18
  'be used. Instead, use `%<top_level>sURI::DEFAULT_PARSER.' \
19
- 'make_regexp%<arg>s`.'.freeze
19
+ 'make_regexp%<arg>s`.'
20
20
 
21
21
  def_node_matcher :uri_regexp_with_argument?, <<-PATTERN
22
22
  (send
@@ -91,7 +91,7 @@ module RuboCop
91
91
  # delegate :method_a, to: :method_b
92
92
  # end
93
93
  class UselessAccessModifier < Cop
94
- MSG = 'Useless `%<current>s` access modifier.'.freeze
94
+ MSG = 'Useless `%<current>s` access modifier.'
95
95
 
96
96
  def on_class(node)
97
97
  check_node(node.children[2]) # class body
@@ -32,7 +32,7 @@ module RuboCop
32
32
  # end
33
33
  class UselessAssignment < Cop
34
34
  include NameSimilarity
35
- MSG = 'Useless assignment to variable - `%<variable>s`.'.freeze
35
+ MSG = 'Useless assignment to variable - `%<variable>s`.'
36
36
 
37
37
  def join_force?(force_class)
38
38
  force_class == VariableForce
@@ -11,7 +11,7 @@ module RuboCop
11
11
  #
12
12
  # x.top >= x.top
13
13
  class UselessComparison < Cop
14
- MSG = 'Comparison of something with itself detected.'.freeze
14
+ MSG = 'Comparison of something with itself detected.'
15
15
  OPS = %w[== === != < > <= >= <=>].freeze
16
16
 
17
17
  def_node_matcher :useless_comparison?,
@@ -29,7 +29,7 @@ module RuboCop
29
29
  class UselessElseWithoutRescue < Cop
30
30
  include ParserDiagnostic
31
31
 
32
- MSG = '`else` without `rescue` is useless.'.freeze
32
+ MSG = '`else` without `rescue` is useless.'
33
33
 
34
34
  private
35
35
 
@@ -25,7 +25,7 @@ module RuboCop
25
25
  # x
26
26
  # end
27
27
  class UselessSetterCall < Cop
28
- MSG = 'Useless setter call to local variable `%<variable>s`.'.freeze
28
+ MSG = 'Useless setter call to local variable `%<variable>s`.'
29
29
  ASSIGNMENT_TYPES = %i[lvasgn ivasgn cvasgn gvasgn].freeze
30
30
 
31
31
  def on_def(node)
@@ -60,13 +60,13 @@ module RuboCop
60
60
  # do_something(some_array)
61
61
  # end
62
62
  class Void < Cop
63
- OP_MSG = 'Operator `%<op>s` used in void context.'.freeze
64
- VAR_MSG = 'Variable `%<var>s` used in void context.'.freeze
65
- LIT_MSG = 'Literal `%<lit>s` used in void context.'.freeze
66
- SELF_MSG = '`self` used in void context.'.freeze
67
- DEFINED_MSG = '`%<defined>s` used in void context.'.freeze
63
+ OP_MSG = 'Operator `%<op>s` used in void context.'
64
+ VAR_MSG = 'Variable `%<var>s` used in void context.'
65
+ LIT_MSG = 'Literal `%<lit>s` used in void context.'
66
+ SELF_MSG = '`self` used in void context.'
67
+ DEFINED_MSG = '`%<defined>s` used in void context.'
68
68
  NONMUTATING_MSG = 'Method `#%<method>s` used in void context. ' \
69
- 'Did you mean `#%<method>s!`?'.freeze
69
+ 'Did you mean `#%<method>s!`?'
70
70
 
71
71
  BINARY_OPERATORS = %i[* / % + - == === != < > <= >= <=>].freeze
72
72
  UNARY_OPERATORS = %i[+@ -@ ~ !].freeze
@@ -11,7 +11,7 @@ module RuboCop
11
11
  include MethodComplexity
12
12
 
13
13
  MSG = 'Assignment Branch Condition size for %<method>s is too high. ' \
14
- '[%<complexity>.4g/%<max>.4g]'.freeze
14
+ '[%<complexity>.4g/%<max>.4g]'
15
15
 
16
16
  private
17
17
 
@@ -10,7 +10,7 @@ module RuboCop
10
10
  class BlockLength < Cop
11
11
  include TooManyLines
12
12
 
13
- LABEL = 'Block'.freeze
13
+ LABEL = 'Block'
14
14
 
15
15
  def on_block(node)
16
16
  return if excluded_method?(node)
@@ -22,7 +22,7 @@ module RuboCop
22
22
  private
23
23
 
24
24
  def excluded_method?(node)
25
- node_receiver = node.receiver && node.receiver.source.gsub(/\s+/, '')
25
+ node_receiver = node.receiver&.source&.gsub(/\s+/, '')
26
26
  node_method = String(node.method_name)
27
27
 
28
28
  excluded_methods.any? do |config|
@@ -17,7 +17,7 @@ module RuboCop
17
17
  include MethodComplexity
18
18
 
19
19
  MSG = 'Cyclomatic complexity for %<method>s is too high. ' \
20
- '[%<complexity>d/%<max>d]'.freeze
20
+ '[%<complexity>d/%<max>d]'
21
21
  COUNTED_NODES = %i[if while until for
22
22
  rescue when and or].freeze
23
23
 
@@ -58,7 +58,7 @@ module RuboCop
58
58
  include IgnoredPattern
59
59
  include RangeHelp
60
60
 
61
- MSG = 'Line is too long. [%<length>d/%<max>d]'.freeze
61
+ MSG = 'Line is too long. [%<length>d/%<max>d]'
62
62
 
63
63
  def on_potential_breakable_node(node)
64
64
  check_for_breakable_node(node)
@@ -9,7 +9,7 @@ module RuboCop
9
9
  class MethodLength < Cop
10
10
  include TooManyLines
11
11
 
12
- LABEL = 'Method'.freeze
12
+ LABEL = 'Method'
13
13
 
14
14
  def on_def(node)
15
15
  excluded_methods = cop_config['ExcludedMethods']
@@ -10,7 +10,7 @@ module RuboCop
10
10
  include ConfigurableMax
11
11
 
12
12
  MSG = 'Avoid parameter lists longer than %<max>d parameters. ' \
13
- '[%<count>d/%<max>d]'.freeze
13
+ '[%<count>d/%<max>d]'
14
14
 
15
15
  def on_args(node)
16
16
  count = args_count(node)
@@ -30,7 +30,7 @@ module RuboCop
30
30
  include MethodComplexity
31
31
 
32
32
  MSG = 'Perceived complexity for %<method>s is too high. ' \
33
- '[%<complexity>d/%<max>d]'.freeze
33
+ '[%<complexity>d/%<max>d]'
34
34
  COUNTED_NODES = %i[if case while until
35
35
  for rescue and or].freeze
36
36
 
@@ -7,7 +7,7 @@ module RuboCop
7
7
  module Alignment
8
8
  private
9
9
 
10
- SPACE = ' '.freeze
10
+ SPACE = ' '
11
11
 
12
12
  attr_reader :column_delta
13
13
 
@@ -31,7 +31,7 @@ module RuboCop
31
31
  _scope, _lhs, rhs = *node
32
32
  elsif node.op_asgn_type?
33
33
  _lhs, _op, rhs = *node
34
- elsif node.send_type? || node.csend_type?
34
+ elsif node.call_type?
35
35
  rhs = node.last_argument
36
36
  elsif node.assignment?
37
37
  _lhs, rhs = *node
@@ -11,10 +11,10 @@ module RuboCop
11
11
  include RangeHelp
12
12
 
13
13
  MSG_EXTRA = 'Extra empty line detected at %<kind>s body ' \
14
- '%<location>s.'.freeze
15
- MSG_MISSING = 'Empty line missing at %<kind>s body %<location>s.'.freeze
14
+ '%<location>s.'
15
+ MSG_MISSING = 'Empty line missing at %<kind>s body %<location>s.'
16
16
  MSG_DEFERRED = 'Empty line missing before first %<type>s ' \
17
- 'definition'.freeze
17
+ 'definition'
18
18
 
19
19
  private
20
20
 
@@ -8,7 +8,7 @@ module RuboCop
8
8
  include RangeHelp
9
9
 
10
10
  MSG = '`end` at %<end_line>d, %<end_col>d is not aligned with ' \
11
- '`%<source>s` at %<align_line>d, %<align_col>d.'.freeze
11
+ '`%<source>s` at %<align_line>d, %<align_col>d.'
12
12
 
13
13
  private
14
14
 
@@ -6,8 +6,8 @@ module RuboCop
6
6
  module FrozenStringLiteral
7
7
  module_function
8
8
 
9
- FROZEN_STRING_LITERAL = '# frozen_string_literal:'.freeze
10
- FROZEN_STRING_LITERAL_ENABLED = '# frozen_string_literal: true'.freeze
9
+ FROZEN_STRING_LITERAL = '# frozen_string_literal:'
10
+ FROZEN_STRING_LITERAL_ENABLED = '# frozen_string_literal: true'
11
11
  FROZEN_STRING_LITERAL_TYPES = %i[str dstr].freeze
12
12
 
13
13
  def frozen_string_literal_comment_exists?
@@ -21,6 +21,7 @@ module RuboCop
21
21
  def frozen_string_literals_enabled?
22
22
  ruby_version = processed_source.ruby_version
23
23
  return false unless ruby_version
24
+
24
25
  # TODO: Ruby officially abandon making frozen string literals default
25
26
  # for Ruby 3.0.
26
27
  # https://bugs.ruby-lang.org/issues/11473#note-53
@@ -33,8 +34,6 @@ module RuboCop
33
34
  # And the above `ruby_version >= 3.1` is undecided whether it will be
34
35
  # Ruby 3.1, 3.2, 4.0 or others.
35
36
  # See https://bugs.ruby-lang.org/issues/8976#note-41 for details.
36
- return false unless ruby_version >= 2.3
37
-
38
37
  leading_comment_lines.any? do |line|
39
38
  MagicComment.parse(line).frozen_string_literal?
40
39
  end
@@ -12,7 +12,7 @@ module RuboCop
12
12
 
13
13
  def min_body_length
14
14
  length = cop_config['MinBodyLength'] || 1
15
- return length if length.is_a?(Integer) && length > 0
15
+ return length if length.is_a?(Integer) && length.positive?
16
16
 
17
17
  raise 'MinBodyLength needs to be a positive integer!'
18
18
  end
@@ -8,10 +8,10 @@ module RuboCop
8
8
  KEYWORD_ANCESTOR_TYPES = %i[for if while until return].freeze
9
9
  UNALIGNED_RHS_TYPES = %i[if while until for return
10
10
  array kwbegin].freeze
11
- DEFAULT_MESSAGE_TAIL = 'an expression'.freeze
12
- ASSIGNMENT_MESSAGE_TAIL = 'an expression in an assignment'.freeze
11
+ DEFAULT_MESSAGE_TAIL = 'an expression'
12
+ ASSIGNMENT_MESSAGE_TAIL = 'an expression in an assignment'
13
13
  KEYWORD_MESSAGE_TAIL = 'a %<kind>s in %<article>s `%<keyword>s` ' \
14
- 'statement'.freeze
14
+ 'statement'
15
15
 
16
16
  def on_send(node)
17
17
  return if !node.receiver || node.method?(:[])
@@ -31,7 +31,7 @@ module RuboCop
31
31
  # b c { block }. <-- b is indented relative to a
32
32
  # d <-- d is indented relative to a
33
33
  def left_hand_side(lhs)
34
- lhs = lhs.parent while lhs.parent && lhs.parent.send_type?
34
+ lhs = lhs.parent while lhs.parent&.send_type?
35
35
  lhs
36
36
  end
37
37