rubocop 0.13.1 → 0.14.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 (222) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +42 -0
  4. data/README.md +59 -54
  5. data/config/default.yml +124 -95
  6. data/config/disabled.yml +4 -0
  7. data/config/enabled.yml +286 -264
  8. data/lib/rubocop.rb +10 -3
  9. data/lib/rubocop/cli.rb +10 -171
  10. data/lib/rubocop/cop/cop.rb +14 -11
  11. data/lib/rubocop/cop/lint/debugger.rb +35 -0
  12. data/lib/rubocop/cop/lint/syntax.rb +34 -0
  13. data/lib/rubocop/cop/offence.rb +15 -23
  14. data/lib/rubocop/cop/style/align_array.rb +1 -10
  15. data/lib/rubocop/cop/style/align_hash.rb +14 -2
  16. data/lib/rubocop/cop/style/align_parameters.rb +1 -11
  17. data/lib/rubocop/cop/style/and_or.rb +13 -11
  18. data/lib/rubocop/cop/style/attr.rb +1 -1
  19. data/lib/rubocop/cop/style/autocorrect_alignment.rb +31 -6
  20. data/lib/rubocop/cop/style/blocks.rb +14 -6
  21. data/lib/rubocop/cop/style/character_literal.rb +1 -1
  22. data/lib/rubocop/cop/style/class_length.rb +38 -0
  23. data/lib/rubocop/cop/style/collection_methods.rb +1 -1
  24. data/lib/rubocop/cop/style/colon_method_call.rb +1 -1
  25. data/lib/rubocop/cop/style/configurable_naming.rb +47 -0
  26. data/lib/rubocop/cop/style/def_parentheses.rb +2 -2
  27. data/lib/rubocop/cop/style/empty_literal.rb +1 -1
  28. data/lib/rubocop/cop/style/even_odd.rb +7 -3
  29. data/lib/rubocop/cop/style/hash_methods.rb +1 -1
  30. data/lib/rubocop/cop/style/hash_syntax.rb +36 -7
  31. data/lib/rubocop/cop/style/lambda_call.rb +36 -11
  32. data/lib/rubocop/cop/style/method_call_parentheses.rb +1 -1
  33. data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +41 -0
  34. data/lib/rubocop/cop/style/method_length.rb +2 -13
  35. data/lib/rubocop/cop/style/method_name.rb +42 -0
  36. data/lib/rubocop/cop/style/numeric_literals.rb +4 -0
  37. data/lib/rubocop/cop/style/perl_backrefs.rb +1 -1
  38. data/lib/rubocop/cop/style/raise_args.rb +60 -0
  39. data/lib/rubocop/cop/style/redundant_exception.rb +32 -0
  40. data/lib/rubocop/cop/style/redundant_return.rb +14 -5
  41. data/lib/rubocop/cop/style/redundant_self.rb +1 -1
  42. data/lib/rubocop/cop/style/semicolon.rb +13 -4
  43. data/lib/rubocop/cop/style/signal_exception.rb +63 -14
  44. data/lib/rubocop/cop/style/special_global_vars.rb +1 -1
  45. data/lib/rubocop/cop/style/string_help.rb +4 -1
  46. data/lib/rubocop/cop/style/string_literals.rb +34 -11
  47. data/lib/rubocop/cop/style/surrounding_space.rb +64 -17
  48. data/lib/rubocop/cop/style/tab.rb +1 -1
  49. data/lib/rubocop/cop/style/variable_name.rb +44 -0
  50. data/lib/rubocop/cop/style/when_then.rb +1 -1
  51. data/lib/rubocop/cop/style/while_until_do.rb +1 -1
  52. data/lib/rubocop/cop/team.rb +4 -7
  53. data/lib/rubocop/cop/util.rb +12 -0
  54. data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
  55. data/lib/rubocop/formatter/emacs_style_formatter.rb +5 -2
  56. data/lib/rubocop/formatter/json_formatter.rb +1 -0
  57. data/lib/rubocop/formatter/progress_formatter.rb +9 -13
  58. data/lib/rubocop/formatter/simple_text_formatter.rb +63 -15
  59. data/lib/rubocop/options.rb +184 -0
  60. data/lib/rubocop/processed_source.rb +4 -0
  61. data/lib/rubocop/version.rb +1 -1
  62. data/rubocop.gemspec +1 -1
  63. data/spec/rubocop/cli_spec.rb +870 -1001
  64. data/spec/rubocop/config_spec.rb +13 -13
  65. data/spec/rubocop/config_store_spec.rb +38 -37
  66. data/spec/rubocop/cop/commissioner_spec.rb +42 -46
  67. data/spec/rubocop/cop/cop_spec.rb +72 -77
  68. data/spec/rubocop/cop/corrector_spec.rb +51 -55
  69. data/spec/rubocop/cop/lint/assignment_in_condition_spec.rb +100 -106
  70. data/spec/rubocop/cop/lint/block_alignment_spec.rb +403 -409
  71. data/spec/rubocop/cop/lint/debugger_spec.rb +39 -0
  72. data/spec/rubocop/cop/lint/empty_ensure_spec.rb +19 -25
  73. data/spec/rubocop/cop/lint/end_alignment_spec.rb +50 -56
  74. data/spec/rubocop/cop/lint/end_in_method_spec.rb +20 -26
  75. data/spec/rubocop/cop/lint/ensure_return_spec.rb +30 -36
  76. data/spec/rubocop/cop/lint/eval_spec.rb +25 -31
  77. data/spec/rubocop/cop/lint/handle_exceptions_spec.rb +22 -28
  78. data/spec/rubocop/cop/lint/literal_in_condition_spec.rb +51 -57
  79. data/spec/rubocop/cop/lint/loop_spec.rb +17 -23
  80. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +51 -57
  81. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +105 -111
  82. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +230 -236
  83. data/spec/rubocop/cop/lint/syntax_spec.rb +33 -0
  84. data/spec/rubocop/cop/lint/unreachable_code_spec.rb +51 -57
  85. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +1544 -1550
  86. data/spec/rubocop/cop/lint/useless_comparison_spec.rb +21 -27
  87. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +119 -125
  88. data/spec/rubocop/cop/lint/void_spec.rb +50 -56
  89. data/spec/rubocop/cop/offence_spec.rb +101 -131
  90. data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +6 -12
  91. data/spec/rubocop/cop/rails/read_attribute_spec.rb +6 -12
  92. data/spec/rubocop/cop/rails/validation_spec.rb +13 -19
  93. data/spec/rubocop/cop/style/access_control_spec.rb +146 -152
  94. data/spec/rubocop/cop/style/alias_spec.rb +30 -36
  95. data/spec/rubocop/cop/style/align_array_spec.rb +57 -56
  96. data/spec/rubocop/cop/style/align_hash_spec.rb +256 -237
  97. data/spec/rubocop/cop/style/align_parameters_spec.rb +216 -202
  98. data/spec/rubocop/cop/style/and_or_spec.rb +51 -55
  99. data/spec/rubocop/cop/style/ascii_comments_spec.rb +14 -20
  100. data/spec/rubocop/cop/style/ascii_identifiers_spec.rb +26 -32
  101. data/spec/rubocop/cop/style/attr_spec.rb +11 -17
  102. data/spec/rubocop/cop/style/begin_block_spec.rb +6 -12
  103. data/spec/rubocop/cop/style/block_comments_spec.rb +13 -19
  104. data/spec/rubocop/cop/style/block_nesting_spec.rb +134 -140
  105. data/spec/rubocop/cop/style/blocks_spec.rb +81 -84
  106. data/spec/rubocop/cop/style/case_equality_spec.rb +5 -11
  107. data/spec/rubocop/cop/style/case_indentation_spec.rb +71 -77
  108. data/spec/rubocop/cop/style/character_literal_spec.rb +31 -37
  109. data/spec/rubocop/cop/style/class_and_module_camel_case_spec.rb +31 -37
  110. data/spec/rubocop/cop/style/class_length_spec.rb +65 -0
  111. data/spec/rubocop/cop/style/class_methods_spec.rb +35 -41
  112. data/spec/rubocop/cop/style/class_vars_spec.rb +11 -17
  113. data/spec/rubocop/cop/style/collection_methods_spec.rb +41 -47
  114. data/spec/rubocop/cop/style/colon_method_call_spec.rb +45 -51
  115. data/spec/rubocop/cop/style/comment_annotation_spec.rb +79 -85
  116. data/spec/rubocop/cop/style/constant_name_spec.rb +45 -51
  117. data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +28 -34
  118. data/spec/rubocop/cop/style/def_without_parentheses_spec.rb +23 -29
  119. data/spec/rubocop/cop/style/documentation_spec.rb +60 -66
  120. data/spec/rubocop/cop/style/dot_position_spec.rb +50 -56
  121. data/spec/rubocop/cop/style/empty_line_between_defs_spec.rb +109 -110
  122. data/spec/rubocop/cop/style/empty_lines_spec.rb +28 -34
  123. data/spec/rubocop/cop/style/empty_literal_spec.rb +80 -86
  124. data/spec/rubocop/cop/style/encoding_spec.rb +50 -56
  125. data/spec/rubocop/cop/style/end_block_spec.rb +6 -12
  126. data/spec/rubocop/cop/style/end_of_line_spec.rb +13 -19
  127. data/spec/rubocop/cop/style/even_odd_spec.rb +69 -41
  128. data/spec/rubocop/cop/style/favor_join_spec.rb +21 -27
  129. data/spec/rubocop/cop/style/favor_modifier_spec.rb +180 -176
  130. data/spec/rubocop/cop/style/favor_sprintf_spec.rb +41 -47
  131. data/spec/rubocop/cop/style/favor_unless_over_negated_if_spec.rb +63 -69
  132. data/spec/rubocop/cop/style/favor_until_over_negated_while_spec.rb +32 -38
  133. data/spec/rubocop/cop/style/final_newline_spec.rb +16 -22
  134. data/spec/rubocop/cop/style/for_spec.rb +18 -24
  135. data/spec/rubocop/cop/style/global_vars_spec.rb +23 -29
  136. data/spec/rubocop/cop/style/hash_methods_spec.rb +39 -45
  137. data/spec/rubocop/cop/style/hash_syntax_spec.rb +93 -65
  138. data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +11 -17
  139. data/spec/rubocop/cop/style/indentation_width_spec.rb +377 -383
  140. data/spec/rubocop/cop/style/lambda_call_spec.rb +40 -22
  141. data/spec/rubocop/cop/style/lambda_spec.rb +30 -34
  142. data/spec/rubocop/cop/style/leading_comment_space_spec.rb +44 -50
  143. data/spec/rubocop/cop/style/line_length_spec.rb +11 -17
  144. data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +14 -20
  145. data/spec/rubocop/cop/style/method_called_on_do_end_block_spec.rb +60 -0
  146. data/spec/rubocop/cop/style/method_length_spec.rb +127 -133
  147. data/spec/rubocop/cop/style/method_name_spec.rb +103 -0
  148. data/spec/rubocop/cop/style/module_function_spec.rb +16 -22
  149. data/spec/rubocop/cop/style/multiline_block_chain_spec.rb +64 -70
  150. data/spec/rubocop/cop/style/multiline_if_then_spec.rb +74 -80
  151. data/spec/rubocop/cop/style/nil_comparison_spec.rb +20 -26
  152. data/spec/rubocop/cop/style/not_spec.rb +13 -19
  153. data/spec/rubocop/cop/style/numeric_literals_spec.rb +36 -35
  154. data/spec/rubocop/cop/style/one_line_conditional_spec.rb +5 -11
  155. data/spec/rubocop/cop/style/op_method_spec.rb +61 -67
  156. data/spec/rubocop/cop/style/parameter_lists_spec.rb +31 -37
  157. data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +62 -68
  158. data/spec/rubocop/cop/style/perl_backrefs_spec.rb +9 -15
  159. data/spec/rubocop/cop/style/proc_spec.rb +13 -19
  160. data/spec/rubocop/cop/style/raise_args_spec.rb +55 -0
  161. data/spec/rubocop/cop/style/reduce_arguments_spec.rb +49 -55
  162. data/spec/rubocop/cop/style/redundant_begin_spec.rb +47 -53
  163. data/spec/rubocop/cop/style/redundant_exception_spec.rb +27 -0
  164. data/spec/rubocop/cop/style/redundant_return_spec.rb +164 -72
  165. data/spec/rubocop/cop/style/redundant_self_spec.rb +109 -115
  166. data/spec/rubocop/cop/style/regexp_literal_spec.rb +57 -63
  167. data/spec/rubocop/cop/style/rescue_modifier_spec.rb +99 -105
  168. data/spec/rubocop/cop/style/semicolon_spec.rb +95 -90
  169. data/spec/rubocop/cop/style/signal_exception_spec.rb +248 -95
  170. data/spec/rubocop/cop/style/single_line_methods_spec.rb +45 -51
  171. data/spec/rubocop/cop/style/space_after_colon_spec.rb +14 -20
  172. data/spec/rubocop/cop/style/space_after_comma_spec.rb +16 -22
  173. data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +48 -54
  174. data/spec/rubocop/cop/style/space_after_method_name_spec.rb +49 -55
  175. data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +10 -16
  176. data/spec/rubocop/cop/style/space_around_block_braces_spec.rb +118 -50
  177. data/spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb +18 -24
  178. data/spec/rubocop/cop/style/space_around_operators_spec.rb +204 -210
  179. data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +36 -42
  180. data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +39 -45
  181. data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +62 -68
  182. data/spec/rubocop/cop/style/space_inside_parens_spec.rb +18 -24
  183. data/spec/rubocop/cop/style/special_global_vars_spec.rb +40 -46
  184. data/spec/rubocop/cop/style/string_literals_spec.rb +148 -70
  185. data/spec/rubocop/cop/style/symbol_array_spec.rb +28 -34
  186. data/spec/rubocop/cop/style/symbol_name_spec.rb +132 -138
  187. data/spec/rubocop/cop/style/tab_spec.rb +9 -15
  188. data/spec/rubocop/cop/style/ternary_operator_spec.rb +25 -31
  189. data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +10 -16
  190. data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +14 -20
  191. data/spec/rubocop/cop/style/trivial_accessors_spec.rb +374 -380
  192. data/spec/rubocop/cop/style/unless_else_spec.rb +17 -23
  193. data/spec/rubocop/cop/style/variable_interpolation_spec.rb +36 -42
  194. data/spec/rubocop/cop/style/variable_name_spec.rb +83 -0
  195. data/spec/rubocop/cop/style/when_then_spec.rb +31 -37
  196. data/spec/rubocop/cop/style/while_until_do_spec.rb +47 -53
  197. data/spec/rubocop/cop/style/word_array_spec.rb +49 -55
  198. data/spec/rubocop/cop/team_spec.rb +125 -127
  199. data/spec/rubocop/cop/variable_inspector/assignment_spec.rb +176 -180
  200. data/spec/rubocop/cop/variable_inspector/locatable_spec.rb +580 -586
  201. data/spec/rubocop/cop/variable_inspector/scope_spec.rb +140 -146
  202. data/spec/rubocop/cop/variable_inspector/variable_spec.rb +52 -58
  203. data/spec/rubocop/cop/variable_inspector/variable_table_spec.rb +217 -223
  204. data/spec/rubocop/cop/variable_inspector_spec.rb +15 -19
  205. data/spec/rubocop/formatter/clang_style_formatter_spec.rb +35 -36
  206. data/spec/rubocop/formatter/disabled_config_formatter_spec.rb +2 -2
  207. data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +24 -1
  208. data/spec/rubocop/formatter/file_list_formatter_spec.rb +1 -1
  209. data/spec/rubocop/formatter/formatter_set_spec.rb +3 -3
  210. data/spec/rubocop/formatter/json_formatter_spec.rb +7 -2
  211. data/spec/rubocop/formatter/offence_count_formatter_spec.rb +1 -1
  212. data/spec/rubocop/formatter/progress_formatter_spec.rb +1 -1
  213. data/spec/rubocop/formatter/simple_text_formatter_spec.rb +55 -6
  214. data/spec/rubocop/options_spec.rb +233 -0
  215. data/spec/rubocop/processed_source_spec.rb +85 -42
  216. data/spec/rubocop/source_parser_spec.rb +108 -110
  217. data/spec/rubocop/target_finder_spec.rb +125 -127
  218. data/spec/rubocop/token_spec.rb +15 -17
  219. metadata +32 -8
  220. data/lib/rubocop/backports/bsearch.rb +0 -39
  221. data/lib/rubocop/cop/style/method_and_variable_snake_case.rb +0 -77
  222. data/spec/rubocop/cop/style/method_and_variable_snake_case_spec.rb +0 -102
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93f1416caf62b3dbb7452feeeb5be8b017bf3926
4
- data.tar.gz: 6de08a58bf2d425bb08411fd33f0e20e9515bba6
3
+ metadata.gz: 98ac250f0e0bf154099056814a9ab3e479b18ca0
4
+ data.tar.gz: 889fe91593bb5d98857a87cdf54a0e103d289727
5
5
  SHA512:
6
- metadata.gz: 59017f0bc97a22ee8b1ed0795d14cafa479992b8e5338af31c8db0dd0dc3c9b0a999799a2a01cf6843e6f39c10e03cacd87c88bdcf3d8455962f1187be033fc2
7
- data.tar.gz: a54661cf2a09e2078ed40b5fb0e3649356d82a2fb2a6f4821b9837e1c1975a0df23c4f25178b7ed782f17b04634d696cfc87316e2f587929d9ead94c195d701b
6
+ metadata.gz: 8808eb3774ea169915eaeafee503e01e94c54357c70c50154ecb2a40ccf00e743d2997e2ec5b0e6caf328180ef76f5e2d9136f0ea3ec47141c9eaab3780d5529
7
+ data.tar.gz: e47780e9359a3ea1c1215eaa418ce62ae01b895f12910624a2d931a4b7db009d21886edf298b42e54286f2f1abc8045460de4c5ff05a2104fa4407f8a32d5536
@@ -5,3 +5,6 @@ inherit_from: config/default.yml
5
5
  # Avoid methods longer than 30 lines of code
6
6
  MethodLength:
7
7
  Max: 30
8
+
9
+ ClassLength:
10
+ Max: 210
@@ -2,6 +2,48 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.14.0 (07/10/2013)
6
+
7
+ ### New features
8
+
9
+ * [#491](https://github.com/bbatsov/rubocop/issues/491) - New cop `MethodCalledOnDoEndBlock` keeps track of methods called on `do`...`end` blocks.
10
+ * [#456](https://github.com/bbatsov/rubocop/issues/456) - New configuration parameter `AllCops`/`RunRailsCops` can be set to `true` for a project, removing the need to give the `-R`/`--rails` option with every invocation of `rubocop`.
11
+ * [#501](https://github.com/bbatsov/rubocop/issues/501) - `simple`/`clang`/`progress`/`emacs` formatters now print `[Corrected]` along with offence message when the offence is automatically corrected.
12
+ * [#501](https://github.com/bbatsov/rubocop/issues/501) - `simple`/`clang`/`progress` formatters now print count of auto-corrected offences in the final summary.
13
+ * [#501](https://github.com/bbatsov/rubocop/issues/501) - `json` formatter now outputs `corrected` key with boolean value in offence objects whether the offence is automatically corrected.
14
+ * New cop `ClassLength` checks for overly long class definitions
15
+ * New cop `Debugger` checks for forgotten calls to debugger or pry
16
+ * New cop `RedundantException` checks for code like `raise RuntimeError, message`
17
+ * [#526](https://github.com/bbatsov/rubocop/issues/526) - New cop `RaiseArgs` checks the args passed to `raise/fail`.
18
+
19
+ ### Changes
20
+
21
+ * Cop `MethodAndVariableSnakeCase` replaced by `MethodName` and `VariableName`, both having the configuration parameter `EnforcedStyle` with values `snake_case` (default) and `camelCase`.
22
+ * [#519](https://github.com/bbatsov/rubocop/issues/519) - `HashSyntax` cop is now configurable and can enforce the use of the classic hash rockets syntax
23
+ * [#520](https://github.com/bbatsov/rubocop/issues/520) - `StringLiterals` cop is now configurable and can enforce either single-quoted or double-quoted strings.
24
+ * [#528](https://github.com/bbatsov/rubocop/issues/528) - Added a config option to `RedundantReturn` to allow a `return` with multiple values.
25
+ * [#524](https://github.com/bbatsov/rubocop/issues/524) - Added a config option to `Semicolon` to allow the use of `;` as an expression separator.
26
+ * [#525](https://github.com/bbatsov/rubocop/issues/525) - `SignalException` cop is now configurable and can enforce the semantic rule or an exclusive use of `raise` or `fail`.
27
+ * `LambdaCall` is now configurable and enforce either `Proc#call` or `Proc#()`.
28
+ * [#529](https://github.com/bbatsov/rubocop/issues/529) - Added config option `EnforcedStyle` to `SpaceAroundBraces`.
29
+ * [#529](https://github.com/bbatsov/rubocop/issues/529) - Changed config option `NoSpaceBeforeBlockParameters` to `SpaceBeforeBlockParameters`.
30
+ * Support Parser 2.0.0 (non-beta)
31
+
32
+ ### Bugs fixed
33
+
34
+ * [#514](https://github.com/bbatsov/rubocop/issues/514) - Fix alignment of the hash containing different key lengths in one line
35
+ * [#496](https://github.com/bbatsov/rubocop/issues/496) - Fix corner case crash in `AlignHash` cop: single key/value pair when configuration is `table` for '=>' and `separator` for `:`.
36
+ * [#502](https://github.com/bbatsov/rubocop/issues/502) - Don't check non-decimal literals with `NumericLiterals`
37
+ * [#448](https://github.com/bbatsov/rubocop/issues/448) - Fix auto-correction of parameters spanning more than one line in `AlignParameters` cop.
38
+ * [#493](https://github.com/bbatsov/rubocop/issues/493) - Support disabling `Syntax` offences with `warning` severity
39
+ * Fix bug appearing when there were different values for the `AllCops`/`RunRailsCops` configuration parameter in different directories.
40
+ * [#512](https://github.com/bbatsov/rubocop/issues/512) - Fix bug causing crash in `AndOr` auto-correction.
41
+ * [#515](https://github.com/bbatsov/rubocop/issues/515) - Fix bug causing `AlignParameters` and `AlignArray` auto-correction to destroy code.
42
+ * [#516](https://github.com/bbatsov/rubocop/issues/516) - Fix bug causing `RedundantReturn` auto-correction to produce invalid code.
43
+ * [#527](https://github.com/bbatsov/rubocop/issues/527) - Handle `!=` expressions in `EvenOdd` cop
44
+ * `SignalException` cop now finds `raise` calls anywhere, not only in `begin` sections.
45
+ * [#538](https://github.com/bbatsov/rubocop/issues/538) - Fix bug causing `Blocks` auto-correction to produce invalid code.
46
+
5
47
  ## 0.13.1 (19/09/2013)
6
48
 
7
49
  ### New features
data/README.md CHANGED
@@ -11,7 +11,8 @@
11
11
  enforce many of the guidelines outlined in the community
12
12
  [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
13
13
 
14
- Most aspects of its behavior can be tweaked via various configuration options.
14
+ Most aspects of its behavior can be tweaked via various
15
+ [configuration options](https://github.com/bbatsov/rubocop/blob/master/config/default.yml).
15
16
 
16
17
  Apart from reporting problems in your code, RuboCop can also
17
18
  automatically fix some of the problems for you.
@@ -27,13 +28,13 @@ $ gem install rubocop
27
28
  ## Basic Usage
28
29
 
29
30
  Running `rubocop` with no arguments will check all Ruby source files
30
- in the current folder:
31
+ in the current directory:
31
32
 
32
33
  ```bash
33
34
  $ rubocop
34
35
  ```
35
36
 
36
- Alternatively you can pass `rubocop` a list of files and folders to check:
37
+ Alternatively you can pass `rubocop` a list of files and directories to check:
37
38
 
38
39
  ```bash
39
40
  $ rubocop app spec lib/something.rb
@@ -128,11 +129,12 @@ $ rubocop -R
128
129
 
129
130
  The behavior of RuboCop can be controlled via the
130
131
  [.rubocop.yml](https://github.com/bbatsov/rubocop/blob/master/.rubocop.yml)
131
- configuration file. The file can be placed either in your home folder
132
- or in some project folder.
132
+ configuration file. It makes it possible to enable/disable certain cops
133
+ (checks) and to alter their behavior if they accept any parameters. The file
134
+ can be placed either in your home directory or in some project directory.
133
135
 
134
136
  RuboCop will start looking for the configuration file in the directory
135
- where the inspected file is and continue its way up to the root folder.
137
+ where the inspected file is and continue its way up to the root directory.
136
138
 
137
139
  The file has the following format:
138
140
 
@@ -140,26 +142,24 @@ The file has the following format:
140
142
  inherit_from: ../.rubocop.yml
141
143
 
142
144
  Encoding:
143
- Enabled: true
145
+ Enabled: false
144
146
 
145
147
  LineLength:
146
- Enabled: true
147
- Max: 79
148
+ Max: 99
148
149
  ```
149
150
 
150
- It allows to enable/disable certain cops (checks) and to alter their
151
- behavior if they accept any parameters.
151
+ ### Inheritance
152
152
 
153
153
  The optional `inherit_from` directive is used to include configuration
154
154
  from one or more files. This makes it possible to have the common
155
155
  project settings in the `.rubocop.yml` file at the project root, and
156
156
  then only the deviations from those rules in the subdirectories. The
157
- included files can be given with absolute paths or paths relative to
158
- the file where they are referenced. The settings after an
159
- `inherit_from` directive override any settings in the included
160
- file(s). When multiple files are included, the first file in the list
161
- has the lowest precedence and the last one has the highest. The format
162
- for multiple inclusion is:
157
+ files can be given with absolute paths or paths relative to the file
158
+ where they are referenced. The settings after an `inherit_from`
159
+ directive override any settings in the file(s) inherited from. When
160
+ multiple files are included, the first file in the list has the lowest
161
+ precedence and the last one has the highest. The format for multiple
162
+ inheritance is:
163
163
 
164
164
  ```yaml
165
165
  inherit_from:
@@ -170,47 +170,21 @@ inherit_from:
170
170
  ### Defaults
171
171
 
172
172
  The file
173
- [config/default.yml]([.rubocop.yml](https://github.com/bbatsov/rubocop/blob/master/config/.default.yml))
173
+ [config/default.yml](https://github.com/bbatsov/rubocop/blob/master/config/default.yml)
174
174
  under the RuboCop home directory contains the default settings that
175
175
  all configurations inherit from. Project and personal `.rubocop.yml`
176
176
  files need only make settings that are different from the default
177
177
  ones. If there is no `.rubocop.yml` file in the project or home
178
178
  directory, `config/default.yml` will be used.
179
179
 
180
- ### Disabling Cops within Source Code
181
-
182
- One or more individual cops can be disabled locally in a section of a
183
- file by adding a comment such as
184
-
185
- ```ruby
186
- # rubocop:disable LineLength, StringLiterals
187
- [...]
188
- # rubocop:enable LineLength, StringLiterals
189
- ```
190
-
191
- You can also disable *all* cops with
192
-
193
- ```ruby
194
- # rubocop:disable all
195
- [...]
196
- # rubocop:enable all
197
- ```
198
-
199
- One or more cops can be disabled on a single line with an end-of-line
200
- comment.
201
-
202
- ```ruby
203
- for x in (0..19) # rubocop:disable AvoidFor
204
- ```
205
-
206
180
  ### Including/Excluding files
207
181
 
208
182
  RuboCop checks all files recursively within the directory it is run
209
- on. However, it does not recognize some files as Ruby(only files
210
- ending with `.rb` or extensionless files with a `#!.*ruby` declaration
211
- are automatically detected) files, and if you'd like it to check these
212
- you'll need to manually pass them in. Files and directories can
213
- also be ignored through `.rubocop.yml`.
183
+ on. However, it only recognizes files ending with `.rb` or
184
+ extensionless files with a `#!.*ruby` declaration as Ruby files. If
185
+ you'd like it to check other files you'll need to manually pass them
186
+ in, or to add entries for them under `AllCops`/`Includes`. Files and
187
+ directories can also be ignored through `AllCops`/`Excludes`.
214
188
 
215
189
  Here is an example that might be used for a Rails project:
216
190
 
@@ -228,11 +202,14 @@ AllCops:
228
202
  # ...
229
203
  ```
230
204
 
231
- Note: Files and directories are specified relative to the
232
- `.rubocop.yml` file. The `Excludes` parameter is special. It is valid
233
- for the directory tree starting where it is defined. It is not
234
- shadowed by the setting of `Excludes` in other `.rubocop.yml` files in
235
- subdirectories.
205
+ Files and directories are specified relative to the `.rubocop.yml` file.
206
+
207
+ **Note**: The `Excludes` parameter is special. It is valid for the
208
+ directory tree starting where it is defined. It is not shadowed by the
209
+ setting of `Excludes` in other `.rubocop.yml` files in
210
+ subdirectories. This is different from all other parameters, who
211
+ follow RuboCop's general principle that configuration for an inspected
212
+ file is taken from the nearest `.rubocop.yml`, searching upwards.
236
213
 
237
214
  ### Automatically Generated Configuration
238
215
 
@@ -243,6 +220,32 @@ contains configuration to disable all cops that currently detect an offence in
243
220
  the code. Then you can start removing the entries in the generated file one by
244
221
  one as you work through all the offences in the code.
245
222
 
223
+ ## Disabling Cops within Source Code
224
+
225
+ One or more individual cops can be disabled locally in a section of a
226
+ file by adding a comment such as
227
+
228
+ ```ruby
229
+ # rubocop:disable LineLength, StringLiterals
230
+ [...]
231
+ # rubocop:enable LineLength, StringLiterals
232
+ ```
233
+
234
+ You can also disable *all* cops with
235
+
236
+ ```ruby
237
+ # rubocop:disable all
238
+ [...]
239
+ # rubocop:enable all
240
+ ```
241
+
242
+ One or more cops can be disabled on a single line with an end-of-line
243
+ comment.
244
+
245
+ ```ruby
246
+ for x in (0..19) # rubocop:disable AvoidFor
247
+ ```
248
+
246
249
  ## Formatters
247
250
 
248
251
  ### Clang Formatter (default)
@@ -332,6 +335,7 @@ The JSON structure is like the following example:
332
335
  "severity": "convention",
333
336
  "message": "Line is too long. [81/79]",
334
337
  "cop_name": "LineLength",
338
+ "corrected": true,
335
339
  "location": {
336
340
  "line": 546,
337
341
  "column": 80
@@ -340,6 +344,7 @@ The JSON structure is like the following example:
340
344
  "severity": "warning",
341
345
  "message": "Unreachable code detected.",
342
346
  "cop_name": "UnreachableCode",
347
+ "corrected": false,
343
348
  "location": {
344
349
  "line": 15,
345
350
  "column": 9
@@ -12,76 +12,151 @@ AllCops:
12
12
  - '**/*.gemspec'
13
13
  - '**/Rakefile'
14
14
  Excludes: []
15
+ # By default, the rails cops are not run. Override in project or home
16
+ # directory .rubocop.yml files, or by giving the -R/--rails option.
17
+ RunRailsCops: false
18
+
19
+ # Align the elements of a hash literal if they span more than one line.
20
+ AlignHash:
21
+ # Alignment of entries using hash rocket as separator. Valid values are:
22
+ #
23
+ # key - left alignment of keys
24
+ # 'a' => 2
25
+ # 'bb' => 3
26
+ # separator - alignment of hash rockets, keys are right aligned
27
+ # 'a' => 2
28
+ # 'bb' => 3
29
+ # table - left alignment of keys, hash rockets, and values
30
+ # 'a' => 2
31
+ # 'bb' => 3
32
+ EnforcedHashRocketStyle: key
33
+ # Alignment of entries using colon as separator. Valid values are:
34
+ #
35
+ # key - left alignment of keys
36
+ # a: 0
37
+ # bb: 1
38
+ # separator - alignment of colons, keys are right aligned
39
+ # a: 0
40
+ # bb: 1
41
+ # table - left alignment of keys and values
42
+ # a: 0
43
+ # bb: 1
44
+ EnforcedColonStyle: key
45
+
46
+ # Allow safe assignment in conditions.
47
+ AssignmentInCondition:
48
+ AllowSafeAssignment: true
49
+
50
+ BlockNesting:
51
+ Max: 3
52
+
53
+ ClassLength:
54
+ CountComments: false # count full line comments?
55
+ Max: 100
56
+
57
+ # Align with the style guide.
58
+ CollectionMethods:
59
+ PreferredMethods:
60
+ collect: 'map'
61
+ collect!: 'map!'
62
+ inject: 'reduce'
63
+ detect: 'find'
64
+ find_all: 'select'
65
+
66
+ # Checks formatting of special comments
67
+ CommentAnnotation:
68
+ Keywords:
69
+ - TODO
70
+ - FIXME
71
+ - OPTIMIZE
72
+ - HACK
73
+ - REVIEW
74
+
75
+ # Multi-line method chaining should be done with leading dots.
76
+ DotPosition:
77
+ Style: 'leading'
78
+
79
+ # Use empty lines between defs.
80
+ EmptyLineBetweenDefs:
81
+ # If true, this parameter means that single line method definitions don't
82
+ # need an empty line between them.
83
+ AllowAdjacentOneLineDefs: false
84
+
85
+ # Built-in global variables are allowed by default.
86
+ GlobalVars:
87
+ AllowedVariables: []
88
+
89
+ HashSyntax:
90
+ # Valid values are: ruby19, hash_rockets
91
+ EnforcedStyle: ruby19
92
+
93
+ LambdaCall:
94
+ # Valid values are: call, braces
95
+ EnforcedStyle: call
15
96
 
16
97
  LineLength:
17
- Description: 'Limit lines to 79 characters.'
18
98
  Max: 79
19
99
 
20
100
  MethodLength:
21
- Description: 'Avoid methods longer than 10 lines of code.'
22
101
  CountComments: false # count full line comments?
23
102
  Max: 10
24
103
 
25
- SpaceAroundBlockBraces:
26
- Description: 'Use spaces around { and before } in blocks.'
27
- NoSpaceBeforeBlockParameters: false
104
+ MethodName:
105
+ # Valid values are: snake_case, camelCase
106
+ EnforcedStyle: snake_case
107
+
108
+ NumericLiterals:
109
+ MinDigits: 5
28
110
 
29
111
  ParameterLists:
30
- Description: 'Avoid parameter lists longer than five parameters.'
31
112
  Max: 5
32
113
  CountKeywordArgs: true
33
114
 
115
+ # Allow safe assignment in conditions.
116
+ ParenthesesAroundCondition:
117
+ AllowSafeAssignment: true
118
+
119
+ RaiseArgs:
120
+ # Valid values are: compact and exploded
121
+ # exploded: raise Exception, msg
122
+ # compact: raise Exception.new(msg)
123
+ EnforcedStyle: exploded
124
+
125
+ RedundantReturn:
126
+ # When true allows code like `return x, y`.
127
+ AllowMultipleReturnValues: false
128
+
129
+ RegexpLiteral:
130
+ MaxSlashes: 1
131
+
34
132
  Semicolon:
35
- Description: "Don't use semicolons to terminate expressions."
36
- # For example; def area(height, width); height * width end
37
- AllowAfterParameterListInOneLineMethods: false
38
- # For example; def area(height, width) height * width; end
39
- AllowBeforeEndInOneLineMethods: true
133
+ # Allow ; to separate several expressions on the same line.
134
+ AllowAsExpressionSeparator: false
135
+
136
+ SignalException:
137
+ # Valid values are: semantic, only_raise and only_fail
138
+ EnforcedStyle: semantic
40
139
 
41
140
  SingleLineMethods:
42
- Description: 'Avoid single-line methods.'
43
141
  AllowIfMethodIsEmpty: true
44
142
 
143
+ StringLiterals:
144
+ # Valid values (denoting the preferred quote delimiters) are:
145
+ # single_quotes, double_quotes
146
+ EnforcedStyle: single_quotes
147
+
148
+ SpaceAroundBlockBraces:
149
+ # Valid values are: space_inside_braces, no_space_inside_braces
150
+ EnforcedStyle: space_inside_braces
151
+ # Space between { and |. Overrides EnforcedStyle if there is a conflict.
152
+ SpaceBeforeBlockParameters: true
153
+
45
154
  SpaceInsideHashLiteralBraces:
46
- Description: "Use spaces inside hash literal braces - or don't."
47
155
  EnforcedStyleIsWithSpaces: true
48
156
 
49
157
  SymbolName:
50
- Description: 'Symbol literals should use snake_case.'
51
158
  AllowCamelCase: true
52
159
 
53
- BlockNesting:
54
- Description: 'Avoid more than `Max` levels of nesting.'
55
- Max: 3
56
-
57
- NumericLiterals:
58
- MinDigits: 5
59
-
60
- RegexpLiteral:
61
- Description: >
62
- Use %r for regular expressions matching more than
63
- `MaxSlashes` '/' characters.
64
- Use %r only for regular expressions matching more than
65
- `MaxSlashes` '/' character.
66
- MaxSlashes: 1
67
-
68
- # Built-in global variables are allowed by default.
69
- GlobalVars:
70
- AllowedVariables: []
71
-
72
- # Align with the style guide.
73
- CollectionMethods:
74
- PreferredMethods:
75
- collect: 'map'
76
- collect!: 'map!'
77
- inject: 'reduce'
78
- detect: 'find'
79
- find_all: 'select'
80
-
81
- # Multi-line method chaining should be done with leading dots.
82
- DotPosition:
83
- Style: 'leading'
84
-
85
160
  # TrivialAccessors doesn't require exact name matches and doesn't allow
86
161
  # predicated methods by default.
87
162
  TrivialAccessors:
@@ -106,52 +181,6 @@ TrivialAccessors:
106
181
  - to_s
107
182
  - to_sym
108
183
 
109
- # Allow safe assignment in conditions.
110
- AssignmentInCondition:
111
- AllowSafeAssignment: true
112
-
113
- # Allow safe assignment in conditions.
114
- ParenthesesAroundCondition:
115
- AllowSafeAssignment: true
116
-
117
- # Checks formatting of special comments
118
- CommentAnnotation:
119
- Keywords:
120
- - TODO
121
- - FIXME
122
- - OPTIMIZE
123
- - HACK
124
- - REVIEW
125
-
126
- # Use empty lines between defs.
127
- EmptyLineBetweenDefs:
128
- # If true, this parameter means that single line method definitions don't
129
- # need an empty line between them.
130
- AllowAdjacentOneLineDefs: false
131
-
132
- # Align the elements of a hash literal if they span more than one line.
133
- AlignHash:
134
- # Alignment of entries using hash rocket as separator. Valid values are:
135
- #
136
- # key - left alignment of keys
137
- # 'a' => 2
138
- # 'bb' => 3
139
- # separator - alignment of hash rockets, keys are right aligned
140
- # 'a' => 2
141
- # 'bb' => 3
142
- # table - left alignment of keys, hash rockets, and values
143
- # 'a' => 2
144
- # 'bb' => 3
145
- EnforcedHashRocketStyle: key
146
- # Alignment of entries using colon as separator. Valid values are:
147
- #
148
- # key - left alignment of keys
149
- # a: 0
150
- # bb: 1
151
- # separator - alignment of colons, keys are right aligned
152
- # a: 0
153
- # bb: 1
154
- # table - left alignment of keys and values
155
- # a: 0
156
- # bb: 1
157
- EnforcedColonStyle: key
184
+ VariableName:
185
+ # Valid values are: snake_case, camelCase
186
+ EnforcedStyle: snake_case