rubocop 0.47.1 → 0.48.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 (242) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -16
  3. data/config/default.yml +203 -115
  4. data/config/disabled.yml +0 -5
  5. data/config/enabled.yml +92 -8
  6. data/lib/rubocop.rb +24 -1
  7. data/lib/rubocop/ast/builder.rb +7 -2
  8. data/lib/rubocop/ast/node.rb +23 -20
  9. data/lib/rubocop/ast/node/and_node.rb +37 -0
  10. data/lib/rubocop/ast/node/array_node.rb +4 -1
  11. data/lib/rubocop/ast/node/case_node.rb +1 -0
  12. data/lib/rubocop/ast/node/ensure_node.rb +25 -0
  13. data/lib/rubocop/ast/node/hash_node.rb +10 -3
  14. data/lib/rubocop/ast/node/if_node.rb +2 -0
  15. data/lib/rubocop/ast/node/mixin/binary_operator_node.rb +23 -0
  16. data/lib/rubocop/ast/node/mixin/predicate_operator_node.rb +35 -0
  17. data/lib/rubocop/ast/node/or_node.rb +37 -0
  18. data/lib/rubocop/ast/node/resbody_node.rb +25 -0
  19. data/lib/rubocop/ast/node/send_node.rb +190 -0
  20. data/lib/rubocop/ast/node/when_node.rb +1 -1
  21. data/lib/rubocop/ast/traversal.rb +15 -15
  22. data/lib/rubocop/comment_config.rb +1 -1
  23. data/lib/rubocop/config.rb +39 -15
  24. data/lib/rubocop/config_loader.rb +34 -13
  25. data/lib/rubocop/cop/bundler/ordered_gems.rb +23 -4
  26. data/lib/rubocop/cop/commissioner.rb +4 -0
  27. data/lib/rubocop/cop/cop.rb +5 -0
  28. data/lib/rubocop/cop/lint/ambiguous_block_association.rb +53 -0
  29. data/lib/rubocop/cop/lint/debugger.rb +8 -1
  30. data/lib/rubocop/cop/lint/def_end_alignment.rb +2 -1
  31. data/lib/rubocop/cop/lint/deprecated_class_methods.rb +2 -4
  32. data/lib/rubocop/cop/lint/duplicate_case_condition.rb +1 -1
  33. data/lib/rubocop/cop/lint/each_with_object_argument.rb +3 -1
  34. data/lib/rubocop/cop/lint/empty_ensure.rb +6 -2
  35. data/lib/rubocop/cop/lint/ensure_return.rb +1 -1
  36. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +20 -18
  37. data/lib/rubocop/cop/lint/handle_exceptions.rb +1 -3
  38. data/lib/rubocop/cop/lint/literal_in_condition.rb +1 -1
  39. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +1 -1
  40. data/lib/rubocop/cop/lint/multiple_compare.rb +5 -3
  41. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +26 -18
  42. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +7 -8
  43. data/lib/rubocop/cop/lint/require_parentheses.rb +7 -13
  44. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +7 -3
  45. data/lib/rubocop/cop/lint/shadowed_exception.rb +2 -6
  46. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +7 -8
  47. data/lib/rubocop/cop/lint/unneeded_disable.rb +35 -11
  48. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +1 -1
  49. data/lib/rubocop/cop/lint/unreachable_code.rb +5 -2
  50. data/lib/rubocop/cop/lint/unused_block_argument.rb +6 -6
  51. data/lib/rubocop/cop/lint/useless_assignment.rb +2 -1
  52. data/lib/rubocop/cop/lint/useless_comparison.rb +5 -4
  53. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  54. data/lib/rubocop/cop/message_annotator.rb +7 -3
  55. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  56. data/lib/rubocop/cop/metrics/block_nesting.rb +4 -4
  57. data/lib/rubocop/cop/metrics/cyclomatic_complexity.rb +2 -2
  58. data/lib/rubocop/cop/metrics/line_length.rb +2 -9
  59. data/lib/rubocop/cop/metrics/parameter_lists.rb +4 -3
  60. data/lib/rubocop/cop/metrics/perceived_complexity.rb +2 -2
  61. data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
  62. data/lib/rubocop/cop/mixin/array_hash_indentation.rb +2 -2
  63. data/lib/rubocop/cop/mixin/check_assignment.rb +6 -6
  64. data/lib/rubocop/cop/mixin/duplication.rb +1 -1
  65. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +1 -1
  66. data/lib/rubocop/cop/mixin/ignored_pattern.rb +27 -0
  67. data/lib/rubocop/cop/mixin/method_preference.rb +2 -0
  68. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +17 -29
  69. data/lib/rubocop/cop/mixin/on_method_def.rb +3 -3
  70. data/lib/rubocop/cop/mixin/percent_literal.rb +27 -0
  71. data/lib/rubocop/cop/mixin/rescue_node.rb +21 -0
  72. data/lib/rubocop/cop/mixin/safe_mode.rb +1 -1
  73. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +1 -1
  74. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -1
  75. data/lib/rubocop/cop/mixin/target_rails_version.rb +16 -0
  76. data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
  77. data/lib/rubocop/cop/offense.rb +3 -3
  78. data/lib/rubocop/cop/performance/casecmp.rb +1 -1
  79. data/lib/rubocop/cop/performance/detect.rb +2 -1
  80. data/lib/rubocop/cop/performance/double_start_end_with.rb +35 -1
  81. data/lib/rubocop/cop/performance/end_with.rb +3 -1
  82. data/lib/rubocop/cop/performance/flat_map.rb +6 -6
  83. data/lib/rubocop/cop/performance/lstrip_rstrip.rb +2 -2
  84. data/lib/rubocop/cop/performance/range_include.rb +3 -1
  85. data/lib/rubocop/cop/performance/redundant_match.rb +6 -5
  86. data/lib/rubocop/cop/performance/regexp_match.rb +10 -3
  87. data/lib/rubocop/cop/performance/reverse_each.rb +2 -1
  88. data/lib/rubocop/cop/performance/size.rb +6 -11
  89. data/lib/rubocop/cop/performance/start_with.rb +3 -1
  90. data/lib/rubocop/cop/performance/string_replacement.rb +13 -18
  91. data/lib/rubocop/cop/performance/times_map.rb +4 -4
  92. data/lib/rubocop/cop/rails/action_filter.rb +42 -42
  93. data/lib/rubocop/cop/rails/active_support_aliases.rb +68 -0
  94. data/lib/rubocop/cop/rails/blank.rb +131 -0
  95. data/lib/rubocop/cop/rails/date.rb +25 -28
  96. data/lib/rubocop/cop/rails/delegate_allow_blank.rb +5 -7
  97. data/lib/rubocop/cop/rails/dynamic_find_by.rb +7 -3
  98. data/lib/rubocop/cop/rails/exit.rb +9 -9
  99. data/lib/rubocop/cop/rails/file_path.rb +5 -14
  100. data/lib/rubocop/cop/rails/find_by.rb +8 -10
  101. data/lib/rubocop/cop/rails/find_each.rb +6 -9
  102. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +1 -0
  103. data/lib/rubocop/cop/rails/http_positional_arguments.rb +15 -7
  104. data/lib/rubocop/cop/rails/output.rb +3 -5
  105. data/lib/rubocop/cop/rails/output_safety.rb +4 -8
  106. data/lib/rubocop/cop/rails/pluralization_grammar.rb +25 -24
  107. data/lib/rubocop/cop/rails/present.rb +137 -0
  108. data/lib/rubocop/cop/rails/read_write_attribute.rb +9 -18
  109. data/lib/rubocop/cop/rails/relative_date_constant.rb +53 -0
  110. data/lib/rubocop/cop/rails/request_referer.rb +7 -4
  111. data/lib/rubocop/cop/rails/reversible_migration.rb +1 -2
  112. data/lib/rubocop/cop/rails/safe_navigation.rb +2 -1
  113. data/lib/rubocop/cop/rails/save_bang.rb +10 -10
  114. data/lib/rubocop/cop/rails/skips_model_validations.rb +23 -6
  115. data/lib/rubocop/cop/rails/time_zone.rb +20 -18
  116. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +3 -2
  117. data/lib/rubocop/cop/rails/validation.rb +8 -11
  118. data/lib/rubocop/cop/registry.rb +3 -3
  119. data/lib/rubocop/cop/security/json_load.rb +1 -1
  120. data/lib/rubocop/cop/security/marshal_load.rb +5 -1
  121. data/lib/rubocop/cop/security/yaml_load.rb +3 -3
  122. data/lib/rubocop/cop/severity.rb +1 -1
  123. data/lib/rubocop/cop/style/alias.rb +5 -5
  124. data/lib/rubocop/cop/style/align_hash.rb +1 -1
  125. data/lib/rubocop/cop/style/align_parameters.rb +5 -5
  126. data/lib/rubocop/cop/style/and_or.rb +16 -31
  127. data/lib/rubocop/cop/style/attr.rb +14 -8
  128. data/lib/rubocop/cop/style/auto_resource_cleanup.rb +8 -11
  129. data/lib/rubocop/cop/style/block_delimiters.rb +11 -13
  130. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +19 -23
  131. data/lib/rubocop/cop/style/case_indentation.rb +2 -0
  132. data/lib/rubocop/cop/style/class_and_module_children.rb +1 -1
  133. data/lib/rubocop/cop/style/class_check.rb +5 -7
  134. data/lib/rubocop/cop/style/closing_parenthesis_indentation.rb +5 -4
  135. data/lib/rubocop/cop/style/collection_methods.rb +8 -8
  136. data/lib/rubocop/cop/style/colon_method_call.rb +2 -9
  137. data/lib/rubocop/cop/style/conditional_assignment.rb +38 -45
  138. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  139. data/lib/rubocop/cop/style/documentation_method.rb +1 -0
  140. data/lib/rubocop/cop/style/dot_position.rb +3 -7
  141. data/lib/rubocop/cop/style/double_negation.rb +2 -1
  142. data/lib/rubocop/cop/style/each_with_object.rb +1 -1
  143. data/lib/rubocop/cop/style/empty_else.rb +2 -2
  144. data/lib/rubocop/cop/style/empty_line_after_magic_comment.rb +63 -0
  145. data/lib/rubocop/cop/style/empty_line_between_defs.rb +74 -4
  146. data/lib/rubocop/cop/style/empty_lines_around_begin_body.rb +42 -0
  147. data/lib/rubocop/cop/style/empty_lines_around_exception_handling_keywords.rb +127 -0
  148. data/lib/rubocop/cop/style/empty_literal.rb +17 -9
  149. data/lib/rubocop/cop/style/end_of_line.rb +25 -3
  150. data/lib/rubocop/cop/style/file_name.rb +1 -1
  151. data/lib/rubocop/cop/style/first_method_argument_line_break.rb +1 -1
  152. data/lib/rubocop/cop/style/first_parameter_indentation.rb +17 -19
  153. data/lib/rubocop/cop/style/for.rb +2 -4
  154. data/lib/rubocop/cop/style/format_string.rb +5 -4
  155. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +1 -1
  156. data/lib/rubocop/cop/style/identical_conditional_branches.rb +27 -1
  157. data/lib/rubocop/cop/style/if_unless_modifier.rb +2 -2
  158. data/lib/rubocop/cop/style/indent_assignment.rb +2 -2
  159. data/lib/rubocop/cop/style/indent_hash.rb +2 -1
  160. data/lib/rubocop/cop/style/indent_heredoc.rb +173 -0
  161. data/lib/rubocop/cop/style/indentation_width.rb +61 -29
  162. data/lib/rubocop/cop/style/inverse_methods.rb +130 -0
  163. data/lib/rubocop/cop/style/lambda_call.rb +15 -11
  164. data/lib/rubocop/cop/style/line_end_concatenation.rb +4 -4
  165. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +26 -14
  166. data/lib/rubocop/cop/style/method_call_without_args_parentheses.rb +6 -16
  167. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +4 -1
  168. data/lib/rubocop/cop/style/missing_else.rb +4 -3
  169. data/lib/rubocop/cop/style/mixin_grouping.rb +97 -0
  170. data/lib/rubocop/cop/style/multiline_memoization.rb +38 -5
  171. data/lib/rubocop/cop/style/multiline_method_call_brace_layout.rb +2 -3
  172. data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +38 -19
  173. data/lib/rubocop/cop/style/mutable_constant.rb +5 -1
  174. data/lib/rubocop/cop/style/negated_if.rb +73 -1
  175. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +21 -19
  176. data/lib/rubocop/cop/style/next.rb +5 -5
  177. data/lib/rubocop/cop/style/non_nil_check.rb +7 -10
  178. data/lib/rubocop/cop/style/not.rb +3 -4
  179. data/lib/rubocop/cop/style/numeric_literals.rb +25 -3
  180. data/lib/rubocop/cop/style/numeric_predicate.rb +1 -1
  181. data/lib/rubocop/cop/style/one_line_conditional.rb +2 -2
  182. data/lib/rubocop/cop/style/op_method.rb +2 -2
  183. data/lib/rubocop/cop/style/parallel_assignment.rb +6 -3
  184. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +52 -6
  185. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  186. data/lib/rubocop/cop/style/preferred_hash_methods.rb +9 -9
  187. data/lib/rubocop/cop/style/raise_args.rb +28 -24
  188. data/lib/rubocop/cop/style/redundant_freeze.rb +5 -7
  189. data/lib/rubocop/cop/style/redundant_parentheses.rb +2 -3
  190. data/lib/rubocop/cop/style/redundant_self.rb +17 -35
  191. data/lib/rubocop/cop/style/rescue_modifier.rb +2 -14
  192. data/lib/rubocop/cop/style/self_assignment.rb +3 -3
  193. data/lib/rubocop/cop/style/send.rb +4 -5
  194. data/lib/rubocop/cop/style/space_after_not.rb +7 -8
  195. data/lib/rubocop/cop/style/space_around_keyword.rb +8 -9
  196. data/lib/rubocop/cop/style/space_around_operators.rb +19 -15
  197. data/lib/rubocop/cop/style/space_before_first_arg.rb +17 -14
  198. data/lib/rubocop/cop/style/space_inside_brackets.rb +1 -1
  199. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +3 -3
  200. data/lib/rubocop/cop/style/space_inside_parens.rb +1 -1
  201. data/lib/rubocop/cop/style/special_global_vars.rb +14 -14
  202. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -1
  203. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  204. data/lib/rubocop/cop/style/string_methods.rb +10 -5
  205. data/lib/rubocop/cop/style/struct_inheritance.rb +4 -15
  206. data/lib/rubocop/cop/style/symbol_array.rb +31 -35
  207. data/lib/rubocop/cop/style/symbol_proc.rb +2 -2
  208. data/lib/rubocop/cop/style/ternary_parentheses.rb +41 -13
  209. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +6 -9
  210. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +4 -1
  211. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -1
  212. data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -2
  213. data/lib/rubocop/cop/style/unneeded_percent_q.rb +1 -1
  214. data/lib/rubocop/cop/style/word_array.rb +12 -34
  215. data/lib/rubocop/cop/style/zero_length_predicate.rb +11 -4
  216. data/lib/rubocop/cop/team.rb +4 -1
  217. data/lib/rubocop/cop/util.rb +33 -26
  218. data/lib/rubocop/cop/variable_force.rb +13 -13
  219. data/lib/rubocop/cop/variable_force/assignment.rb +1 -8
  220. data/lib/rubocop/cop/variable_force/branch.rb +318 -0
  221. data/lib/rubocop/cop/variable_force/branchable.rb +21 -0
  222. data/lib/rubocop/cop/variable_force/reference.rb +1 -3
  223. data/lib/rubocop/cop/variable_force/scope.rb +36 -20
  224. data/lib/rubocop/cop/variable_force/variable.rb +9 -8
  225. data/lib/rubocop/formatter/colorizable.rb +10 -10
  226. data/lib/rubocop/formatter/formatter_set.rb +1 -1
  227. data/lib/rubocop/formatter/html_formatter.rb +2 -1
  228. data/lib/rubocop/formatter/simple_text_formatter.rb +4 -2
  229. data/lib/rubocop/magic_comment.rb +20 -6
  230. data/lib/rubocop/options.rb +1 -1
  231. data/lib/rubocop/platform.rb +11 -0
  232. data/lib/rubocop/processed_source.rb +1 -1
  233. data/lib/rubocop/remote_config.rb +18 -6
  234. data/lib/rubocop/result_cache.rb +8 -8
  235. data/lib/rubocop/rspec/cop_helper.rb +2 -0
  236. data/lib/rubocop/rspec/shared_contexts.rb +20 -0
  237. data/lib/rubocop/rspec/shared_examples.rb +1 -1
  238. data/lib/rubocop/runner.rb +2 -2
  239. data/lib/rubocop/target_finder.rb +64 -6
  240. data/lib/rubocop/version.rb +2 -4
  241. metadata +27 -4
  242. data/lib/rubocop/cop/variable_force/locatable.rb +0 -200
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48613fc7243fce70d23fbe5d0041753273006808
4
- data.tar.gz: d3ec7b011e070b4a8c60f85abb6dc4fd406d99e3
3
+ metadata.gz: 83278e7b0db6182dca6c9c459ec501d77879da8f
4
+ data.tar.gz: f704ff6c92918ac9d981d2bc99a9cb5e8c93ae36
5
5
  SHA512:
6
- metadata.gz: e0f233291feb68a508b380875b3bde017e546003fb6e9839d91c1d205c5be2753af21c8e4f250c1723f9b5ea9190cbf07e59726d3e41e100e6e17d6f9d8b94a1
7
- data.tar.gz: 72cd29331eca9b7f356da651681a6a0e91cbb38c6c4c185a6ba2e417c218164304d853728f95e583a2438978f6218d853453ee4f682af50dfaa9ca3fb108331e
6
+ metadata.gz: 6cfa68a81c85d90199e4c334b0c067956d0a44004651622c65ff62902bd1624d06f051dab10213bce4c0f00dd7cf13db8345e938cef0444f9762bb4d33222dcb
7
+ data.tar.gz: f573cc40d97449a1b51925594c1b034ca047a1ee5cf3693851008fb4e1d5be21bae3d450296b11dfe904ec99324e6318d3e8e33271001854e3b1f161f134d94b
data/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
  [![Coverage Status](https://img.shields.io/codeclimate/coverage/github/bbatsov/rubocop.svg)](https://codeclimate.com/github/bbatsov/rubocop)
5
5
  [![Code Climate](https://codeclimate.com/github/bbatsov/rubocop/badges/gpa.svg)](https://codeclimate.com/github/bbatsov/rubocop)
6
6
  [![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
7
- [![Gratipay Team](https://img.shields.io/gratipay/team/rubocop.svg?maxAge=2592000)](https://gratipay.com/rubocop/)
8
- [![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#backers)
9
- [![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#sponsors)
10
7
 
8
+ [![Gratipay Team](https://img.shields.io/gratipay/team/rubocop.svg?maxAge=2592000)](https://gratipay.com/rubocop/)
9
+ [![OpenCollective](https://opencollective.com/rubocop/backers/badge.svg)](#open-collective-backers)
10
+ [![OpenCollective](https://opencollective.com/rubocop/sponsors/badge.svg)](#open-collective-sponsors)
11
11
 
12
12
  <p align="center">
13
13
  <img src="https://raw.githubusercontent.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
@@ -28,11 +28,7 @@ automatically fix some of the problems for you.
28
28
 
29
29
  [![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)
30
30
 
31
- You can support my work on RuboCop via
32
- [Salt](https://salt.bountysource.com/teams/rubocop) and
33
- [Gratipay](https://gratipay.com/rubocop/).
34
-
35
- [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop/)
31
+ **Please consider [supporting financially its ongoing development](#funding).**
36
32
 
37
33
  ## Installation
38
34
 
@@ -54,7 +50,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
54
50
  might want to use a conservative version locking in your `Gemfile`:
55
51
 
56
52
  ```rb
57
- gem 'rubocop', '~> 0.47.1', require: false
53
+ gem 'rubocop', '~> 0.48.0', require: false
58
54
  ```
59
55
 
60
56
  ## Quickstart
@@ -116,13 +112,30 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
116
112
  Of course, bug reports and suggestions for improvements are always
117
113
  welcome. GitHub pull requests are even better! :-)
118
114
 
119
- You can also support my work on RuboCop via
120
- [Salt](https://salt.bountysource.com/teams/rubocop) and
121
- [Gratipay](https://gratipay.com/rubocop/).
115
+ ## Funding
116
+
117
+ While RuboCop is free software and will always be, the project would benefit immensely from some funding.
118
+ Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on
119
+ certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on.
120
+ Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project
121
+ which would speed up the pace of development significantly.
122
122
 
123
- [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop/)
123
+ We welcome both individual and corporate sponsors! We also offer a
124
+ wide array of funding channels to account for your preferences
125
+ (although
126
+ currently [Open Collective](https://opencollective.com/rubocop) is our
127
+ preferred funding platform).
124
128
 
125
- ## Open Collective Backers
129
+ If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company
130
+ to become a RuboCop sponsor.
131
+
132
+ You can support the development of RuboCop via
133
+ [Salt](https://salt.bountysource.com/teams/rubocop),
134
+ [Gratipay](https://www.gratipay.com/rubocop) and [Open Collective](https://opencollective.com/rubocop).
135
+
136
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop)
137
+
138
+ ### Open Collective Backers
126
139
 
127
140
  Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/rubocop#backer)]
128
141
 
@@ -157,8 +170,7 @@ Support us with a monthly donation and help us continue our activities. [[Become
157
170
  <a href="https://opencollective.com/rubocop/backer/28/website" target="_blank"><img src="https://opencollective.com/rubocop/backer/28/avatar.svg"></a>
158
171
  <a href="https://opencollective.com/rubocop/backer/29/website" target="_blank"><img src="https://opencollective.com/rubocop/backer/29/avatar.svg"></a>
159
172
 
160
-
161
- ## Open Collective Sponsors
173
+ ### Open Collective Sponsors
162
174
 
163
175
  Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://opencollective.com/rubocop#sponsor)]
164
176
 
data/config/default.yml CHANGED
@@ -51,11 +51,17 @@ AllCops:
51
51
  # the `--only-guide-cops` option.
52
52
  StyleGuideCopsOnly: false
53
53
  # All cops except the ones in disabled.yml are enabled by default. Change
54
- # this behavior by overriding `DisabledByDefault`. When `DisabledByDefault` is
55
- # `true`, all cops in the default configuration are disabled, and only cops
56
- # in user configuration are enabled. This makes cops opt-in instead of
57
- # opt-out. Note that when `DisabledByDefault` is `true`, cops in user
58
- # configuration will be enabled even if they don't set the Enabled parameter.
54
+ # this behavior by overriding either `DisabledByDefault` or `EnabledByDefault`.
55
+ # When `DisabledByDefault` is `true`, all cops in the default configuration
56
+ # are disabled, and only cops in user configuration are enabled. This makes
57
+ # cops opt-in instead of opt-out. Note that when `DisabledByDefault` is `true`,
58
+ # cops in user configuration will be enabled even if they don't set the
59
+ # Enabled parameter.
60
+ # When `EnabledByDefault` is `true`, all cops, even those in disabled.yml,
61
+ # are enabled by default. Cops can still be disabled in user configuration.
62
+ # Note that it is invalid to set both EnabledByDefault and DisabledByDefault
63
+ # to true in the same configuration.
64
+ EnabledByDefault: false
59
65
  DisabledByDefault: false
60
66
  # Enables the result cache if `true`. Can be overridden by the `--cache` command
61
67
  # line option.
@@ -82,6 +88,7 @@ AllCops:
82
88
  # Else if .ruby-version exists and it contains an MRI version it is used.
83
89
  # Otherwise we fallback to the oldest officially supported Ruby version (2.1).
84
90
  TargetRubyVersion: ~
91
+ TargetRailsVersion: 5.0
85
92
 
86
93
  # Indent private/protected/public as deep as method definitions
87
94
  Style/AccessModifierIndentation:
@@ -420,7 +427,7 @@ Style/DotPosition:
420
427
  # Warn on empty else statements
421
428
  # empty - warn only on empty `else`
422
429
  # nil - warn on `else` with nil in it
423
- # both - warn on empty `else` and `else` with nil in it
430
+ # both - warn on empty `else` and `else` with `nil` in it
424
431
  Style/EmptyElse:
425
432
  EnforcedStyle: both
426
433
  SupportedStyles:
@@ -433,6 +440,8 @@ Style/EmptyLineBetweenDefs:
433
440
  # If `true`, this parameter means that single line method definitions don't
434
441
  # need an empty line between them.
435
442
  AllowAdjacentOneLineDefs: false
443
+ # Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
444
+ NumberOfEmptyLines: 1
436
445
 
437
446
  Style/EmptyLinesAroundBlockBody:
438
447
  EnforcedStyle: no_empty_lines
@@ -473,6 +482,16 @@ Style/Encoding:
473
482
  - never
474
483
  AutoCorrectEncodingComment: '# encoding: utf-8'
475
484
 
485
+ Style/EndOfLine:
486
+ # The `native` style means that CR+LF (Carriage Return + Line Feed) is
487
+ # enforced on Windows, and LF is enforced on other platforms. The other styles
488
+ # mean LF and CR+LF, respectively.
489
+ EnforcedStyle: native
490
+ SupportedStyles:
491
+ - native
492
+ - lf
493
+ - crlf
494
+
476
495
  Style/ExtraSpacing:
477
496
  # When true, allows most uses of extra spacing if the intent is to align
478
497
  # things with the previous or next line, not counting empty lines or comment
@@ -632,6 +651,7 @@ Style/IndentationConsistency:
632
651
  Style/IndentationWidth:
633
652
  # Number of spaces for each indentation level.
634
653
  Width: 2
654
+ IgnoredPatterns: []
635
655
 
636
656
  # Checks the indentation of the first element in an array literal.
637
657
  Style/IndentArray:
@@ -683,6 +703,37 @@ Style/IndentHash:
683
703
  # But it can be overridden by setting this parameter
684
704
  IndentationWidth: ~
685
705
 
706
+ Style/IndentHeredoc:
707
+ EnforcedStyle: auto_detection
708
+ SupportedStyles:
709
+ - auto_detection
710
+ - squiggly
711
+ - active_support
712
+ - powerpack
713
+ - unindent
714
+
715
+ Style/InverseMethods:
716
+ Enabled: true
717
+ # `InverseMethods` are methods that can be inverted by a not (`not` or `!`)
718
+ # The relationship of inverse methods only needs to be defined in one direction.
719
+ # Keys and values both need to be defined as symbols.
720
+ InverseMethods:
721
+ :any?: :none?
722
+ :even?: :odd?
723
+ :==: :!=
724
+ :=~: :!~
725
+ :<: :>=
726
+ :>: :<=
727
+ # `ActiveSupport` defines some common inverse methods. They are listed below,
728
+ # and not enabled by default.
729
+ #:present?: :blank?,
730
+ #:include?: :exclude?
731
+ # `InverseBlocks` are methods that are inverted by inverting the return
732
+ # of the block that is passed to the method
733
+ InverseBlocks:
734
+ :select: :reject
735
+ :select!: :reject!
736
+
686
737
  Style/Lambda:
687
738
  EnforcedStyle: line_count_dependent
688
739
  SupportedStyles:
@@ -702,36 +753,9 @@ Style/LambdaCall:
702
753
  - call
703
754
  - braces
704
755
 
705
- Style/Next:
706
- # With `always` all conditions at the end of an iteration needs to be
707
- # replaced by next - with `skip_modifier_ifs` the modifier if like this one
708
- # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
709
- EnforcedStyle: skip_modifier_ifs
710
- # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
711
- # needs to have to trigger this cop
712
- MinBodyLength: 3
713
- SupportedStyles:
714
- - skip_modifier_ifs
715
- - always
716
-
717
- Style/NonNilCheck:
718
- # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
719
- # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
720
- # **usually** OK, but might change behavior.
721
- #
722
- # With `IncludeSemanticChanges` set to `false`, this cop does not report
723
- # offenses for `!x.nil?` and does no changes that might change behavior.
724
- IncludeSemanticChanges: false
725
-
726
- Style/NumericPredicate:
727
- EnforcedStyle: predicate
728
- SupportedStyles:
729
- - predicate
730
- - comparison
731
- # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
732
- # false positives.
733
- Exclude:
734
- - 'spec/**/*'
756
+ Style/MethodCallWithArgsParentheses:
757
+ IgnoreMacros: true
758
+ IgnoredMethods: []
735
759
 
736
760
  Style/MethodDefParentheses:
737
761
  EnforcedStyle: require_parentheses
@@ -740,15 +764,22 @@ Style/MethodDefParentheses:
740
764
  - require_no_parentheses
741
765
  - require_no_parentheses_except_multiline
742
766
 
743
- Style/MethodCallWithArgsParentheses:
744
- IgnoredMethods: []
745
-
746
767
  Style/MethodName:
747
768
  EnforcedStyle: snake_case
748
769
  SupportedStyles:
749
770
  - snake_case
750
771
  - camelCase
751
772
 
773
+ # Checks the grouping of mixins (`include`, `extend`, `prepend`) in `class` and
774
+ # `module` bodies.
775
+ Style/MixinGrouping:
776
+ EnforcedStyle: separated
777
+ SupportedStyles:
778
+ # separated: each mixed in module goes in a separate statement.
779
+ # grouped: mixed in modules are grouped into a single statement.
780
+ - separated
781
+ - grouped
782
+
752
783
  Style/ModuleFunction:
753
784
  EnforcedStyle: module_function
754
785
  SupportedStyles:
@@ -793,6 +824,12 @@ Style/MultilineHashBraceLayout:
793
824
  - new_line
794
825
  - same_line
795
826
 
827
+ Style/MultilineMemoization:
828
+ EnforcedStyle: keyword
829
+ SupportedStyles:
830
+ - keyword
831
+ - braces
832
+
796
833
  Style/MultilineMethodCallBraceLayout:
797
834
  EnforcedStyle: symmetrical
798
835
  SupportedStyles:
@@ -832,6 +869,37 @@ Style/MultilineOperationIndentation:
832
869
  # But it can be overridden by setting this parameter
833
870
  IndentationWidth: ~
834
871
 
872
+ Style/NegatedIf:
873
+ EnforcedStyle: both
874
+ SupportedStyles:
875
+ # both: prefix and postfix negated `if` should both use `unless`
876
+ # prefix: only use `unless` for negated `if` statements positioned before the body of the statement
877
+ # postfix: only use `unless` for negated `if` statements positioned after the body of the statement
878
+ - both
879
+ - prefix
880
+ - postfix
881
+
882
+ Style/Next:
883
+ # With `always` all conditions at the end of an iteration needs to be
884
+ # replaced by next - with `skip_modifier_ifs` the modifier if like this one
885
+ # are ignored: [1, 2].each { |a| return 'yes' if a == 1 }
886
+ EnforcedStyle: skip_modifier_ifs
887
+ # `MinBodyLength` defines the number of lines of the a body of an `if` or `unless`
888
+ # needs to have to trigger this cop
889
+ MinBodyLength: 3
890
+ SupportedStyles:
891
+ - skip_modifier_ifs
892
+ - always
893
+
894
+ Style/NonNilCheck:
895
+ # With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
896
+ # `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
897
+ # **usually** OK, but might change behavior.
898
+ #
899
+ # With `IncludeSemanticChanges` set to `false`, this cop does not report
900
+ # offenses for `!x.nil?` and does no changes that might change behavior.
901
+ IncludeSemanticChanges: false
902
+
835
903
  Style/NumericLiterals:
836
904
  MinDigits: 5
837
905
 
@@ -841,6 +909,16 @@ Style/NumericLiteralPrefix:
841
909
  - zero_with_o
842
910
  - zero_only
843
911
 
912
+ Style/NumericPredicate:
913
+ EnforcedStyle: predicate
914
+ SupportedStyles:
915
+ - predicate
916
+ - comparison
917
+ # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
918
+ # false positives.
919
+ Exclude:
920
+ - 'spec/**/*'
921
+
844
922
  Style/OptionHash:
845
923
  # A list of parameter names that will be flagged by this cop.
846
924
  SuspiciousParamNames:
@@ -855,17 +933,12 @@ Style/ParenthesesAroundCondition:
855
933
  AllowSafeAssignment: true
856
934
 
857
935
  Style/PercentLiteralDelimiters:
936
+ # Specify the default preferred delimiter for all types with the 'default' key
937
+ # Override individual delimiters (even with default specified) by specifying
938
+ # an individual key
858
939
  PreferredDelimiters:
859
- '%': ()
860
- '%i': ()
861
- '%I': ()
862
- '%q': ()
863
- '%Q': ()
940
+ default: ()
864
941
  '%r': '{}'
865
- '%s': ()
866
- '%w': ()
867
- '%W': ()
868
- '%x': ()
869
942
 
870
943
  Style/PercentQLiterals:
871
944
  EnforcedStyle: lower_case_q
@@ -951,49 +1024,6 @@ Style/SingleLineBlockParams:
951
1024
  Style/SingleLineMethods:
952
1025
  AllowIfMethodIsEmpty: true
953
1026
 
954
- Style/SpaceBeforeFirstArg:
955
- # When `true`, allows most uses of extra spacing if the intent is to align
956
- # things with the previous or next line, not counting empty lines or comment
957
- # lines.
958
- AllowForAlignment: true
959
-
960
- Style/SpecialGlobalVars:
961
- EnforcedStyle: use_english_names
962
- SupportedStyles:
963
- - use_perl_names
964
- - use_english_names
965
-
966
- Style/StabbyLambdaParentheses:
967
- EnforcedStyle: require_parentheses
968
- SupportedStyles:
969
- - require_parentheses
970
- - require_no_parentheses
971
-
972
- Style/StringLiterals:
973
- EnforcedStyle: single_quotes
974
- SupportedStyles:
975
- - single_quotes
976
- - double_quotes
977
- # If `true`, strings which span multiple lines using `\` for continuation must
978
- # use the same type of quotes on each line.
979
- ConsistentQuotesInMultiline: false
980
-
981
- Style/StringLiteralsInInterpolation:
982
- EnforcedStyle: single_quotes
983
- SupportedStyles:
984
- - single_quotes
985
- - double_quotes
986
-
987
- Style/StringMethods:
988
- # Mapping from undesired method to desired_method
989
- # e.g. to use `to_sym` over `intern`:
990
- #
991
- # StringMethods:
992
- # PreferredMethods:
993
- # intern: to_sym
994
- PreferredMethods:
995
- intern: to_sym
996
-
997
1027
  Style/SpaceAroundBlockParameters:
998
1028
  EnforcedStyleInsidePipes: no_space
999
1029
  SupportedStylesInsidePipes:
@@ -1018,6 +1048,12 @@ Style/SpaceBeforeBlockBraces:
1018
1048
  - space
1019
1049
  - no_space
1020
1050
 
1051
+ Style/SpaceBeforeFirstArg:
1052
+ # When `true`, allows most uses of extra spacing if the intent is to align
1053
+ # things with the previous or next line, not counting empty lines or comment
1054
+ # lines.
1055
+ AllowForAlignment: true
1056
+
1021
1057
  Style/SpaceInsideBlockBraces:
1022
1058
  EnforcedStyle: space
1023
1059
  SupportedStyles:
@@ -1027,7 +1063,7 @@ Style/SpaceInsideBlockBraces:
1027
1063
  SupportedStylesForEmptyBraces:
1028
1064
  - space
1029
1065
  - no_space
1030
- # Space between { and |. Overrides EnforcedStyle if there is a conflict.
1066
+ # Space between `{` and `|`. Overrides `EnforcedStyle` if there is a conflict.
1031
1067
  SpaceBeforeBlockParameters: true
1032
1068
 
1033
1069
  Style/SpaceInsideHashLiteralBraces:
@@ -1049,6 +1085,43 @@ Style/SpaceInsideStringInterpolation:
1049
1085
  - space
1050
1086
  - no_space
1051
1087
 
1088
+ Style/SpecialGlobalVars:
1089
+ EnforcedStyle: use_english_names
1090
+ SupportedStyles:
1091
+ - use_perl_names
1092
+ - use_english_names
1093
+
1094
+ Style/StabbyLambdaParentheses:
1095
+ EnforcedStyle: require_parentheses
1096
+ SupportedStyles:
1097
+ - require_parentheses
1098
+ - require_no_parentheses
1099
+
1100
+ Style/StringLiterals:
1101
+ EnforcedStyle: single_quotes
1102
+ SupportedStyles:
1103
+ - single_quotes
1104
+ - double_quotes
1105
+ # If `true`, strings which span multiple lines using `\` for continuation must
1106
+ # use the same type of quotes on each line.
1107
+ ConsistentQuotesInMultiline: false
1108
+
1109
+ Style/StringLiteralsInInterpolation:
1110
+ EnforcedStyle: single_quotes
1111
+ SupportedStyles:
1112
+ - single_quotes
1113
+ - double_quotes
1114
+
1115
+ Style/StringMethods:
1116
+ # Mapping from undesired method to desired_method
1117
+ # e.g. to use `to_sym` over `intern`:
1118
+ #
1119
+ # StringMethods:
1120
+ # PreferredMethods:
1121
+ # intern: to_sym
1122
+ PreferredMethods:
1123
+ intern: to_sym
1124
+
1052
1125
  Style/SymbolArray:
1053
1126
  EnforcedStyle: percent
1054
1127
  SupportedStyles:
@@ -1098,7 +1171,7 @@ Style/TrailingCommaInLiteral:
1098
1171
  - consistent_comma
1099
1172
  - no_comma
1100
1173
 
1101
- # TrivialAccessors requires exact name matches and doesn't allow
1174
+ # `TrivialAccessors` requires exact name matches and doesn't allow
1102
1175
  # predicated methods by default.
1103
1176
  Style/TrivialAccessors:
1104
1177
  # When set to `false` the cop will suggest the use of accessor methods
@@ -1171,13 +1244,18 @@ Style/WordArray:
1171
1244
  # The regular expression `WordRegex` decides what is considered a word.
1172
1245
  WordRegex: !ruby/regexp '/\A[\p{Word}\n\t]+\z/'
1173
1246
 
1174
- ##################### Metrics ##################################
1247
+ #################### Metrics ###############################
1175
1248
 
1176
1249
  Metrics/AbcSize:
1177
1250
  # The ABC size is a calculated magnitude, so this number can be an Integer or
1178
1251
  # a Float.
1179
1252
  Max: 15
1180
1253
 
1254
+ Metrics/BlockLength:
1255
+ CountComments: false # count full line comments?
1256
+ Max: 25
1257
+ ExcludedMethods: []
1258
+
1181
1259
  Metrics/BlockNesting:
1182
1260
  CountBlocks: false
1183
1261
  Max: 3
@@ -1186,10 +1264,6 @@ Metrics/ClassLength:
1186
1264
  CountComments: false # count full line comments?
1187
1265
  Max: 100
1188
1266
 
1189
- Metrics/ModuleLength:
1190
- CountComments: false # count full line comments?
1191
- Max: 100
1192
-
1193
1267
  # Avoid complex methods.
1194
1268
  Metrics/CyclomaticComplexity:
1195
1269
  Max: 6
@@ -1215,10 +1289,9 @@ Metrics/MethodLength:
1215
1289
  CountComments: false # count full line comments?
1216
1290
  Max: 10
1217
1291
 
1218
- Metrics/BlockLength:
1292
+ Metrics/ModuleLength:
1219
1293
  CountComments: false # count full line comments?
1220
- Max: 25
1221
- ExcludedMethods: []
1294
+ Max: 100
1222
1295
 
1223
1296
  Metrics/ParameterLists:
1224
1297
  Max: 5
@@ -1227,7 +1300,7 @@ Metrics/ParameterLists:
1227
1300
  Metrics/PerceivedComplexity:
1228
1301
  Max: 7
1229
1302
 
1230
- ##################### Lint ##################################
1303
+ #################### Lint ##################################
1231
1304
 
1232
1305
  # Allow safe assignment in conditions.
1233
1306
  Lint/AssignmentInCondition:
@@ -1246,6 +1319,17 @@ Lint/BlockAlignment:
1246
1319
  - start_of_block
1247
1320
  - start_of_line
1248
1321
 
1322
+ Lint/DefEndAlignment:
1323
+ # The value `def` means that `end` should be aligned with the def keyword.
1324
+ # The value `start_of_line` means that `end` should be aligned with method
1325
+ # calls like `private`, `public`, etc, if present in front of the `def`
1326
+ # keyword on the same line.
1327
+ EnforcedStyleAlignWith: start_of_line
1328
+ SupportedStylesAlignWith:
1329
+ - start_of_line
1330
+ - def
1331
+ AutoCorrect: false
1332
+
1249
1333
  # Align ends correctly.
1250
1334
  Lint/EndAlignment:
1251
1335
  # The value `keyword` means that `end` should be aligned with the matching
@@ -1262,17 +1346,6 @@ Lint/EndAlignment:
1262
1346
  - start_of_line
1263
1347
  AutoCorrect: false
1264
1348
 
1265
- Lint/DefEndAlignment:
1266
- # The value `def` means that `end` should be aligned with the def keyword.
1267
- # The value `start_of_line` means that `end` should be aligned with method
1268
- # calls like `private`, `public`, etc, if present in front of the `def`
1269
- # keyword on the same line.
1270
- EnforcedStyleAlignWith: start_of_line
1271
- SupportedStylesAlignWith:
1272
- - start_of_line
1273
- - def
1274
- AutoCorrect: false
1275
-
1276
1349
  Lint/InheritException:
1277
1350
  # The default base class in favour of `Exception`.
1278
1351
  EnforcedStyle: runtime_error
@@ -1280,6 +1353,13 @@ Lint/InheritException:
1280
1353
  - runtime_error
1281
1354
  - standard_error
1282
1355
 
1356
+ Lint/SafeNavigationChain:
1357
+ Whitelist:
1358
+ - present?
1359
+ - blank?
1360
+ - presence
1361
+ - try
1362
+
1283
1363
  # Checks for unused block arguments
1284
1364
  Lint/UnusedBlockArgument:
1285
1365
  IgnoreEmptyBlocks: true
@@ -1290,13 +1370,18 @@ Lint/UnusedMethodArgument:
1290
1370
  AllowUnusedKeywordArguments: false
1291
1371
  IgnoreEmptyMethods: true
1292
1372
 
1293
- ##################### Performance ############################
1373
+ #################### Performance ###########################
1374
+
1375
+ Performance/DoubleStartEndWith:
1376
+ # Used to check for `starts_with?` and `ends_with?`.
1377
+ # These methods are defined by `ActiveSupport`.
1378
+ IncludeActiveSupportAliases: false
1294
1379
 
1295
1380
  Performance/RedundantMerge:
1296
1381
  # Max number of key-value pairs to consider an offense
1297
1382
  MaxKeyValuePairs: 2
1298
1383
 
1299
- ##################### Rails ##################################
1384
+ #################### Rails #################################
1300
1385
 
1301
1386
  Rails/ActionFilter:
1302
1387
  EnforcedStyle: action
@@ -1413,3 +1498,6 @@ Rails/SkipsModelValidations:
1413
1498
  Rails/Validation:
1414
1499
  Include:
1415
1500
  - app/models/**/*.rb
1501
+
1502
+ Bundler/OrderedGems:
1503
+ TreatCommentsAsGroupSeparators: true