rubocop 0.42.0 → 0.43.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 (221) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/output.html.erb +21 -10
  4. data/config/default.yml +32 -2
  5. data/config/disabled.yml +8 -1
  6. data/config/enabled.yml +40 -12
  7. data/lib/rubocop.rb +14 -2
  8. data/lib/rubocop/ast_node.rb +2 -0
  9. data/lib/rubocop/cached_data.rb +13 -11
  10. data/lib/rubocop/cli.rb +5 -5
  11. data/lib/rubocop/config.rb +68 -24
  12. data/lib/rubocop/config_loader.rb +13 -11
  13. data/lib/rubocop/config_loader_resolver.rb +4 -2
  14. data/lib/rubocop/cop/cop.rb +16 -5
  15. data/lib/rubocop/cop/lint/assignment_in_condition.rb +21 -20
  16. data/lib/rubocop/cop/lint/block_alignment.rb +3 -4
  17. data/lib/rubocop/cop/lint/def_end_alignment.rb +2 -3
  18. data/lib/rubocop/cop/lint/duplicate_methods.rb +16 -6
  19. data/lib/rubocop/cop/lint/else_layout.rb +1 -1
  20. data/lib/rubocop/cop/lint/empty_interpolation.rb +1 -1
  21. data/lib/rubocop/cop/lint/end_alignment.rb +4 -6
  22. data/lib/rubocop/cop/lint/eval.rb +1 -1
  23. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +1 -1
  24. data/lib/rubocop/cop/lint/ineffective_access_modifier.rb +8 -8
  25. data/lib/rubocop/cop/lint/inherit_exception.rb +22 -7
  26. data/lib/rubocop/cop/lint/literal_in_condition.rb +5 -5
  27. data/lib/rubocop/cop/lint/literal_in_interpolation.rb +3 -5
  28. data/lib/rubocop/cop/lint/next_without_accumulator.rb +1 -1
  29. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +9 -8
  30. data/lib/rubocop/cop/lint/percent_string_array.rb +17 -6
  31. data/lib/rubocop/cop/lint/percent_symbol_array.rb +4 -4
  32. data/lib/rubocop/cop/lint/rand_one.rb +3 -3
  33. data/lib/rubocop/cop/lint/require_parentheses.rb +1 -3
  34. data/lib/rubocop/cop/lint/shadowed_exception.rb +39 -44
  35. data/lib/rubocop/cop/lint/string_conversion_in_interpolation.rb +2 -2
  36. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +1 -2
  37. data/lib/rubocop/cop/lint/unified_integer.rb +38 -0
  38. data/lib/rubocop/cop/lint/unneeded_disable.rb +51 -38
  39. data/lib/rubocop/cop/lint/unneeded_splat_expansion.rb +114 -0
  40. data/lib/rubocop/cop/lint/useless_assignment.rb +25 -12
  41. data/lib/rubocop/cop/lint/useless_setter_call.rb +27 -28
  42. data/lib/rubocop/cop/lint/void.rb +2 -4
  43. data/lib/rubocop/cop/mixin/access_modifier_node.rb +5 -5
  44. data/lib/rubocop/cop/mixin/array_hash_indentation.rb +19 -17
  45. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +3 -5
  46. data/lib/rubocop/cop/mixin/configurable_naming.rb +4 -5
  47. data/lib/rubocop/cop/mixin/configurable_numbering.rb +52 -0
  48. data/lib/rubocop/cop/mixin/def_node.rb +28 -0
  49. data/lib/rubocop/cop/mixin/documentation_comment.rb +41 -0
  50. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +18 -13
  51. data/lib/rubocop/cop/mixin/if_node.rb +6 -0
  52. data/lib/rubocop/cop/mixin/match_range.rb +2 -5
  53. data/lib/rubocop/cop/mixin/multiline_expression_indentation.rb +2 -2
  54. data/lib/rubocop/cop/mixin/multiline_literal_brace_layout.rb +40 -28
  55. data/lib/rubocop/cop/mixin/negative_conditional.rb +6 -6
  56. data/lib/rubocop/cop/mixin/percent_literal.rb +1 -5
  57. data/lib/rubocop/cop/mixin/preceding_following_alignment.rb +14 -4
  58. data/lib/rubocop/cop/mixin/safe_mode.rb +23 -0
  59. data/lib/rubocop/cop/mixin/space_before_punctuation.rb +2 -4
  60. data/lib/rubocop/cop/mixin/space_inside.rb +1 -3
  61. data/lib/rubocop/cop/mixin/statement_modifier.rb +30 -20
  62. data/lib/rubocop/cop/mixin/trailing_comma.rb +19 -17
  63. data/lib/rubocop/cop/performance/case_when_splat.rb +16 -41
  64. data/lib/rubocop/cop/performance/casecmp.rb +28 -16
  65. data/lib/rubocop/cop/performance/count.rb +58 -34
  66. data/lib/rubocop/cop/performance/detect.rb +3 -7
  67. data/lib/rubocop/cop/performance/double_start_end_with.rb +17 -13
  68. data/lib/rubocop/cop/performance/fixed_size.rb +19 -14
  69. data/lib/rubocop/cop/performance/flat_map.rb +16 -9
  70. data/lib/rubocop/cop/performance/hash_each.rb +2 -3
  71. data/lib/rubocop/cop/performance/lstrip_rstrip.rb +4 -6
  72. data/lib/rubocop/cop/performance/redundant_match.rb +4 -1
  73. data/lib/rubocop/cop/performance/redundant_merge.rb +63 -32
  74. data/lib/rubocop/cop/performance/redundant_sort_by.rb +8 -7
  75. data/lib/rubocop/cop/performance/reverse_each.rb +1 -4
  76. data/lib/rubocop/cop/performance/size.rb +21 -8
  77. data/lib/rubocop/cop/performance/sort_with_block.rb +54 -0
  78. data/lib/rubocop/cop/performance/string_replacement.rb +3 -7
  79. data/lib/rubocop/cop/rails/delegate.rb +2 -3
  80. data/lib/rubocop/cop/rails/find_by.rb +4 -8
  81. data/lib/rubocop/cop/rails/not_null_column.rb +45 -0
  82. data/lib/rubocop/cop/rails/request_referer.rb +3 -3
  83. data/lib/rubocop/cop/rails/safe_navigation.rb +89 -0
  84. data/lib/rubocop/cop/rails/save_bang.rb +78 -9
  85. data/lib/rubocop/cop/rails/scope_args.rb +3 -1
  86. data/lib/rubocop/cop/rails/uniq_before_pluck.rb +2 -3
  87. data/lib/rubocop/cop/rails/validation.rb +1 -1
  88. data/lib/rubocop/cop/security/json_load.rb +36 -0
  89. data/lib/rubocop/cop/style/alias.rb +1 -1
  90. data/lib/rubocop/cop/style/align_hash.rb +25 -14
  91. data/lib/rubocop/cop/style/and_or.rb +13 -3
  92. data/lib/rubocop/cop/style/array_join.rb +3 -3
  93. data/lib/rubocop/cop/style/ascii_comments.rb +1 -2
  94. data/lib/rubocop/cop/style/ascii_identifiers.rb +1 -2
  95. data/lib/rubocop/cop/style/attr.rb +1 -3
  96. data/lib/rubocop/cop/style/block_comments.rb +2 -6
  97. data/lib/rubocop/cop/style/block_delimiters.rb +35 -21
  98. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +4 -4
  99. data/lib/rubocop/cop/style/case_indentation.rb +1 -3
  100. data/lib/rubocop/cop/style/class_methods.rb +3 -4
  101. data/lib/rubocop/cop/style/collection_methods.rb +1 -1
  102. data/lib/rubocop/cop/style/command_literal.rb +15 -8
  103. data/lib/rubocop/cop/style/comment_annotation.rb +1 -2
  104. data/lib/rubocop/cop/style/conditional_assignment.rb +68 -36
  105. data/lib/rubocop/cop/style/copyright.rb +1 -5
  106. data/lib/rubocop/cop/style/def_with_parentheses.rb +3 -5
  107. data/lib/rubocop/cop/style/documentation.rb +28 -56
  108. data/lib/rubocop/cop/style/documentation_method.rb +80 -0
  109. data/lib/rubocop/cop/style/each_for_simple_loop.rb +6 -5
  110. data/lib/rubocop/cop/style/each_with_object.rb +2 -2
  111. data/lib/rubocop/cop/style/else_alignment.rb +10 -9
  112. data/lib/rubocop/cop/style/empty_case_condition.rb +2 -4
  113. data/lib/rubocop/cop/style/empty_else.rb +1 -4
  114. data/lib/rubocop/cop/style/empty_line_between_defs.rb +1 -3
  115. data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +2 -5
  116. data/lib/rubocop/cop/style/encoding.rb +28 -14
  117. data/lib/rubocop/cop/style/even_odd.rb +28 -17
  118. data/lib/rubocop/cop/style/extra_spacing.rb +36 -25
  119. data/lib/rubocop/cop/style/file_name.rb +19 -10
  120. data/lib/rubocop/cop/style/first_parameter_indentation.rb +2 -3
  121. data/lib/rubocop/cop/style/for.rb +12 -8
  122. data/lib/rubocop/cop/style/format_string.rb +1 -1
  123. data/lib/rubocop/cop/style/guard_clause.rb +22 -56
  124. data/lib/rubocop/cop/style/hash_syntax.rb +72 -7
  125. data/lib/rubocop/cop/style/if_unless_modifier.rb +23 -19
  126. data/lib/rubocop/cop/style/if_unless_modifier_of_if_unless.rb +3 -3
  127. data/lib/rubocop/cop/style/indentation_width.rb +30 -16
  128. data/lib/rubocop/cop/style/infinite_loop.rb +16 -13
  129. data/lib/rubocop/cop/style/initial_indentation.rb +23 -18
  130. data/lib/rubocop/cop/style/inline_comment.rb +16 -3
  131. data/lib/rubocop/cop/style/lambda.rb +22 -10
  132. data/lib/rubocop/cop/style/leading_comment_space.rb +12 -1
  133. data/lib/rubocop/cop/style/line_end_concatenation.rb +24 -6
  134. data/lib/rubocop/cop/style/method_call_parentheses.rb +18 -9
  135. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +3 -4
  136. data/lib/rubocop/cop/style/method_def_parentheses.rb +3 -4
  137. data/lib/rubocop/cop/style/method_missing.rb +10 -2
  138. data/lib/rubocop/cop/style/module_function.rb +14 -6
  139. data/lib/rubocop/cop/style/multiline_assignment_layout.rb +2 -5
  140. data/lib/rubocop/cop/style/multiline_block_chain.rb +3 -5
  141. data/lib/rubocop/cop/style/multiline_block_layout.rb +22 -15
  142. data/lib/rubocop/cop/style/multiline_method_call_brace_layout.rb +9 -0
  143. data/lib/rubocop/cop/style/multiline_method_call_indentation.rb +41 -20
  144. data/lib/rubocop/cop/style/multiline_operation_indentation.rb +6 -6
  145. data/lib/rubocop/cop/style/multiline_ternary_operator.rb +3 -5
  146. data/lib/rubocop/cop/style/mutable_constant.rb +21 -13
  147. data/lib/rubocop/cop/style/negated_if.rb +1 -1
  148. data/lib/rubocop/cop/style/negated_while.rb +3 -3
  149. data/lib/rubocop/cop/style/nested_modifier.rb +2 -4
  150. data/lib/rubocop/cop/style/next.rb +4 -4
  151. data/lib/rubocop/cop/style/non_nil_check.rb +18 -10
  152. data/lib/rubocop/cop/style/numeric_literal_prefix.rb +8 -0
  153. data/lib/rubocop/cop/style/numeric_predicate.rb +9 -9
  154. data/lib/rubocop/cop/style/one_line_conditional.rb +11 -1
  155. data/lib/rubocop/cop/style/op_method.rb +1 -1
  156. data/lib/rubocop/cop/style/option_hash.rb +8 -8
  157. data/lib/rubocop/cop/style/optional_arguments.rb +21 -8
  158. data/lib/rubocop/cop/style/parallel_assignment.rb +51 -35
  159. data/lib/rubocop/cop/style/parentheses_around_condition.rb +2 -2
  160. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +1 -1
  161. data/lib/rubocop/cop/style/raise_args.rb +2 -2
  162. data/lib/rubocop/cop/style/redundant_begin.rb +1 -1
  163. data/lib/rubocop/cop/style/redundant_parentheses.rb +26 -15
  164. data/lib/rubocop/cop/style/redundant_return.rb +5 -5
  165. data/lib/rubocop/cop/style/redundant_self.rb +20 -11
  166. data/lib/rubocop/cop/style/regexp_literal.rb +16 -10
  167. data/lib/rubocop/cop/style/rescue_ensure_alignment.rb +8 -6
  168. data/lib/rubocop/cop/style/safe_navigation.rb +125 -0
  169. data/lib/rubocop/cop/style/self_assignment.rb +2 -2
  170. data/lib/rubocop/cop/style/semicolon.rb +9 -10
  171. data/lib/rubocop/cop/style/signal_exception.rb +2 -4
  172. data/lib/rubocop/cop/style/single_line_block_params.rb +1 -1
  173. data/lib/rubocop/cop/style/single_line_methods.rb +18 -11
  174. data/lib/rubocop/cop/style/space_after_method_name.rb +2 -3
  175. data/lib/rubocop/cop/style/space_after_not.rb +4 -6
  176. data/lib/rubocop/cop/style/space_around_block_parameters.rb +1 -2
  177. data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +1 -3
  178. data/lib/rubocop/cop/style/space_around_operators.rb +21 -16
  179. data/lib/rubocop/cop/style/space_before_block_braces.rb +2 -12
  180. data/lib/rubocop/cop/style/space_before_first_arg.rb +1 -3
  181. data/lib/rubocop/cop/style/space_inside_array_percent_literal.rb +1 -1
  182. data/lib/rubocop/cop/style/space_inside_block_braces.rb +33 -40
  183. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +38 -23
  184. data/lib/rubocop/cop/style/space_inside_percent_literal_delimiters.rb +1 -1
  185. data/lib/rubocop/cop/style/space_inside_string_interpolation.rb +26 -12
  186. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +2 -4
  187. data/lib/rubocop/cop/style/symbol_array.rb +10 -10
  188. data/lib/rubocop/cop/style/symbol_proc.rb +28 -13
  189. data/lib/rubocop/cop/style/ternary_parentheses.rb +35 -5
  190. data/lib/rubocop/cop/style/trailing_blank_lines.rb +2 -4
  191. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +29 -17
  192. data/lib/rubocop/cop/style/trivial_accessors.rb +6 -6
  193. data/lib/rubocop/cop/style/unless_else.rb +2 -6
  194. data/lib/rubocop/cop/style/unneeded_capital_w.rb +8 -4
  195. data/lib/rubocop/cop/style/unneeded_interpolation.rb +4 -5
  196. data/lib/rubocop/cop/style/unneeded_percent_q.rb +13 -7
  197. data/lib/rubocop/cop/style/variable_number.rb +79 -0
  198. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  199. data/lib/rubocop/cop/style/word_array.rb +25 -15
  200. data/lib/rubocop/cop/style/zero_length_predicate.rb +2 -0
  201. data/lib/rubocop/cop/util.rb +23 -4
  202. data/lib/rubocop/cop/variable_force.rb +59 -25
  203. data/lib/rubocop/cop/variable_force/locatable.rb +8 -6
  204. data/lib/rubocop/cop/variable_force/variable.rb +2 -2
  205. data/lib/rubocop/cop/variable_force/variable_table.rb +3 -3
  206. data/lib/rubocop/formatter/disabled_config_formatter.rb +16 -11
  207. data/lib/rubocop/formatter/formatter_set.rb +12 -10
  208. data/lib/rubocop/formatter/worst_offenders_formatter.rb +4 -4
  209. data/lib/rubocop/node_pattern.rb +79 -35
  210. data/lib/rubocop/options.rb +4 -4
  211. data/lib/rubocop/processed_source.rb +9 -5
  212. data/lib/rubocop/remote_config.rb +14 -10
  213. data/lib/rubocop/result_cache.rb +14 -6
  214. data/lib/rubocop/runner.rb +55 -34
  215. data/lib/rubocop/string_util.rb +9 -5
  216. data/lib/rubocop/target_finder.rb +1 -1
  217. data/lib/rubocop/token.rb +1 -1
  218. data/lib/rubocop/version.rb +1 -1
  219. metadata +15 -4
  220. data/lib/rubocop/cop/lint/useless_array_splat.rb +0 -56
  221. data/lib/rubocop/cop/performance/push_splat.rb +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a32da91af2bcd18b8deee4673be9daf3a5783d2
4
- data.tar.gz: 8d6c1b8a6624ccdaa5014ac08c18b2483768386c
3
+ metadata.gz: 5a3cab88e12da31681ef92d0b6f51398cf80b923
4
+ data.tar.gz: 1e86c53747471bba3288f3c50d58c5ff00cd6e8d
5
5
  SHA512:
6
- metadata.gz: 0a5deb237bbedb201eabcfc8923d488bd44c11e151371cc467f8ac8678c8f04fb48fddd4d721dd0cc147a01006916bd554a333d755114f9ea665be61beaef557
7
- data.tar.gz: 7adc5a8bc59f5fecc727ebe5e60ebdc0c87072636294d91a701263e77ac9a785a471469d1bd0d035d10dd5cefbfd7fcb4d506a5cd9c240b193591200c8af4cbe
6
+ metadata.gz: 16e14107016b4b1317715a5fa4aaf69292f3ba3b58f24f894b8967fd8e8e9762070c7a589b1ca887bdb1f82c631f8b5f240cc2e57c4e580e08ce83813abf9907
7
+ data.tar.gz: 6629b87681d63b954c4e24f23a44bf16226a8aa1222be8320cd09b750340416b95f0654c121bfda5867b4ad4fe69bb5996af63e86a84632bdf21055ea8e649b1
data/README.md CHANGED
@@ -51,7 +51,7 @@ haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you
51
51
  might want to use a conservative version locking in your `Gemfile`:
52
52
 
53
53
  ```rb
54
- gem 'rubocop', '~> 0.42.0', require: false
54
+ gem 'rubocop', '~> 0.43.0', require: false
55
55
  ```
56
56
 
57
57
  ## Quickstart
@@ -70,14 +70,13 @@
70
70
  line-height: 2.2rem;
71
71
  margin: 0 0 0.5em;
72
72
  }
73
- .information .infobox ul {
74
- list-style: none;
75
- margin: 0;
76
- padding: 0;
77
- }
78
- .information .infobox ul li {
73
+ .information .offenses-list li {
79
74
  line-height: 1.8rem
80
75
  }
76
+ .information .offenses-list {
77
+ padding-left: 20px;
78
+ margin-bottom: 0;
79
+ }
81
80
 
82
81
  #offenses .offense-box {
83
82
  border-radius: 4px;
@@ -191,7 +190,7 @@
191
190
  idx,
192
191
  scrollY = window.scrollY;
193
192
  for (i = 0; i < boxPositions.length; i++) {
194
- if (scrollY <= boxPositions[i]) {
193
+ if (scrollY <= boxPositions[i] - 1) {
195
194
  idx = i;
196
195
  break;
197
196
  }
@@ -214,14 +213,26 @@
214
213
  </div>
215
214
  <div class="information">
216
215
  <div class="infobox">
217
- <%= pluralize(files.count, 'file') %> inspected,
218
- <%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected
216
+ <div class="total">
217
+ <%= pluralize(files.count, 'file') %> inspected,
218
+ <%= pluralize(summary.offense_count, 'offense', no_for_zero: true) %> detected:
219
+ </div>
220
+ <ul class="offenses-list">
221
+ <% files.each do |file| %>
222
+ <% next if file.offenses.none? %>
223
+ <li>
224
+ <a href="#offense_<%= relative_path(file.path) %>">
225
+ <%= relative_path(file.path) %> - <%= pluralize(file.offenses.count, 'offense') %>
226
+ </a>
227
+ </li>
228
+ <% end %>
229
+ </ul>
219
230
  </div>
220
231
  </div>
221
232
  <div id="offenses">
222
233
  <% files.each do |file| %>
223
234
  <% if file.offenses.any? %>
224
- <div class="offense-box">
235
+ <div class="offense-box" id="offense_<%= relative_path(file.path) %>">
225
236
  <div class="box-title-placeholder"><h3>&nbsp;</h3></div>
226
237
  <div class="box-title"><h3><%= relative_path(file.path) %> - <%= pluralize(file.offenses.count, 'offense') %></h3></div>
227
238
  <div class="offense-reports">
data/config/default.yml CHANGED
@@ -395,6 +395,9 @@ Style/Copyright:
395
395
  Notice: '^Copyright (\(c\) )?2[0-9]{3} .+'
396
396
  AutocorrectNotice: ''
397
397
 
398
+ Style/DocumentationMethod:
399
+ RequireForNonPublicMethods: false
400
+
398
401
  # Multi-line method chaining should be done with leading dots.
399
402
  Style/DotPosition:
400
403
  EnforcedStyle: leading
@@ -532,9 +535,14 @@ Style/GuardClause:
532
535
  Style/HashSyntax:
533
536
  EnforcedStyle: ruby19
534
537
  SupportedStyles:
538
+ # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
535
539
  - ruby19
536
- - ruby19_no_mixed_keys
540
+ # checks for hash rocket syntax for all hashes
537
541
  - hash_rockets
542
+ # forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
543
+ - no_mixed_keys
544
+ # enforces both ruby19 and no_mixed_keys styles
545
+ - ruby19_no_mixed_keys
538
546
  # Force hashes that have a symbol value to use hash rockets
539
547
  UseHashRocketsWithSymbolValues: false
540
548
  # Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
@@ -648,6 +656,10 @@ Style/NumericPredicate:
648
656
  SupportedStyles:
649
657
  - predicate
650
658
  - comparison
659
+ # Exclude RSpec specs because assertions like `expect(1).to be > 0` cause
660
+ # false positives.
661
+ Exclude:
662
+ - 'spec/**/*'
651
663
 
652
664
  Style/MethodDefParentheses:
653
665
  EnforcedStyle: require_parentheses
@@ -1041,6 +1053,13 @@ Style/VariableName:
1041
1053
  - snake_case
1042
1054
  - camelCase
1043
1055
 
1056
+ Style/VariableNumber:
1057
+ EnforcedStyle: normalcase
1058
+ SupportedStyles:
1059
+ - snake_case
1060
+ - normalcase
1061
+ - non_integer
1062
+
1044
1063
  Style/WhileUntilModifier:
1045
1064
  MaxLineLength: 80
1046
1065
 
@@ -1062,7 +1081,7 @@ Style/WordArray:
1062
1081
  ##################### Metrics ##################################
1063
1082
 
1064
1083
  Metrics/AbcSize:
1065
- # The ABC size is a calculated magnitude, so this number can be a Fixnum or
1084
+ # The ABC size is a calculated magnitude, so this number can be an Integer or
1066
1085
  # a Float.
1067
1086
  Max: 15
1068
1087
 
@@ -1212,6 +1231,10 @@ Rails/HasAndBelongsToMany:
1212
1231
  Include:
1213
1232
  - app/models/**/*.rb
1214
1233
 
1234
+ Rails/NotNullColumn:
1235
+ Include:
1236
+ - db/migrate/*.rb
1237
+
1215
1238
  Rails/Output:
1216
1239
  Include:
1217
1240
  - app/**/*.rb
@@ -1229,6 +1252,13 @@ Rails/RequestReferer:
1229
1252
  - referer
1230
1253
  - referrer
1231
1254
 
1255
+ Rails/SafeNavigation:
1256
+ # This will convert usages of `try` to use safe navigation as well as `try!`.
1257
+ # `try` and `try!` work slighly differently. `try!` and safe navigation will
1258
+ # both raise a `NoMethodError` if the receiver of the method call does not
1259
+ # implement the intended method. `try` will not raise an exception for this.
1260
+ ConvertTry: false
1261
+
1232
1262
  Rails/ScopeArgs:
1233
1263
  Include:
1234
1264
  - app/models/**/*.rb
data/config/disabled.yml CHANGED
@@ -23,6 +23,13 @@ Style/Copyright:
23
23
  Description: 'Include a copyright notice in each file before any code.'
24
24
  Enabled: false
25
25
 
26
+ Style/DocumentationMethod:
27
+ Description: 'Public methods.'
28
+ Enabled: false
29
+ Exclude:
30
+ - 'spec/**/*'
31
+ - 'test/**/*'
32
+
26
33
  Style/Encoding:
27
34
  Description: 'Use UTF-8 as the source file encoding.'
28
35
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#utf-8'
@@ -59,7 +66,7 @@ Style/ImplicitRuntimeError:
59
66
  Enabled: false
60
67
 
61
68
  Style/InlineComment:
62
- Description: 'Avoid inline comments.'
69
+ Description: 'Avoid trailing inline comments.'
63
70
  Enabled: false
64
71
 
65
72
  Style/MethodCalledOnDoEndBlock:
data/config/enabled.yml CHANGED
@@ -260,7 +260,7 @@ Style/EndOfLine:
260
260
  Enabled: true
261
261
 
262
262
  Style/EvenOdd:
263
- Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
263
+ Description: 'Favor the use of Integer#even? && Integer#odd?'
264
264
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
265
265
  Enabled: true
266
266
 
@@ -402,7 +402,7 @@ Style/LineEndConcatenation:
402
402
 
403
403
  Style/MethodCallParentheses:
404
404
  Description: 'Do not use parentheses for method calls with no arguments.'
405
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens'
405
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-invocation-parens'
406
406
  Enabled: true
407
407
 
408
408
  Style/MethodDefParentheses:
@@ -556,6 +556,7 @@ Style/NumericPredicate:
556
556
  Description: >-
557
557
  Checks for the use of predicate- or comparison methods for
558
558
  numeric comparisons.
559
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
559
560
  Enabled: true
560
561
 
561
562
  Style/OneLineConditional:
@@ -663,6 +664,13 @@ Style/RescueModifier:
663
664
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers'
664
665
  Enabled: true
665
666
 
667
+ Style/SafeNavigation:
668
+ Description: >-
669
+ This cop transforms usages of a method call safeguarded by
670
+ a check for the existance of the object to
671
+ safe navigation (`&.`).
672
+ Enabled: true
673
+
666
674
  Style/SelfAssignment:
667
675
  Description: >-
668
676
  Checks for places where self-assignment shorthand should have
@@ -911,6 +919,10 @@ Style/VariableName:
911
919
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars'
912
920
  Enabled: true
913
921
 
922
+ Style/VariableNumber:
923
+ Description: 'Use the configured style when numbering variables.'
924
+ Enabled: true
925
+
914
926
  Style/WhenThen:
915
927
  Description: 'Use when x then ... for one-line cases.'
916
928
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
@@ -993,7 +1005,7 @@ Lint/AmbiguousOperator:
993
1005
  Description: >-
994
1006
  Checks for ambiguous operators in the first argument of a
995
1007
  method invocation without parentheses.
996
- StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
1008
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-invocation-parens'
997
1009
  Enabled: true
998
1010
 
999
1011
  Lint/AmbiguousRegexpLiteral:
@@ -1197,6 +1209,10 @@ Lint/UnderscorePrefixedVariableName:
1197
1209
  Description: 'Do not use prefix `_` for a variable that is used.'
1198
1210
  Enabled: true
1199
1211
 
1212
+ Lint/UnifiedInteger:
1213
+ Description: 'Use Integer instead of Fixnum or Bignum'
1214
+ Enabled: true
1215
+
1200
1216
  Lint/UnneededDisable:
1201
1217
  Description: >-
1202
1218
  Checks for rubocop:disable comments that can be removed.
@@ -1204,6 +1220,10 @@ Lint/UnneededDisable:
1204
1220
  It must be explicitly disabled.
1205
1221
  Enabled: true
1206
1222
 
1223
+ Lint/UnneededSplatExpansion:
1224
+ Description: 'Checks for splat unnecessarily being called on literals'
1225
+ Enabled: true
1226
+
1207
1227
  Lint/UnusedBlockArgument:
1208
1228
  Description: 'Checks for unused block arguments.'
1209
1229
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
@@ -1223,10 +1243,6 @@ Lint/UselessAccessModifier:
1223
1243
  Enabled: true
1224
1244
  ContextCreatingMethods: []
1225
1245
 
1226
- Lint/UselessArraySplat:
1227
- Description: 'Checks for useless array splats.'
1228
- Enabled: true
1229
-
1230
1246
  Lint/UselessAssignment:
1231
1247
  Description: 'Checks for useless assignment to a local variable.'
1232
1248
  StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars'
@@ -1326,10 +1342,6 @@ Performance/LstripRstrip:
1326
1342
  Description: 'Use `strip` instead of `lstrip.rstrip`.'
1327
1343
  Enabled: true
1328
1344
 
1329
- Performance/PushSplat:
1330
- Description: 'Use `concat` instead of `push(*)`.'
1331
- Enabled: true
1332
-
1333
1345
  Performance/RangeInclude:
1334
1346
  Description: 'Use `Range#cover?` instead of `Range#include?`.'
1335
1347
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#cover-vs-include-code'
@@ -1363,7 +1375,7 @@ Performance/ReverseEach:
1363
1375
  Performance/Sample:
1364
1376
  Description: >-
1365
1377
  Use `sample` instead of `shuffle.first`,
1366
- `shuffle.last`, and `shuffle[Fixnum]`.
1378
+ `shuffle.last`, and `shuffle[Integer]`.
1367
1379
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
1368
1380
  Enabled: true
1369
1381
 
@@ -1374,6 +1386,10 @@ Performance/Size:
1374
1386
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
1375
1387
  Enabled: true
1376
1388
 
1389
+ Performance/SortWithBlock:
1390
+ Description: 'Use `sort_by(&:foo)` instead of `sort_by { |a, b| a.foo <=> b.foo }`.'
1391
+ Enabled: true
1392
+
1377
1393
  Performance/StartWith:
1378
1394
  Description: 'Use `start_with?` instead of a regex match anchored to the beginning of a string.'
1379
1395
  Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringmatch-vs-stringstart_withstringend_with-code-start-code-end'
@@ -1429,6 +1445,10 @@ Rails/HasAndBelongsToMany:
1429
1445
  StyleGuide: 'https://github.com/bbatsov/rails-style-guide#has-many-through'
1430
1446
  Enabled: true
1431
1447
 
1448
+ Rails/NotNullColumn:
1449
+ Description: 'Do not add a NOT NULL column without a default value'
1450
+ Enabled: true
1451
+
1432
1452
  Rails/Output:
1433
1453
  Description: 'Checks for calls to puts, print, etc.'
1434
1454
  Enabled: true
@@ -1452,6 +1472,10 @@ Rails/RequestReferer:
1452
1472
  Description: 'Use consistent syntax for request.referer.'
1453
1473
  Enabled: true
1454
1474
 
1475
+ Rails/SafeNavigation:
1476
+ Description: "Use Ruby's safe navigation operator (`&.`) instead of `try!`"
1477
+ Enabled: true
1478
+
1455
1479
  Rails/ScopeArgs:
1456
1480
  Description: 'Checks the arguments of ActiveRecord scopes.'
1457
1481
  Enabled: true
@@ -1469,3 +1493,7 @@ Rails/UniqBeforePluck:
1469
1493
  Rails/Validation:
1470
1494
  Description: 'Use validates :attribute, hash of validations.'
1471
1495
  Enabled: true
1496
+
1497
+ Security/JSONLoad:
1498
+ Description : 'Prefer usage of JSON.parse'
1499
+ Enabled: true
data/lib/rubocop.rb CHANGED
@@ -56,6 +56,9 @@ require 'rubocop/cop/mixin/code_length' # relies on configurable_max
56
56
  require 'rubocop/cop/mixin/classish_length' # relies on code_length
57
57
  require 'rubocop/cop/mixin/configurable_enforced_style'
58
58
  require 'rubocop/cop/mixin/configurable_naming'
59
+ require 'rubocop/cop/mixin/configurable_numbering'
60
+ require 'rubocop/cop/mixin/def_node'
61
+ require 'rubocop/cop/mixin/documentation_comment'
59
62
  require 'rubocop/cop/mixin/empty_lines_around_body'
60
63
  require 'rubocop/cop/mixin/end_keyword_alignment'
61
64
  require 'rubocop/cop/mixin/first_element_line_break'
@@ -77,6 +80,7 @@ require 'rubocop/cop/mixin/parser_diagnostic'
77
80
  require 'rubocop/cop/mixin/percent_literal'
78
81
  require 'rubocop/cop/mixin/preceding_following_alignment'
79
82
  require 'rubocop/cop/mixin/safe_assignment'
83
+ require 'rubocop/cop/mixin/safe_mode'
80
84
  require 'rubocop/cop/mixin/space_after_punctuation'
81
85
  require 'rubocop/cop/mixin/space_before_punctuation'
82
86
  require 'rubocop/cop/mixin/surrounding_space'
@@ -130,12 +134,13 @@ require 'rubocop/cop/lint/shadowing_outer_local_variable'
130
134
  require 'rubocop/cop/lint/string_conversion_in_interpolation'
131
135
  require 'rubocop/cop/lint/syntax'
132
136
  require 'rubocop/cop/lint/underscore_prefixed_variable_name'
137
+ require 'rubocop/cop/lint/unified_integer'
133
138
  require 'rubocop/cop/lint/unneeded_disable'
139
+ require 'rubocop/cop/lint/unneeded_splat_expansion'
134
140
  require 'rubocop/cop/lint/unreachable_code'
135
141
  require 'rubocop/cop/lint/unused_block_argument'
136
142
  require 'rubocop/cop/lint/unused_method_argument'
137
143
  require 'rubocop/cop/lint/useless_access_modifier'
138
- require 'rubocop/cop/lint/useless_array_splat'
139
144
  require 'rubocop/cop/lint/useless_assignment'
140
145
  require 'rubocop/cop/lint/useless_comparison'
141
146
  require 'rubocop/cop/lint/useless_else_without_rescue'
@@ -162,7 +167,6 @@ require 'rubocop/cop/performance/fixed_size'
162
167
  require 'rubocop/cop/performance/flat_map'
163
168
  require 'rubocop/cop/performance/hash_each'
164
169
  require 'rubocop/cop/performance/lstrip_rstrip'
165
- require 'rubocop/cop/performance/push_splat'
166
170
  require 'rubocop/cop/performance/range_include'
167
171
  require 'rubocop/cop/performance/redundant_block_call'
168
172
  require 'rubocop/cop/performance/redundant_match'
@@ -171,6 +175,7 @@ require 'rubocop/cop/performance/redundant_sort_by'
171
175
  require 'rubocop/cop/performance/reverse_each'
172
176
  require 'rubocop/cop/performance/sample'
173
177
  require 'rubocop/cop/performance/size'
178
+ require 'rubocop/cop/performance/sort_with_block'
174
179
  require 'rubocop/cop/performance/start_with'
175
180
  require 'rubocop/cop/performance/string_replacement'
176
181
  require 'rubocop/cop/performance/times_map'
@@ -212,6 +217,7 @@ require 'rubocop/cop/style/constant_name'
212
217
  require 'rubocop/cop/style/copyright'
213
218
  require 'rubocop/cop/style/def_with_parentheses'
214
219
  require 'rubocop/cop/style/preferred_hash_methods'
220
+ require 'rubocop/cop/style/documentation_method'
215
221
  require 'rubocop/cop/style/documentation'
216
222
  require 'rubocop/cop/style/dot_position'
217
223
  require 'rubocop/cop/style/double_negation'
@@ -316,6 +322,7 @@ require 'rubocop/cop/style/redundant_self'
316
322
  require 'rubocop/cop/style/regexp_literal'
317
323
  require 'rubocop/cop/style/rescue_ensure_alignment'
318
324
  require 'rubocop/cop/style/rescue_modifier'
325
+ require 'rubocop/cop/style/safe_navigation'
319
326
  require 'rubocop/cop/style/self_assignment'
320
327
  require 'rubocop/cop/style/semicolon'
321
328
  require 'rubocop/cop/style/send'
@@ -367,6 +374,7 @@ require 'rubocop/cop/style/unneeded_interpolation'
367
374
  require 'rubocop/cop/style/unneeded_percent_q'
368
375
  require 'rubocop/cop/style/variable_interpolation'
369
376
  require 'rubocop/cop/style/variable_name'
377
+ require 'rubocop/cop/style/variable_number'
370
378
  require 'rubocop/cop/style/when_then'
371
379
  require 'rubocop/cop/style/while_until_do'
372
380
  require 'rubocop/cop/style/while_until_modifier'
@@ -380,17 +388,21 @@ require 'rubocop/cop/rails/exit'
380
388
  require 'rubocop/cop/rails/find_by'
381
389
  require 'rubocop/cop/rails/find_each'
382
390
  require 'rubocop/cop/rails/has_and_belongs_to_many'
391
+ require 'rubocop/cop/rails/not_null_column'
383
392
  require 'rubocop/cop/rails/output_safety'
384
393
  require 'rubocop/cop/rails/output'
385
394
  require 'rubocop/cop/rails/pluralization_grammar'
386
395
  require 'rubocop/cop/rails/read_write_attribute'
387
396
  require 'rubocop/cop/rails/request_referer'
397
+ require 'rubocop/cop/rails/safe_navigation'
388
398
  require 'rubocop/cop/rails/save_bang'
389
399
  require 'rubocop/cop/rails/scope_args'
390
400
  require 'rubocop/cop/rails/time_zone'
391
401
  require 'rubocop/cop/rails/uniq_before_pluck'
392
402
  require 'rubocop/cop/rails/validation'
393
403
 
404
+ require 'rubocop/cop/security/json_load'
405
+
394
406
  require 'rubocop/cop/team'
395
407
 
396
408
  require 'rubocop/formatter/base_formatter'
@@ -468,6 +468,7 @@ module RuboCop
468
468
  # So, does the return value of this node matter? If we changed it to
469
469
  # `(...; nil)`, might that affect anything?
470
470
  #
471
+ # rubocop:disable Metrics/MethodLength
471
472
  def value_used?
472
473
  # Be conservative and return true if we're not sure
473
474
  return false if parent.nil?
@@ -489,6 +490,7 @@ module RuboCop
489
490
  true
490
491
  end
491
492
  end
493
+ # rubocop:enable Metrics/MethodLength
492
494
 
493
495
  # Some expressions are evaluated for their value, some for their side
494
496
  # effects, and some for both
@@ -11,7 +11,7 @@ module RuboCop
11
11
  end
12
12
 
13
13
  def from_json(text)
14
- deserialize_offenses(JSON.load(text))
14
+ deserialize_offenses(JSON.parse(text))
15
15
  end
16
16
 
17
17
  def to_json(offenses)
@@ -21,15 +21,6 @@ module RuboCop
21
21
  private
22
22
 
23
23
  def serialize_offense(offense)
24
- # JSON.dump will fail if the offense message contains text which is not
25
- # valid UTF-8
26
- message = offense.message
27
- message = if message.respond_to?(:scrub)
28
- message.scrub
29
- else
30
- message.chars.select(&:valid_encoding?).join
31
- end
32
-
33
24
  {
34
25
  # Calling #to_s here ensures that the serialization works when using
35
26
  # other json serializers such as Oj. Some of these gems do not call
@@ -39,12 +30,23 @@ module RuboCop
39
30
  begin_pos: offense.location.begin_pos,
40
31
  end_pos: offense.location.end_pos
41
32
  },
42
- message: message,
33
+ message: message(offense),
43
34
  cop_name: offense.cop_name,
44
35
  status: offense.status
45
36
  }
46
37
  end
47
38
 
39
+ def message(offense)
40
+ # JSON.dump will fail if the offense message contains text which is not
41
+ # valid UTF-8
42
+ message = offense.message
43
+ if message.respond_to?(:scrub)
44
+ message.scrub
45
+ else
46
+ message.chars.select(&:valid_encoding?).join
47
+ end
48
+ end
49
+
48
50
  # Restore an offense object loaded from a JSON file.
49
51
  def deserialize_offenses(offenses)
50
52
  source_buffer = utf8_source_buffer