rubocop 0.43.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rubocop might be problematic. Click here for more details.

Files changed (430) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/rubocop +0 -1
  4. data/config/default.yml +31 -0
  5. data/config/disabled.yml +6 -6
  6. data/config/enabled.yml +182 -140
  7. data/lib/rubocop.rb +7 -2
  8. data/lib/rubocop/ast_node.rb +0 -1
  9. data/lib/rubocop/ast_node/builder.rb +0 -1
  10. data/lib/rubocop/ast_node/sexp.rb +0 -1
  11. data/lib/rubocop/ast_node/traversal.rb +0 -1
  12. data/lib/rubocop/cached_data.rb +3 -20
  13. data/lib/rubocop/cli.rb +0 -1
  14. data/lib/rubocop/comment_config.rb +0 -1
  15. data/lib/rubocop/config.rb +0 -1
  16. data/lib/rubocop/config_loader.rb +1 -2
  17. data/lib/rubocop/config_loader_resolver.rb +0 -1
  18. data/lib/rubocop/config_store.rb +0 -1
  19. data/lib/rubocop/cop/autocorrect_logic.rb +0 -1
  20. data/lib/rubocop/cop/commissioner.rb +0 -1
  21. data/lib/rubocop/cop/cop.rb +15 -5
  22. data/lib/rubocop/cop/corrector.rb +0 -1
  23. data/lib/rubocop/cop/force.rb +0 -1
  24. data/lib/rubocop/cop/ignored_node.rb +0 -1
  25. data/lib/rubocop/cop/lint/ambiguous_operator.rb +0 -1
  26. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +0 -1
  27. data/lib/rubocop/cop/lint/assignment_in_condition.rb +2 -2
  28. data/lib/rubocop/cop/lint/block_alignment.rb +0 -1
  29. data/lib/rubocop/cop/lint/circular_argument_reference.rb +0 -1
  30. data/lib/rubocop/cop/lint/condition_position.rb +0 -1
  31. data/lib/rubocop/cop/lint/debugger.rb +0 -1
  32. data/lib/rubocop/cop/lint/def_end_alignment.rb +0 -1
  33. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +0 -1
  34. data/lib/rubocop/cop/lint/duplicate_methods.rb +0 -1
  35. data/lib/rubocop/cop/lint/duplicated_key.rb +0 -1
  36. data/lib/rubocop/cop/lint/each_with_object_argument.rb +0 -1
  37. data/lib/rubocop/cop/lint/else_layout.rb +0 -1
  38. data/lib/rubocop/cop/lint/empty_ensure.rb +0 -1
  39. data/lib/rubocop/cop/lint/empty_interpolation.rb +0 -1
  40. data/lib/rubocop/cop/lint/end_alignment.rb +0 -1
  41. data/lib/rubocop/cop/lint/end_in_method.rb +0 -1
  42. data/lib/rubocop/cop/lint/ensure_return.rb +0 -1
  43. data/lib/rubocop/cop/lint/eval.rb +0 -1
  44. data/lib/rubocop/cop/lint/float_out_of_range.rb +0 -1
  45. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +0 -1
  46. data/lib/rubocop/cop/lint/handle_exceptions.rb +0 -1
  47. data/lib/rubocop/cop/lint/implicit_string_concatenation.rb +0 -1
  48. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +0 -1
  49. data/lib/rubocop/cop/lint/inherit_exception.rb +0 -1
  50. data/lib/rubocop/cop/lint/invalid_character_literal.rb +0 -1
  51. data/lib/rubocop/cop/lint/literal_in_condition.rb +0 -1
  52. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +0 -1
  53. data/lib/rubocop/cop/lint/loop.rb +0 -1
  54. data/lib/rubocop/cop/lint/nested_method_definition.rb +0 -1
  55. data/lib/rubocop/cop/lint/next_without_accumulator.rb +0 -1
  56. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +0 -1
  57. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +0 -1
  58. data/lib/rubocop/cop/lint/percent_string_array.rb +0 -1
  59. data/lib/rubocop/cop/lint/percent_symbol_array.rb +0 -1
  60. data/lib/rubocop/cop/lint/rand_one.rb +0 -1
  61. data/lib/rubocop/cop/lint/require_parentheses.rb +0 -1
  62. data/lib/rubocop/cop/lint/rescue_exception.rb +0 -1
  63. data/lib/rubocop/cop/lint/shadowed_exception.rb +1 -2
  64. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +0 -1
  65. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +0 -1
  66. data/lib/rubocop/cop/lint/syntax.rb +0 -1
  67. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +0 -1
  68. data/lib/rubocop/cop/lint/unified_integer.rb +0 -1
  69. data/lib/rubocop/cop/lint/unneeded_disable.rb +0 -1
  70. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +15 -2
  71. data/lib/rubocop/cop/lint/unreachable_code.rb +0 -1
  72. data/lib/rubocop/cop/lint/unused_block_argument.rb +81 -27
  73. data/lib/rubocop/cop/lint/unused_method_argument.rb +0 -1
  74. data/lib/rubocop/cop/lint/useless_access_modifier.rb +0 -1
  75. data/lib/rubocop/cop/lint/useless_assignment.rb +0 -1
  76. data/lib/rubocop/cop/lint/useless_comparison.rb +0 -1
  77. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -1
  78. data/lib/rubocop/cop/lint/useless_setter_call.rb +0 -1
  79. data/lib/rubocop/cop/lint/void.rb +0 -1
  80. data/lib/rubocop/cop/metrics/abc_size.rb +1 -2
  81. data/lib/rubocop/cop/metrics/block_length.rb +26 -0
  82. data/lib/rubocop/cop/metrics/block_nesting.rb +0 -1
  83. data/lib/rubocop/cop/metrics/class_length.rb +0 -1
  84. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +0 -1
  85. data/lib/rubocop/cop/metrics/line_length.rb +45 -8
  86. data/lib/rubocop/cop/metrics/method_length.rb +5 -10
  87. data/lib/rubocop/cop/metrics/module_length.rb +0 -1
  88. data/lib/rubocop/cop/metrics/parameter_lists.rb +0 -1
  89. data/lib/rubocop/cop/metrics/perceived_complexity.rb +0 -1
  90. data/lib/rubocop/cop/mixin/access_modifier_node.rb +0 -1
  91. data/lib/rubocop/cop/mixin/annotation_comment.rb +0 -1
  92. data/lib/rubocop/cop/mixin/array_hash_indentation.rb +0 -1
  93. data/lib/rubocop/cop/mixin/array_syntax.rb +0 -1
  94. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +0 -1
  95. data/lib/rubocop/cop/mixin/check_assignment.rb +0 -1
  96. data/lib/rubocop/cop/mixin/classish_length.rb +0 -1
  97. data/lib/rubocop/cop/mixin/code_length.rb +1 -2
  98. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +0 -1
  99. data/lib/rubocop/cop/mixin/configurable_max.rb +0 -1
  100. data/lib/rubocop/cop/mixin/configurable_naming.rb +0 -1
  101. data/lib/rubocop/cop/mixin/configurable_numbering.rb +2 -2
  102. data/lib/rubocop/cop/mixin/def_node.rb +0 -1
  103. data/lib/rubocop/cop/mixin/documentation_comment.rb +0 -1
  104. data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +41 -16
  105. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +0 -1
  106. data/lib/rubocop/cop/mixin/first_element_line_break.rb +0 -1
  107. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +0 -1
  108. data/lib/rubocop/cop/mixin/hash_node.rb +0 -1
  109. data/lib/rubocop/cop/mixin/if_node.rb +0 -1
  110. data/lib/rubocop/cop/mixin/integer_node.rb +0 -1
  111. data/lib/rubocop/cop/mixin/match_range.rb +0 -1
  112. data/lib/rubocop/cop/mixin/method_complexity.rb +0 -1
  113. data/lib/rubocop/cop/mixin/method_preference.rb +0 -1
  114. data/lib/rubocop/cop/mixin/min_body_length.rb +0 -1
  115. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +0 -1
  116. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +0 -1
  117. data/lib/rubocop/cop/mixin/negative_conditional.rb +0 -1
  118. data/lib/rubocop/cop/mixin/on_method_def.rb +0 -1
  119. data/lib/rubocop/cop/mixin/on_normal_if_unless.rb +0 -1
  120. data/lib/rubocop/cop/mixin/parentheses.rb +0 -1
  121. data/lib/rubocop/cop/mixin/parser_diagnostic.rb +0 -1
  122. data/lib/rubocop/cop/mixin/percent_literal.rb +0 -1
  123. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +0 -1
  124. data/lib/rubocop/cop/mixin/safe_assignment.rb +0 -1
  125. data/lib/rubocop/cop/mixin/safe_mode.rb +0 -1
  126. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +0 -1
  127. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +0 -1
  128. data/lib/rubocop/cop/mixin/space_inside.rb +0 -1
  129. data/lib/rubocop/cop/mixin/statement_modifier.rb +0 -1
  130. data/lib/rubocop/cop/mixin/string_help.rb +0 -1
  131. data/lib/rubocop/cop/mixin/string_literals_help.rb +0 -1
  132. data/lib/rubocop/cop/mixin/surrounding_space.rb +0 -1
  133. data/lib/rubocop/cop/mixin/too_many_lines.rb +25 -0
  134. data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -2
  135. data/lib/rubocop/cop/mixin/unused_argument.rb +0 -1
  136. data/lib/rubocop/cop/offense.rb +0 -1
  137. data/lib/rubocop/cop/performance/case_when_splat.rb +17 -8
  138. data/lib/rubocop/cop/performance/casecmp.rb +0 -1
  139. data/lib/rubocop/cop/performance/count.rb +0 -1
  140. data/lib/rubocop/cop/performance/detect.rb +0 -1
  141. data/lib/rubocop/cop/performance/double_start_end_with.rb +0 -1
  142. data/lib/rubocop/cop/performance/end_with.rb +0 -1
  143. data/lib/rubocop/cop/performance/fixed_size.rb +0 -1
  144. data/lib/rubocop/cop/performance/flat_map.rb +0 -1
  145. data/lib/rubocop/cop/performance/{hash_each.rb → hash_each_methods.rb} +0 -1
  146. data/lib/rubocop/cop/performance/lstrip_rstrip.rb +0 -1
  147. data/lib/rubocop/cop/performance/range_include.rb +0 -1
  148. data/lib/rubocop/cop/performance/redundant_block_call.rb +0 -1
  149. data/lib/rubocop/cop/performance/redundant_match.rb +0 -1
  150. data/lib/rubocop/cop/performance/redundant_merge.rb +1 -1
  151. data/lib/rubocop/cop/performance/redundant_sort_by.rb +0 -1
  152. data/lib/rubocop/cop/performance/reverse_each.rb +0 -1
  153. data/lib/rubocop/cop/performance/sample.rb +1 -2
  154. data/lib/rubocop/cop/performance/size.rb +0 -1
  155. data/lib/rubocop/cop/performance/sort_with_block.rb +0 -1
  156. data/lib/rubocop/cop/performance/start_with.rb +0 -1
  157. data/lib/rubocop/cop/performance/string_replacement.rb +0 -1
  158. data/lib/rubocop/cop/performance/times_map.rb +0 -1
  159. data/lib/rubocop/cop/rails/action_filter.rb +2 -3
  160. data/lib/rubocop/cop/rails/date.rb +0 -1
  161. data/lib/rubocop/cop/rails/delegate.rb +0 -1
  162. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +62 -0
  163. data/lib/rubocop/cop/rails/dynamic_find_by.rb +77 -0
  164. data/lib/rubocop/cop/rails/exit.rb +0 -1
  165. data/lib/rubocop/cop/rails/find_by.rb +0 -1
  166. data/lib/rubocop/cop/rails/find_each.rb +0 -1
  167. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +0 -1
  168. data/lib/rubocop/cop/rails/http_positional_arguments.rb +89 -0
  169. data/lib/rubocop/cop/rails/not_null_column.rb +1 -2
  170. data/lib/rubocop/cop/rails/output.rb +0 -1
  171. data/lib/rubocop/cop/rails/output_safety.rb +1 -2
  172. data/lib/rubocop/cop/rails/pluralization_grammar.rb +0 -1
  173. data/lib/rubocop/cop/rails/read_write_attribute.rb +0 -1
  174. data/lib/rubocop/cop/rails/request_referer.rb +0 -1
  175. data/lib/rubocop/cop/rails/safe_navigation.rb +0 -1
  176. data/lib/rubocop/cop/rails/save_bang.rb +12 -3
  177. data/lib/rubocop/cop/rails/scope_args.rb +0 -1
  178. data/lib/rubocop/cop/rails/time_zone.rb +0 -1
  179. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +1 -2
  180. data/lib/rubocop/cop/rails/validation.rb +0 -1
  181. data/lib/rubocop/cop/security/json_load.rb +11 -3
  182. data/lib/rubocop/cop/severity.rb +0 -1
  183. data/lib/rubocop/cop/style/access_modifier_indentation.rb +0 -1
  184. data/lib/rubocop/cop/style/accessor_method_name.rb +0 -1
  185. data/lib/rubocop/cop/style/alias.rb +0 -1
  186. data/lib/rubocop/cop/style/align_array.rb +0 -1
  187. data/lib/rubocop/cop/style/align_hash.rb +0 -1
  188. data/lib/rubocop/cop/style/align_parameters.rb +0 -1
  189. data/lib/rubocop/cop/style/and_or.rb +0 -1
  190. data/lib/rubocop/cop/style/array_join.rb +0 -1
  191. data/lib/rubocop/cop/style/ascii_comments.rb +0 -1
  192. data/lib/rubocop/cop/style/ascii_identifiers.rb +0 -1
  193. data/lib/rubocop/cop/style/attr.rb +0 -1
  194. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +0 -1
  195. data/lib/rubocop/cop/style/bare_percent_literals.rb +0 -1
  196. data/lib/rubocop/cop/style/begin_block.rb +0 -1
  197. data/lib/rubocop/cop/style/block_comments.rb +0 -1
  198. data/lib/rubocop/cop/style/block_delimiters.rb +0 -1
  199. data/lib/rubocop/cop/style/block_end_newline.rb +0 -1
  200. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -1
  201. data/lib/rubocop/cop/style/case_equality.rb +0 -1
  202. data/lib/rubocop/cop/style/case_indentation.rb +0 -1
  203. data/lib/rubocop/cop/style/character_literal.rb +0 -1
  204. data/lib/rubocop/cop/style/class_and_module_camel_case.rb +0 -1
  205. data/lib/rubocop/cop/style/class_and_module_children.rb +0 -1
  206. data/lib/rubocop/cop/style/class_check.rb +0 -1
  207. data/lib/rubocop/cop/style/class_methods.rb +0 -1
  208. data/lib/rubocop/cop/style/class_vars.rb +0 -1
  209. data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +0 -1
  210. data/lib/rubocop/cop/style/collection_methods.rb +0 -1
  211. data/lib/rubocop/cop/style/colon_method_call.rb +0 -1
  212. data/lib/rubocop/cop/style/command_literal.rb +0 -1
  213. data/lib/rubocop/cop/style/comment_annotation.rb +0 -1
  214. data/lib/rubocop/cop/style/comment_indentation.rb +0 -1
  215. data/lib/rubocop/cop/style/conditional_assignment.rb +0 -1
  216. data/lib/rubocop/cop/style/constant_name.rb +0 -1
  217. data/lib/rubocop/cop/style/copyright.rb +0 -1
  218. data/lib/rubocop/cop/style/def_with_parentheses.rb +0 -1
  219. data/lib/rubocop/cop/style/documentation.rb +0 -1
  220. data/lib/rubocop/cop/style/documentation_method.rb +0 -1
  221. data/lib/rubocop/cop/style/dot_position.rb +0 -1
  222. data/lib/rubocop/cop/style/double_negation.rb +0 -1
  223. data/lib/rubocop/cop/style/each_for_simple_loop.rb +0 -1
  224. data/lib/rubocop/cop/style/each_with_object.rb +0 -1
  225. data/lib/rubocop/cop/style/else_alignment.rb +0 -1
  226. data/lib/rubocop/cop/style/empty_case_condition.rb +0 -1
  227. data/lib/rubocop/cop/style/empty_else.rb +7 -6
  228. data/lib/rubocop/cop/style/empty_line_between_defs.rb +0 -1
  229. data/lib/rubocop/cop/style/empty_lines.rb +0 -1
  230. data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +15 -8
  231. data/lib/rubocop/cop/style/empty_lines_around_block_body.rb +0 -1
  232. data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +0 -1
  233. data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +0 -1
  234. data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +0 -1
  235. data/lib/rubocop/cop/style/empty_literal.rb +0 -1
  236. data/lib/rubocop/cop/style/encoding.rb +0 -1
  237. data/lib/rubocop/cop/style/end_block.rb +0 -1
  238. data/lib/rubocop/cop/style/end_of_line.rb +0 -1
  239. data/lib/rubocop/cop/style/even_odd.rb +0 -1
  240. data/lib/rubocop/cop/style/extra_spacing.rb +5 -4
  241. data/lib/rubocop/cop/style/file_name.rb +0 -1
  242. data/lib/rubocop/cop/style/first_array_element_line_break.rb +0 -1
  243. data/lib/rubocop/cop/style/first_hash_element_line_break.rb +0 -1
  244. data/lib/rubocop/cop/style/first_method_argument_line_break.rb +0 -1
  245. data/lib/rubocop/cop/style/first_method_parameter_line_break.rb +0 -1
  246. data/lib/rubocop/cop/style/first_parameter_indentation.rb +0 -1
  247. data/lib/rubocop/cop/style/flip_flop.rb +0 -1
  248. data/lib/rubocop/cop/style/for.rb +0 -1
  249. data/lib/rubocop/cop/style/format_string.rb +0 -1
  250. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +0 -1
  251. data/lib/rubocop/cop/style/global_vars.rb +0 -1
  252. data/lib/rubocop/cop/style/guard_clause.rb +2 -4
  253. data/lib/rubocop/cop/style/hash_syntax.rb +0 -1
  254. data/lib/rubocop/cop/style/identical_conditional_branches.rb +0 -1
  255. data/lib/rubocop/cop/style/if_inside_else.rb +0 -1
  256. data/lib/rubocop/cop/style/if_unless_modifier.rb +0 -1
  257. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +0 -1
  258. data/lib/rubocop/cop/style/if_with_semicolon.rb +0 -1
  259. data/lib/rubocop/cop/style/implicit_runtime_error.rb +0 -1
  260. data/lib/rubocop/cop/style/indent_array.rb +0 -1
  261. data/lib/rubocop/cop/style/indent_assignment.rb +0 -1
  262. data/lib/rubocop/cop/style/indent_hash.rb +0 -1
  263. data/lib/rubocop/cop/style/indentation_consistency.rb +0 -1
  264. data/lib/rubocop/cop/style/indentation_width.rb +0 -1
  265. data/lib/rubocop/cop/style/infinite_loop.rb +0 -1
  266. data/lib/rubocop/cop/style/initial_indentation.rb +0 -1
  267. data/lib/rubocop/cop/style/inline_comment.rb +0 -1
  268. data/lib/rubocop/cop/style/lambda.rb +0 -1
  269. data/lib/rubocop/cop/style/lambda_call.rb +0 -1
  270. data/lib/rubocop/cop/style/leading_comment_space.rb +0 -1
  271. data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -2
  272. data/lib/rubocop/cop/style/method_call_parentheses.rb +0 -1
  273. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +0 -1
  274. data/lib/rubocop/cop/style/method_def_parentheses.rb +0 -1
  275. data/lib/rubocop/cop/style/method_missing.rb +0 -1
  276. data/lib/rubocop/cop/style/method_name.rb +0 -1
  277. data/lib/rubocop/cop/style/missing_else.rb +0 -1
  278. data/lib/rubocop/cop/style/module_function.rb +0 -1
  279. data/lib/rubocop/cop/style/multiline_array_brace_layout.rb +0 -1
  280. data/lib/rubocop/cop/style/multiline_assignment_layout.rb +0 -1
  281. data/lib/rubocop/cop/style/multiline_block_chain.rb +0 -1
  282. data/lib/rubocop/cop/style/multiline_block_layout.rb +0 -1
  283. data/lib/rubocop/cop/style/multiline_hash_brace_layout.rb +0 -1
  284. data/lib/rubocop/cop/style/multiline_if_then.rb +0 -1
  285. data/lib/rubocop/cop/style/multiline_memoization.rb +44 -0
  286. data/lib/rubocop/cop/style/multiline_method_call_brace_layout.rb +0 -1
  287. data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +0 -1
  288. data/lib/rubocop/cop/style/multiline_method_definition_brace_layout.rb +0 -1
  289. data/lib/rubocop/cop/style/multiline_operation_indentation.rb +0 -1
  290. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +0 -1
  291. data/lib/rubocop/cop/style/mutable_constant.rb +0 -1
  292. data/lib/rubocop/cop/style/negated_if.rb +0 -1
  293. data/lib/rubocop/cop/style/negated_while.rb +0 -1
  294. data/lib/rubocop/cop/style/nested_modifier.rb +0 -1
  295. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +0 -1
  296. data/lib/rubocop/cop/style/nested_ternary_operator.rb +0 -1
  297. data/lib/rubocop/cop/style/next.rb +0 -1
  298. data/lib/rubocop/cop/style/nil_comparison.rb +0 -1
  299. data/lib/rubocop/cop/style/non_nil_check.rb +18 -2
  300. data/lib/rubocop/cop/style/not.rb +0 -1
  301. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +2 -5
  302. data/lib/rubocop/cop/style/numeric_literals.rb +0 -1
  303. data/lib/rubocop/cop/style/numeric_predicate.rb +0 -1
  304. data/lib/rubocop/cop/style/one_line_conditional.rb +0 -1
  305. data/lib/rubocop/cop/style/op_method.rb +0 -1
  306. data/lib/rubocop/cop/style/option_hash.rb +0 -1
  307. data/lib/rubocop/cop/style/optional_arguments.rb +0 -1
  308. data/lib/rubocop/cop/style/parallel_assignment.rb +13 -2
  309. data/lib/rubocop/cop/style/parentheses_around_condition.rb +0 -1
  310. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +0 -1
  311. data/lib/rubocop/cop/style/percent_q_literals.rb +0 -1
  312. data/lib/rubocop/cop/style/perl_backrefs.rb +0 -1
  313. data/lib/rubocop/cop/style/predicate_name.rb +0 -1
  314. data/lib/rubocop/cop/style/preferred_hash_methods.rb +44 -6
  315. data/lib/rubocop/cop/style/proc.rb +0 -1
  316. data/lib/rubocop/cop/style/raise_args.rb +13 -14
  317. data/lib/rubocop/cop/style/redundant_begin.rb +0 -1
  318. data/lib/rubocop/cop/style/redundant_exception.rb +0 -1
  319. data/lib/rubocop/cop/style/redundant_freeze.rb +0 -1
  320. data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -2
  321. data/lib/rubocop/cop/style/redundant_return.rb +37 -9
  322. data/lib/rubocop/cop/style/redundant_self.rb +0 -1
  323. data/lib/rubocop/cop/style/regexp_literal.rb +0 -1
  324. data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +0 -1
  325. data/lib/rubocop/cop/style/rescue_modifier.rb +0 -1
  326. data/lib/rubocop/cop/style/safe_navigation.rb +51 -39
  327. data/lib/rubocop/cop/style/self_assignment.rb +0 -1
  328. data/lib/rubocop/cop/style/semicolon.rb +0 -1
  329. data/lib/rubocop/cop/style/send.rb +0 -1
  330. data/lib/rubocop/cop/style/signal_exception.rb +0 -1
  331. data/lib/rubocop/cop/style/single_line_block_params.rb +0 -1
  332. data/lib/rubocop/cop/style/single_line_methods.rb +0 -1
  333. data/lib/rubocop/cop/style/space_after_colon.rb +0 -1
  334. data/lib/rubocop/cop/style/space_after_comma.rb +0 -1
  335. data/lib/rubocop/cop/style/space_after_method_name.rb +0 -1
  336. data/lib/rubocop/cop/style/space_after_not.rb +0 -1
  337. data/lib/rubocop/cop/style/space_after_semicolon.rb +0 -1
  338. data/lib/rubocop/cop/style/space_around_block_parameters.rb +0 -1
  339. data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +0 -1
  340. data/lib/rubocop/cop/style/space_around_keyword.rb +0 -1
  341. data/lib/rubocop/cop/style/space_around_operators.rb +0 -1
  342. data/lib/rubocop/cop/style/space_before_block_braces.rb +0 -1
  343. data/lib/rubocop/cop/style/space_before_comma.rb +0 -1
  344. data/lib/rubocop/cop/style/space_before_comment.rb +0 -1
  345. data/lib/rubocop/cop/style/space_before_first_arg.rb +0 -1
  346. data/lib/rubocop/cop/style/space_before_semicolon.rb +0 -1
  347. data/lib/rubocop/cop/style/space_inside_array_percent_literal.rb +0 -1
  348. data/lib/rubocop/cop/style/space_inside_block_braces.rb +0 -1
  349. data/lib/rubocop/cop/style/space_inside_brackets.rb +0 -1
  350. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +0 -1
  351. data/lib/rubocop/cop/style/space_inside_parens.rb +0 -1
  352. data/lib/rubocop/cop/style/space_inside_percent_literal_delimiters.rb +0 -1
  353. data/lib/rubocop/cop/style/space_inside_range_literal.rb +0 -1
  354. data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +0 -1
  355. data/lib/rubocop/cop/style/special_global_vars.rb +0 -1
  356. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +0 -1
  357. data/lib/rubocop/cop/style/string_literals.rb +0 -1
  358. data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +0 -1
  359. data/lib/rubocop/cop/style/string_methods.rb +0 -1
  360. data/lib/rubocop/cop/style/struct_inheritance.rb +0 -1
  361. data/lib/rubocop/cop/style/symbol_array.rb +0 -1
  362. data/lib/rubocop/cop/style/symbol_literal.rb +0 -1
  363. data/lib/rubocop/cop/style/symbol_proc.rb +0 -1
  364. data/lib/rubocop/cop/style/tab.rb +0 -1
  365. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -2
  366. data/lib/rubocop/cop/style/trailing_blank_lines.rb +0 -1
  367. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +0 -1
  368. data/lib/rubocop/cop/style/trailing_comma_in_literal.rb +0 -1
  369. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +0 -1
  370. data/lib/rubocop/cop/style/trailing_whitespace.rb +0 -1
  371. data/lib/rubocop/cop/style/trivial_accessors.rb +0 -1
  372. data/lib/rubocop/cop/style/unless_else.rb +0 -1
  373. data/lib/rubocop/cop/style/unneeded_capital_w.rb +3 -2
  374. data/lib/rubocop/cop/style/unneeded_interpolation.rb +0 -1
  375. data/lib/rubocop/cop/style/unneeded_percent_q.rb +0 -1
  376. data/lib/rubocop/cop/style/variable_interpolation.rb +0 -1
  377. data/lib/rubocop/cop/style/variable_name.rb +0 -1
  378. data/lib/rubocop/cop/style/variable_number.rb +0 -1
  379. data/lib/rubocop/cop/style/when_then.rb +0 -1
  380. data/lib/rubocop/cop/style/while_until_do.rb +0 -1
  381. data/lib/rubocop/cop/style/while_until_modifier.rb +0 -1
  382. data/lib/rubocop/cop/style/word_array.rb +0 -1
  383. data/lib/rubocop/cop/style/zero_length_predicate.rb +0 -1
  384. data/lib/rubocop/cop/team.rb +1 -2
  385. data/lib/rubocop/cop/util.rb +11 -6
  386. data/lib/rubocop/cop/variable_force.rb +0 -1
  387. data/lib/rubocop/cop/variable_force/assignment.rb +0 -1
  388. data/lib/rubocop/cop/variable_force/locatable.rb +0 -1
  389. data/lib/rubocop/cop/variable_force/reference.rb +0 -1
  390. data/lib/rubocop/cop/variable_force/scope.rb +0 -1
  391. data/lib/rubocop/cop/variable_force/variable.rb +0 -1
  392. data/lib/rubocop/cop/variable_force/variable_table.rb +0 -1
  393. data/lib/rubocop/error.rb +0 -1
  394. data/lib/rubocop/formatter/base_formatter.rb +0 -1
  395. data/lib/rubocop/formatter/clang_style_formatter.rb +0 -1
  396. data/lib/rubocop/formatter/colorizable.rb +0 -1
  397. data/lib/rubocop/formatter/disabled_config_formatter.rb +0 -1
  398. data/lib/rubocop/formatter/disabled_lines_formatter.rb +0 -1
  399. data/lib/rubocop/formatter/emacs_style_formatter.rb +0 -1
  400. data/lib/rubocop/formatter/file_list_formatter.rb +0 -1
  401. data/lib/rubocop/formatter/formatter_set.rb +0 -1
  402. data/lib/rubocop/formatter/fuubar_style_formatter.rb +0 -1
  403. data/lib/rubocop/formatter/html_formatter.rb +2 -3
  404. data/lib/rubocop/formatter/json_formatter.rb +0 -1
  405. data/lib/rubocop/formatter/offense_count_formatter.rb +0 -1
  406. data/lib/rubocop/formatter/progress_formatter.rb +0 -1
  407. data/lib/rubocop/formatter/simple_text_formatter.rb +0 -1
  408. data/lib/rubocop/formatter/text_util.rb +0 -1
  409. data/lib/rubocop/formatter/worst_offenders_formatter.rb +0 -1
  410. data/lib/rubocop/name_similarity.rb +0 -1
  411. data/lib/rubocop/node_pattern.rb +0 -1
  412. data/lib/rubocop/options.rb +0 -1
  413. data/lib/rubocop/path_util.rb +0 -1
  414. data/lib/rubocop/processed_source.rb +3 -4
  415. data/lib/rubocop/rake_task.rb +0 -1
  416. data/lib/rubocop/remote_config.rb +0 -1
  417. data/lib/rubocop/result_cache.rb +3 -4
  418. data/lib/rubocop/rspec/cop_helper.rb +0 -1
  419. data/lib/rubocop/rspec/host_environment_simulation_helper.rb +0 -1
  420. data/lib/rubocop/rspec/shared_contexts.rb +0 -1
  421. data/lib/rubocop/rspec/shared_examples.rb +0 -1
  422. data/lib/rubocop/rspec/support.rb +0 -1
  423. data/lib/rubocop/runner.rb +0 -1
  424. data/lib/rubocop/string_interpreter.rb +0 -1
  425. data/lib/rubocop/string_util.rb +0 -1
  426. data/lib/rubocop/target_finder.rb +0 -1
  427. data/lib/rubocop/token.rb +0 -1
  428. data/lib/rubocop/version.rb +1 -2
  429. data/lib/rubocop/warning.rb +0 -1
  430. metadata +9 -3
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -25,7 +24,9 @@ module RuboCop
25
24
 
26
25
  def requires_interpolation?(node)
27
26
  node.child_nodes.any? do |string|
28
- string.dstr_type? || double_quotes_acceptable?(string.str_content)
27
+ string.dstr_type? ||
28
+ double_quotes_acceptable?(string.str_content) ||
29
+ string.source == '\s'
29
30
  end
30
31
  end
31
32
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -83,7 +82,7 @@ module RuboCop
83
82
  @options[:stdin] = new_source
84
83
  else
85
84
  filename = buffer.name
86
- File.open(filename, 'wb') { |f| f.write(new_source) }
85
+ File.open(filename, 'w') { |f| f.write(new_source) }
87
86
  end
88
87
  @updated_source_file = true
89
88
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
  # rubocop:disable Metrics/ModuleLength
4
3
 
@@ -219,10 +218,11 @@ module RuboCop
219
218
  # If double quoted string literals are found in Ruby code, and they are
220
219
  # not the preferred style, should they be flagged?
221
220
  def double_quotes_acceptable?(string)
222
- # If a string literal contains hard-to-type characters which would
223
- # not appear on a "normal" keyboard, then double-quotes are acceptable
224
- needs_escaping?(string) ||
225
- string.codepoints.any? { |cp| cp < 32 || cp > 126 }
221
+ needs_escaping?(string) || hard_to_type?(string)
222
+ end
223
+
224
+ def hard_to_type?(string)
225
+ string.codepoints.any? { |cp| cp < 32 || cp > 126 }
226
226
  end
227
227
 
228
228
  def needs_escaping?(string)
@@ -234,7 +234,7 @@ module RuboCop
234
234
  end
235
235
 
236
236
  def to_string_literal(string)
237
- if needs_escaping?(string)
237
+ if needs_escaping?(string) && compatible_external_encoding_for?(string)
238
238
  string.inspect
239
239
  else
240
240
  "'#{string.gsub('\\') { '\\\\' }}'"
@@ -266,6 +266,11 @@ module RuboCop
266
266
  def stripped_source_upto(line)
267
267
  processed_source[0..line].map(&:strip)
268
268
  end
269
+
270
+ def compatible_external_encoding_for?(src)
271
+ src = src.dup if RUBY_VERSION < '2.3'
272
+ src.force_encoding(Encoding.default_external).valid_encoding?
273
+ end
269
274
  end
270
275
  end
271
276
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # rubocop:disable Metrics/LineLength
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'fileutils'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'ruby-progressbar'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'cgi'
@@ -12,8 +11,8 @@ module RuboCop
12
11
  # This formatter saves the output as an html file.
13
12
  class HTMLFormatter < BaseFormatter
14
13
  ELLIPSES = '<span class="extra-code">...</span>'.freeze
15
- TEMPLATE_PATH = File.expand_path('../../../../assets/output.html.erb',
16
- __FILE__).encode('utf-8')
14
+ TEMPLATE_PATH =
15
+ File.expand_path('../../../../assets/output.html.erb', __FILE__)
17
16
 
18
17
  Color = Struct.new(:red, :green, :blue, :alpha) do
19
18
  def to_s
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'json'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'rubocop/formatter/colorizable'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'pathname'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # rubocop:disable Metrics/ClassLength
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'optparse'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'digest/md5'
@@ -21,9 +20,9 @@ module RuboCop
21
20
  end
22
21
 
23
22
  def initialize(source, ruby_version, path = nil)
24
- # In Ruby 2, source code encoding defaults to UTF-8. We follow the same
25
- # principle regardless of which Ruby version we're running under.
26
- # Encoding comments will override this setting.
23
+ # Defaults source encoding to UTF-8, regardless of the encoding it has
24
+ # been read with, which could be non-utf8 depending on the default
25
+ # external encoding.
27
26
  unless source.encoding == Encoding::UTF_8
28
27
  source.force_encoding(Encoding::UTF_8)
29
28
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'rake'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'net/http'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'digest/md5'
@@ -91,7 +90,7 @@ module RuboCop
91
90
  end
92
91
 
93
92
  def load
94
- @cached_data.from_json(IO.binread(@path))
93
+ @cached_data.from_json(IO.read(@path, encoding: Encoding::UTF_8))
95
94
  end
96
95
 
97
96
  def save(offenses)
@@ -103,7 +102,7 @@ module RuboCop
103
102
  # indication that a symlink attack is being waged.
104
103
  return if symlink_protection_triggered?(dir)
105
104
 
106
- File.open(preliminary_path, 'wb') do |f|
105
+ File.open(preliminary_path, 'w', encoding: Encoding::UTF_8) do |f|
107
106
  f.write(@cached_data.to_json(offenses))
108
107
  end
109
108
  # The preliminary path is used so that if there are multiple RuboCop
@@ -158,7 +157,7 @@ module RuboCop
158
157
  sources = source_files
159
158
  .select { |path| File.file?(path) }
160
159
  .sort
161
- .map { |path| IO.read(path) }
160
+ .map { |path| IO.read(path, encoding: Encoding::UTF_8) }
162
161
  Digest::MD5.hexdigest(sources.join)
163
162
  end
164
163
  end
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'tempfile'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # RuboCop can be run in contexts where unexpected other libraries are included,
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'tmpdir'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # `cop` and `source` must be declared with #let.
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # Require this file to load code that supports testing using RSpec.
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  require 'set'
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
@@ -1,10 +1,9 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
3
  module RuboCop
5
4
  # This module holds the RuboCop version information.
6
5
  module Version
7
- STRING = '0.43.0'.freeze
6
+ STRING = '0.44.0'.freeze
8
7
 
9
8
  MSG = '%s (using Parser %s, running on %s %s %s)'.freeze
10
9