rubocop 0.34.2 → 0.35.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 (102) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -0
  3. data/README.md +103 -31
  4. data/config/default.yml +32 -2
  5. data/config/disabled.yml +24 -0
  6. data/config/enabled.yml +20 -2
  7. data/lib/rubocop.rb +13 -0
  8. data/lib/rubocop/ast_node.rb +48 -0
  9. data/lib/rubocop/cli.rb +9 -0
  10. data/lib/rubocop/config.rb +8 -6
  11. data/lib/rubocop/config_loader.rb +30 -8
  12. data/lib/rubocop/cop/commissioner.rb +1 -1
  13. data/lib/rubocop/cop/cop.rb +19 -6
  14. data/lib/rubocop/cop/lint/circular_argument_reference.rb +33 -2
  15. data/lib/rubocop/cop/lint/debugger.rb +9 -56
  16. data/lib/rubocop/cop/lint/end_alignment.rb +29 -9
  17. data/lib/rubocop/cop/lint/eval.rb +6 -2
  18. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +24 -6
  19. data/lib/rubocop/cop/lint/literal_in_condition.rb +0 -5
  20. data/lib/rubocop/cop/lint/non_local_exit_from_iterator.rb +10 -1
  21. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  22. data/lib/rubocop/cop/lint/space_before_first_arg.rb +1 -1
  23. data/lib/rubocop/cop/lint/unused_block_argument.rb +6 -0
  24. data/lib/rubocop/cop/lint/unused_method_argument.rb +8 -0
  25. data/lib/rubocop/cop/metrics/abc_size.rb +1 -1
  26. data/lib/rubocop/cop/mixin/access_modifier_node.rb +1 -1
  27. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +1 -1
  28. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +26 -3
  29. data/lib/rubocop/cop/mixin/check_assignment.rb +2 -3
  30. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +59 -12
  31. data/lib/rubocop/cop/mixin/configurable_max.rb +1 -1
  32. data/lib/rubocop/cop/mixin/configurable_naming.rb +1 -1
  33. data/lib/rubocop/cop/mixin/first_element_line_break.rb +41 -0
  34. data/lib/rubocop/cop/mixin/negative_conditional.rb +1 -1
  35. data/lib/rubocop/cop/mixin/safe_assignment.rb +3 -14
  36. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
  37. data/lib/rubocop/cop/performance/detect.rb +5 -1
  38. data/lib/rubocop/cop/performance/fixed_size.rb +50 -0
  39. data/lib/rubocop/cop/performance/size.rb +1 -1
  40. data/lib/rubocop/cop/performance/string_replacement.rb +14 -8
  41. data/lib/rubocop/cop/rails/pluralization_grammar.rb +97 -0
  42. data/lib/rubocop/cop/style/align_hash.rb +1 -12
  43. data/lib/rubocop/cop/style/align_parameters.rb +19 -7
  44. data/lib/rubocop/cop/style/and_or.rb +42 -13
  45. data/lib/rubocop/cop/style/block_comments.rb +4 -2
  46. data/lib/rubocop/cop/style/block_delimiters.rb +57 -18
  47. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
  48. data/lib/rubocop/cop/style/command_literal.rb +2 -10
  49. data/lib/rubocop/cop/style/copyright.rb +5 -3
  50. data/lib/rubocop/cop/style/documentation.rb +9 -6
  51. data/lib/rubocop/cop/style/dot_position.rb +6 -0
  52. data/lib/rubocop/cop/style/double_negation.rb +4 -15
  53. data/lib/rubocop/cop/style/each_with_object.rb +17 -4
  54. data/lib/rubocop/cop/style/empty_line_between_defs.rb +1 -5
  55. data/lib/rubocop/cop/style/encoding.rb +10 -4
  56. data/lib/rubocop/cop/style/extra_spacing.rb +23 -13
  57. data/lib/rubocop/cop/style/first_array_element_line_break.rb +41 -0
  58. data/lib/rubocop/cop/style/first_hash_element_line_break.rb +35 -0
  59. data/lib/rubocop/cop/style/first_method_argument_line_break.rb +37 -0
  60. data/lib/rubocop/cop/style/first_method_parameter_line_break.rb +42 -0
  61. data/lib/rubocop/cop/style/for.rb +2 -1
  62. data/lib/rubocop/cop/style/if_unless_modifier.rb +31 -0
  63. data/lib/rubocop/cop/style/indent_hash.rb +67 -37
  64. data/lib/rubocop/cop/style/indentation_width.rb +1 -1
  65. data/lib/rubocop/cop/style/leading_comment_space.rb +3 -2
  66. data/lib/rubocop/cop/style/method_call_parentheses.rb +8 -0
  67. data/lib/rubocop/cop/style/method_def_parentheses.rb +10 -7
  68. data/lib/rubocop/cop/style/multiline_operation_indentation.rb +8 -13
  69. data/lib/rubocop/cop/style/nested_modifier.rb +97 -0
  70. data/lib/rubocop/cop/style/next.rb +18 -0
  71. data/lib/rubocop/cop/style/parallel_assignment.rb +57 -15
  72. data/lib/rubocop/cop/style/predicate_name.rb +7 -2
  73. data/lib/rubocop/cop/style/regexp_literal.rb +2 -10
  74. data/lib/rubocop/cop/style/single_line_methods.rb +7 -5
  75. data/lib/rubocop/cop/style/single_space_before_first_arg.rb +1 -1
  76. data/lib/rubocop/cop/style/space_around_operators.rb +2 -0
  77. data/lib/rubocop/cop/style/special_global_vars.rb +4 -2
  78. data/lib/rubocop/cop/style/stabby_lambda_parentheses.rb +108 -0
  79. data/lib/rubocop/cop/style/trailing_comma.rb +9 -6
  80. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +23 -2
  81. data/lib/rubocop/cop/style/unneeded_percent_q.rb +31 -20
  82. data/lib/rubocop/cop/style/variable_name.rb +5 -0
  83. data/lib/rubocop/cop/style/word_array.rb +2 -1
  84. data/lib/rubocop/cop/team.rb +17 -4
  85. data/lib/rubocop/cop/util.rb +5 -0
  86. data/lib/rubocop/cop/variable_force/locatable.rb +1 -1
  87. data/lib/rubocop/formatter/base_formatter.rb +1 -1
  88. data/lib/rubocop/formatter/disabled_config_formatter.rb +22 -10
  89. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  90. data/lib/rubocop/node_pattern.rb +390 -0
  91. data/lib/rubocop/options.rb +48 -36
  92. data/lib/rubocop/processed_source.rb +3 -1
  93. data/lib/rubocop/rake_task.rb +1 -1
  94. data/lib/rubocop/remote_config.rb +60 -0
  95. data/lib/rubocop/result_cache.rb +4 -2
  96. data/lib/rubocop/runner.rb +33 -10
  97. data/lib/rubocop/token.rb +2 -1
  98. data/lib/rubocop/version.rb +1 -1
  99. data/lib/rubocop/warning.rb +11 -0
  100. data/relnotes/v0.35.0.md +210 -0
  101. data/rubocop.gemspec +2 -2
  102. metadata +20 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 706a61d96efb82b99fada36b2472fb0adc32ce09
4
- data.tar.gz: 107b525881e8a174454969957a9e2e1b823f66f1
3
+ metadata.gz: faeefb30bb3d8f71a9a27ac9fe972b4f489c12e4
4
+ data.tar.gz: 931e6ba95fc0119b48dbaaa5144ed67121bcd256
5
5
  SHA512:
6
- metadata.gz: 3e2e7a1a59ce5f66a66b013e53a1c864db55583de28c4dae467e8e095f985f0a7f8a81f52132f346308ff358fe9cc04d6db12d9a20275b6afa8fb2ca83944056
7
- data.tar.gz: 52fa283a415fabac9ac2fcf6e06c2450381ecca66cffef48bcccc09729992bfafa8b5ffd2a044c5f936a31ed51932618d18bc593727d5bce823fb22c15370825
6
+ metadata.gz: 1e5163d89e311a7a520b2a690fb75b69450ce1ddbb4d8632205f97cdb821305020d4afed08abb8de02065cb11bb9485d91f4a00c89aa91923cb2b8a6d9c1da22
7
+ data.tar.gz: 5d6a0610ea94aa62673d3ffe75436af19db27e18b0f05b9ac22d4a2af323f349c412a24580f4b8db6a3c22574e58ac77be83527eaeec309c50e7be4d38a89901
@@ -2,6 +2,81 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.35.0 (07/11/2015)
6
+
7
+ ### New features
8
+
9
+ * [#2028](https://github.com/bbatsov/rubocop/issues/2028): New config `ExtraDetails` supports addition of `Details` param to all cops to allow extra details on offense to be displayed. ([@tansaku][])
10
+ * [#2036](https://github.com/bbatsov/rubocop/issues/2036): New cop `Style/StabbyLambdaParentheses` will find and correct cases where a stabby lambda's paramaters are not wrapped in parentheses. ([@hmadison][])
11
+ * [#2246](https://github.com/bbatsov/rubocop/pull/2246): `Style/TrailingUnderscoreVariable` will now register an offense for `*_`. ([@rrosenblum][])
12
+ * [#2246](https://github.com/bbatsov/rubocop/pull/2246): `Style/TrailingUnderscoreVariable` now has a configuration to remove named underscore variables (Defaulted to false). ([@rrosenblum][])
13
+ * [#2276](https://github.com/bbatsov/rubocop/pull/2276): New cop `Performance/FixedSize` will register an offense when calling `length`, `size`, or `count` on statically sized objected (strings, symbols, arrays, and hashes). ([@rrosenblum][])
14
+ * New cop `Style/NestedModifier` checks for nested `if`, `unless`, `while` and `until` modifier statements. ([@lumeet][])
15
+ * [#2270](https://github.com/bbatsov/rubocop/pull/2270): Add a new `inherit_gem` configuration to inherit a config file from an installed gem [(originally requested in #290)](https://github.com/bbatsov/rubocop/issues/290). ([@jhansche][])
16
+ * Allow `StyleGuide` parameters in local configuration for all cops, so users can add references to custom style guide documents. ([@cornelius][])
17
+ * `UnusedMethodArgument` cop allows configuration to skip keyword arguments. ([@apiology][])
18
+ * [#2318](https://github.com/bbatsov/rubocop/pull/2318): `Lint/Debugger` cop now checks for `Pry.rescue`. ([@rrosenblum][])
19
+ * [#2277](https://github.com/bbatsov/rubocop/pull/2277): New cop `Style/FirstArrayElementLineBreak` checks for a line break before the first element in a multi-line array. ([@panthomakos][])
20
+ * [#2277](https://github.com/bbatsov/rubocop/pull/2277): New cop `Style/FirstHashElementLineBreak` checks for a line break before the first element in a multi-line hash. ([@panthomakos][])
21
+ * [#2277](https://github.com/bbatsov/rubocop/pull/2277): New cop `Style/FirstMethodArgumentLineBreak` checks for a line break before the first argument in a multi-line method call. ([@panthomakos][])
22
+ * [#2277](https://github.com/bbatsov/rubocop/pull/2277): New cop `Style/FirstMethodParameterLineBreak` checks for a line break before the first parameter in a multi-line method parameter definition. ([@panthomakos][])
23
+ * Add `Rails/PluralizationGrammar` cop, checks for incorrect grammar when using methods like `3.day.ago`, when you should write `3.days.ago`. ([@maxjacobson][])
24
+ * [#2347](https://github.com/bbatsov/rubocop/pull/2347): `Lint/Eval` cop does not warn about "security risk" when eval argument is a string literal without interpolations. ([@alexdowad][])
25
+ * [#2335](https://github.com/bbatsov/rubocop/issues/2335): `Style/VariableName` cop checks naming style of method parameters. ([@alexdowad][])
26
+ * [#2329](https://github.com/bbatsov/rubocop/pull/2329): New style `braces_for_chaining` for `Style/BlockDelimiters` cop enforces braces on a multi-line block if its return value is being chained with another method. ([@panthomakos][])
27
+ * `Lint/LiteralInCondition` warns if a symbol or dynamic symbol is used as a condition. ([@alexdowad][])
28
+ * [#2369](https://github.com/bbatsov/rubocop/issues/2369): `Style/TrailingComma` doesn't add a trailing comma to a multiline method chain which is the only arg to a method call. ([@alexdowad][])
29
+ * `CircularArgumentReference` cop updated to lint for ordinal circular argument references on top of optional keyword arguments. ([@maxjacobson][])
30
+ * Added ability to download shared rubocop config files from remote urls. ([@ptrippett][])
31
+ * [#1601](https://github.com/bbatsov/rubocop/issues/1601): Add `IgnoreEmptyMethods` config parameter for `Lint/UnusedMethodArgument` and `IgnoreEmptyBlocks` config parameter for `Lint/UnusedBlockArgument` cops. ([@alexdowad][])
32
+ * [#1729](https://github.com/bbatsov/rubocop/issues/1729): `Style/MethodDefParentheses` supports new 'require_no_parentheses_except_multiline' style. ([@alexdowad][])
33
+ * [#2173](https://github.com/bbatsov/rubocop/issues/2173): `Style/AlignParameters` also checks parameter alignment for method definitions. ([@alexdowad][])
34
+ * [#1825](https://github.com/bbatsov/rubocop/issues/1825): New `NameWhitelist` configuration parameter for `Style/PredicateName` can be used to suppress errors on known-good predicate names. ([@alexdowad][])
35
+ * `Style/Documentation` recognizes 'Constant = Class.new' as a class definition. ([@alexdowad][])
36
+ * [#1608](https://github.com/bbatsov/rubocop/issues/1608): Add new 'align_braces' style for `Style/IndentHash`. ([@alexdowad][])
37
+ * `Style/Next` can autocorrect. ([@alexdowad][])
38
+
39
+ ### Bug Fixes
40
+
41
+ * [#2265](https://github.com/bbatsov/rubocop/issues/2265): Handle unary `+` in `ExtraSpacing` cop. ([@jonas054][])
42
+ * [#2275](https://github.com/bbatsov/rubocop/pull/2275): Copy default `Exclude` into `Exclude` lists in `.rubocop_todo.yml`. ([@jonas054][])
43
+ * `Style/IfUnlessModifier` accepts blocks followed by a chained call. ([@lumeet][])
44
+ * [#2261](https://github.com/bbatsov/rubocop/issues/2261): Make relative `Exclude` paths in `$HOME/.rubocop_todo.yml` be relative to current directory. ([@jonas054][])
45
+ * [#2286](https://github.com/bbatsov/rubocop/issues/2286): Handle auto-correction of empty method when `AllowIfMethodIsEmpty` is `false` in `Style/SingleLineMethods`. ([@jonas054][])
46
+ * [#2246](https://github.com/bbatsov/rubocop/pull/2246): Do not register an offense for `Style/TrailingUnderscoreVariable` when the underscore variable is preceeded by a splat variable. ([@rrosenblum][])
47
+ * [#2292](https://github.com/bbatsov/rubocop/pull/2292): Results should not be stored in the cache if affected by errors (crashes). ([@jonas054][])
48
+ * [#2280](https://github.com/bbatsov/rubocop/issues/2280): Avoid reporting space between hash literal keys and values in `Style/ExtraSpacing`. ([@jonas054][])
49
+ * [#2284](https://github.com/bbatsov/rubocop/issues/2284): Fix result cache being shared between ruby versions. ([@miquella][])
50
+ * [#2285](https://github.com/bbatsov/rubocop/issues/2285): Fix `ConfigurableNaming#class_emitter_method?` error when handling singleton class methods. ([@palkan][])
51
+ * [#2295](https://github.com/bbatsov/rubocop/issues/2295): Fix Performance/Detect autocorrect to handle rogue newlines. ([@palkan][])
52
+ * [#2294](https://github.com/bbatsov/rubocop/issues/2294): Do not register an offense in `Performance/StringReplacement` for regex with options. ([@rrosenblum][])
53
+ * Fix `Style/UnneededPercentQ` condition for single-quoted literal containing interpolation-like string. ([@eagletmt][])
54
+ * [#2324](https://github.com/bbatsov/rubocop/issues/2324): Handle `--only Lint/Syntax` and `--except Lint/Syntax` correctly. ([@jonas054][])
55
+ * [#2317](https://github.com/bbatsov/rubocop/issues/2317): Handle `case` as an argument correctly in `Lint/EndAlignment`. ([@lumeet][])
56
+ * [#2287](https://github.com/bbatsov/rubocop/issues/2287): Fix auto-correct of lines with only whitespace in `Style/IndentationWidth`. ([@lumeet][])
57
+ * [#2331](https://github.com/bbatsov/rubocop/issues/2331): Do not register an offense in `Performance/Size` for `count` with an argument. ([@rrosenblum][])
58
+ * Handle a backslash at the end of a line in `Style/SpaceAroundOperators`. ([@lumeet][])
59
+ * Don't warn about lack of "leading space" in a =begin/=end comment. ([@alexdowad][])
60
+ * [#2307](https://github.com/bbatsov/rubocop/issues/2307): In `Lint/FormatParameterMismatch`, don't register an offense if either argument to % is not a literal. ([@alexdowad][])
61
+ * [#2356](https://github.com/bbatsov/rubocop/pull/2356): `Style/Encoding` will now place the encoding comment on the second line if the first line is a shebang. ([@rrosenblum][])
62
+ * `Style/InitialIndentation` cop doesn't error out when a line begins with an integer literal. ([@alexdowad][])
63
+ * [#2296](https://github.com/bbatsov/rubocop/issues/2296): In `Style/DotPosition`, don't "correct" (and break) a method call which has a line comment (or blank line) between the dot and the selector. ([@alexdowad][])
64
+ * [#2272](https://github.com/bbatsov/rubocop/issues/2272): `Lint/NonLocalExitFromIterator` does not warn about `return` in a block which is passed to `Module#define_method`. ([@alexdowad][])
65
+ * [#2262](https://github.com/bbatsov/rubocop/issues/2262): Replace `Rainbow` reference with `Colorizable#yellow`. ([@minustehbare][])
66
+ * [#2068](https://github.com/bbatsov/rubocop/issues/2068): Display warning if `Style/Copyright` is misconfigured. ([@alexdowad][])
67
+ * [#2321](https://github.com/bbatsov/rubocop/issues/2321): In `Style/EachWithObject`, don't replace reduce with each_with_object if the accumulator parameter is assigned to in the block. ([@alexdowad][])
68
+ * [#1981](https://github.com/bbatsov/rubocop/issues/1981): `Lint/UselessAssignment` doesn't erroneously identify assignments in identical if branches as useless. ([@alexdowad][])
69
+ * [#2323](https://github.com/bbatsov/rubocop/issues/2323): `Style/IfUnlessModifier` cop parenthesizes autocorrected code when necessary due to operator precedence, to avoid changing its meaning. ([@alexdowad][])
70
+ * [#2003](https://github.com/bbatsov/rubocop/issues/2003): Make `Lint/UnneededDisable` work with `--auto-correct`. ([@jonas054][])
71
+ * Default RuboCop cache dir moved to per-user folders. ([@br3nda][])
72
+ * [#2393](https://github.com/bbatsov/rubocop/pull/2393): `Style/MethodCallParentheses` doesn't fail on `obj.method ||= func()`. ([@alexdowad][])
73
+ * [#2344](https://github.com/bbatsov/rubocop/pull/2344): When autocorrecting, `Style/ParallelAssignment` reorders assignment statements, if necessary, to avoid breaking code. ([@alexdowad][])
74
+ * `Style/MultilineOperationAlignment` does not try to align the receiver and selector of a method call if both are on the LHS of an assignment. ([@alexdowad][])
75
+
76
+ ### Changes
77
+
78
+ * [#2194](https://github.com/bbatsov/rubocop/issues/2194): Allow any options with `--auto-gen-config`. ([@agrimm][])
79
+
5
80
  ## 0.34.2 (21/09/2015)
6
81
 
7
82
  ### Bug Fixes
@@ -1622,3 +1697,14 @@
1622
1697
  [@mrfoto]: https://github.com/mrfoto
1623
1698
  [@karreiro]: https://github.com/karreiro
1624
1699
  [@dreyks]: https://github.com/dreyks
1700
+ [@hmadison]: https://github.com/hmadison
1701
+ [@miquella]: https://github.com/miquella
1702
+ [@jhansche]: https://github.com/jhansche
1703
+ [@cornelius]: https://github.com/cornelius
1704
+ [@eagletmt]: https://github.com/eagletmt
1705
+ [@apiology]: https://github.com/apiology
1706
+ [@alexdowad]: https://github.com/alexdowad
1707
+ [@minustehbare]: https://github.com/minustehbare
1708
+ [@tansaku]: https://github.com/tansaku
1709
+ [@ptrippett]: https://github.com/ptrippett
1710
+ [@br3nda]: https://github.com/br3nda
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rubocop.svg)](http://badge.fury.io/rb/rubocop)
2
2
  [![Dependency Status](https://gemnasium.com/bbatsov/rubocop.svg)](https://gemnasium.com/bbatsov/rubocop)
3
3
  [![Build Status](https://travis-ci.org/bbatsov/rubocop.svg?branch=master)](https://travis-ci.org/bbatsov/rubocop)
4
- [![Coverage Status](http://img.shields.io/coveralls/bbatsov/rubocop/master.svg)](https://coveralls.io/r/bbatsov/rubocop)
4
+ [![Coverage Status](https://img.shields.io/coveralls/bbatsov/rubocop/master.svg)](https://coveralls.io/r/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
7
 
8
8
  <p align="center">
9
- <img src="https://raw.github.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
9
+ <img src="https://raw.githubusercontent.com/bbatsov/rubocop/master/logo/rubo-logo-horizontal.png" alt="RuboCop Logo"/>
10
10
  </p>
11
11
 
12
12
  > Role models are important. <br/>
@@ -26,9 +26,9 @@ automatically fix some of the problems for you.
26
26
 
27
27
  You can support my work on RuboCop via
28
28
  [Salt](https://salt.bountysource.com/teams/rubocop) and
29
- [Gratipay](https://www.gratipay.com/rubocop).
29
+ [Gratipay](https://gratipay.com/rubocop/).
30
30
 
31
- [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop)
31
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop/)
32
32
 
33
33
  **This documentation tracks the `master` branch of RuboCop. Some of
34
34
  the features and settings discussed here might not be available in
@@ -97,13 +97,13 @@ specific RuboCop release.**
97
97
 
98
98
  **RuboCop**'s installation is pretty standard:
99
99
 
100
- ```
100
+ ```sh
101
101
  $ gem install rubocop
102
102
  ```
103
103
 
104
104
  If you'd rather install RuboCop using `bundler`, don't require it in your `Gemfile`:
105
105
 
106
- ```
106
+ ```rb
107
107
  gem 'rubocop', require: false
108
108
  ```
109
109
 
@@ -112,13 +112,13 @@ gem 'rubocop', require: false
112
112
  Running `rubocop` with no arguments will check all Ruby source files
113
113
  in the current directory:
114
114
 
115
- ```
115
+ ```sh
116
116
  $ rubocop
117
117
  ```
118
118
 
119
119
  Alternatively you can pass `rubocop` a list of files and directories to check:
120
120
 
121
- ```
121
+ ```sh
122
122
  $ rubocop app spec lib/something.rb
123
123
  ```
124
124
 
@@ -158,7 +158,7 @@ test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
158
158
 
159
159
  For more details check the available command-line options:
160
160
 
161
- ```
161
+ ```sh
162
162
  $ rubocop -h
163
163
  ```
164
164
 
@@ -171,6 +171,7 @@ Command flag | Description
171
171
  `-C/--cache` | Store and reuse results for faster operation.
172
172
  `-d/--debug` | Displays some extra debug output.
173
173
  `-D/--display-cop-names` | Displays cop names in offense messages.
174
+ `-E/--extra-details` | Displays extra details in offense messages.
174
175
  `-c/--config` | Run with specified config file.
175
176
  `-f/--format` | Choose a formatter.
176
177
  `-o/--out` | Write output to a file instead of STDOUT.
@@ -207,7 +208,7 @@ code. RuboCop implements in a portable way all built-in MRI lint
207
208
  checks (`ruby -wc`) and adds a lot of extra lint checks of its
208
209
  own. You can run only the lint cops like this:
209
210
 
210
- ```
211
+ ```sh
211
212
  $ rubocop -l
212
213
  ```
213
214
 
@@ -230,7 +231,7 @@ Rails cops are specific to the Ruby on Rails framework. Unlike style
230
231
  and lint cops they are not used by default and you have to request them
231
232
  specifically:
232
233
 
233
- ```
234
+ ```sh
234
235
  $ rubocop -R
235
236
  ```
236
237
 
@@ -269,6 +270,11 @@ Metrics/LineLength:
269
270
 
270
271
  ### Inheritance
271
272
 
273
+ RuboCop supports inheriting configuration from one or more supplemental
274
+ configuration files at runtime.
275
+
276
+ #### Inheriting from another configuration file in the project
277
+
272
278
  The optional `inherit_from` directive is used to include configuration
273
279
  from one or more files. This makes it possible to have the common
274
280
  project settings in the `.rubocop.yml` file at the project root, and
@@ -286,6 +292,57 @@ inherit_from:
286
292
  - ../conf/.rubocop.yml
287
293
  ```
288
294
 
295
+ ### Inheriting configuration from a remote URL
296
+
297
+ The optional `inherit_from` directive can contain a full url to a remote
298
+ file. This makes it possible to have common project settings stored on a http
299
+ server and shared between many projects. You can inherit from both remote and
300
+ local files in the same config.
301
+
302
+ The same inheritance rules apply to remote URLs and inheriting from local
303
+ files where the first file in the list has the lowest precedence and the
304
+ last one has the highest. The format for multiple inheritance using URLs is:
305
+
306
+ ```yaml
307
+ inherit_from:
308
+ - http://www.example.com/rubocop.yml
309
+ - ../.rubocop.yml
310
+ ```
311
+
312
+ #### Inheriting configuration from a dependency gem
313
+
314
+ The optional `inherit_gem` directive is used to include configuration from
315
+ one or more gems external to the current project. This makes it possible to
316
+ inherit a shared dependency's RuboCop configuration that can be used from
317
+ multiple disparate projects.
318
+
319
+ Configurations inherited in this way will be essentially *prepended* to the
320
+ `inherit_from` directive, such that the `inherit_gem` configurations will be
321
+ loaded first, then the `inherit_from` relative file paths will be loaded
322
+ (overriding the configurations from the gems), and finally the remaining
323
+ directives in the configuration file will supersede any of the inherited
324
+ configurations. This means the configurations inherited from one or more gems
325
+ have the lowest precedence of inheritance.
326
+
327
+ The directive should be formatted as a YAML Hash using the gem name as the
328
+ key and the relative path within the gem as the value:
329
+
330
+ ```yaml
331
+ inherit_gem:
332
+ rubocop: config/default.yml
333
+ my-shared-gem: .rubocop.yml
334
+ cucumber: conf/rubocop.yml
335
+ ```
336
+
337
+ **Note**: If the shared dependency is declared using a [Bundler](http://bundler.io/)
338
+ Gemfile and the gem was installed using `bundle install`, it would be
339
+ necessary to also invoke RuboCop using Bundler in order to find the
340
+ dependency's installation path at runtime:
341
+
342
+ ```
343
+ $ bundle exec rubocop <options...>
344
+ ```
345
+
289
346
  ### Defaults
290
347
 
291
348
  The file
@@ -404,6 +461,20 @@ Metrics/CyclomaticComplexity:
404
461
  Severity: warning
405
462
  ```
406
463
 
464
+ ## Details
465
+
466
+ Individual cops can be embellished with extra details in offense messages:
467
+
468
+ ```yaml
469
+ Metrics/LineLength:
470
+ Details: >-
471
+ If lines are too short, text becomes hard to read because you must
472
+ constantly jump from one line to the next while reading. If lines are too
473
+ long, the line jumping becomes too hard because you "lose the line" while
474
+ going back to the start of the next line. 80 characters is a good
475
+ compromise.
476
+ ```
477
+
407
478
  #### AutoCorrect
408
479
 
409
480
  Cops that support the `--auto-correct` option can have that support
@@ -473,7 +544,7 @@ You can enable multiple formatters at the same time by specifying `-f/--format`
473
544
  The `-o/--out` option applies to the previously specified `-f/--format`,
474
545
  or the default `progress` format if no `-f/--format` is specified before the `-o/--out` option.
475
546
 
476
- ```bash
547
+ ```sh
477
548
  # Simple format to $stdout.
478
549
  $ rubocop --format simple
479
550
 
@@ -508,7 +579,7 @@ and at the end it displays all detected offenses in the `clang` format.
508
579
  A `.` represents a clean file, and each of the capital letters means
509
580
  the severest offense (convention, warning, error or fatal) found in a file.
510
581
 
511
- ```
582
+ ```sh
512
583
  $ rubocop
513
584
  Inspecting 26 files
514
585
  ..W.C....C..CWCW.C...WC.CC
@@ -528,7 +599,7 @@ lib/foo.rb:6:5: C: Missing top-level class documentation comment.
528
599
 
529
600
  The `clang` formatter displays the offenses in a manner similar to `clang`:
530
601
 
531
- ```
602
+ ```sh
532
603
  $ rubocop test.rb
533
604
  Inspecting 1 file
534
605
  W
@@ -555,9 +626,9 @@ test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
555
626
 
556
627
  The `fuubar` style formatter displays a progress bar
557
628
  and shows details of offenses in the `clang` format as soon as they are detected.
558
- This is inspired by the [Fuubar](https://github.com/jeffkreeftmeijer/fuubar) formatter for RSpec.
629
+ This is inspired by the [Fuubar](https://github.com/thekompanee/fuubar) formatter for RSpec.
559
630
 
560
- ```
631
+ ```sh
561
632
  $ rubocop --format fuubar
562
633
  lib/foo.rb.rb:1:1: C: Use snake_case for methods and variables.
563
634
  def badName
@@ -574,7 +645,7 @@ lib/bar.rb:13:14: W: File.exists? is deprecated in favor of File.exist?.
574
645
 
575
646
  The `emacs` formatter displays the offenses in a format suitable for consumption by `Emacs` (and possibly other tools).
576
647
 
577
- ```
648
+ ```sh
578
649
  $ rubocop --format emacs test.rb
579
650
  /Users/bozhidar/projects/test.rb:1:1: C: Use snake_case for methods and variables.
580
651
  /Users/bozhidar/projects/test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
@@ -585,7 +656,7 @@ $ rubocop --format emacs test.rb
585
656
 
586
657
  The name of the formatter says it all :-)
587
658
 
588
- ```
659
+ ```sh
589
660
  $ rubocop --format simple test.rb
590
661
  == test.rb ==
591
662
  C: 1: 5: Use snake_case for method names.
@@ -604,7 +675,7 @@ Sometimes you might want to just open all files with offenses in your
604
675
  favorite editor. This formatter outputs just the names of the files
605
676
  with offenses in them and makes it possible to do something like:
606
677
 
607
- ```
678
+ ```sh
608
679
  $ rubocop --format files | xargs vim
609
680
  ```
610
681
 
@@ -669,7 +740,7 @@ see where most of your style cleanup is going to be spent.
669
740
  With this in mind, you can use the offense count formatter to outline the offended
670
741
  cops and the number of offenses found for each by running:
671
742
 
672
- ```
743
+ ```sh
673
744
  $ rubocop --format offenses
674
745
 
675
746
  87 Documentation
@@ -691,7 +762,7 @@ $ rubocop --format offenses
691
762
 
692
763
  Useful for CI environments. It will create an HTML report like [this](http://f.cl.ly/items/0M3029412x3O091a1X1R/expected.html).
693
764
 
694
- ```
765
+ ```sh
695
766
  $ rubocop --format html -o rubocop.html
696
767
  ```
697
768
 
@@ -714,7 +785,7 @@ RuboCop supports the following Ruby implementations:
714
785
  Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
715
786
  and quickly jump between problems in your code.
716
787
 
717
- [flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports
788
+ [flycheck](https://github.com/flycheck/flycheck) > 0.9 also supports
718
789
  RuboCop and uses it by default when available.
719
790
 
720
791
  ### Vim
@@ -733,7 +804,7 @@ useful.
733
804
 
734
805
  ### Brackets
735
806
 
736
- The [brackets-rubocop](https://github.com/smockle/brackets-rubocop)
807
+ The [brackets-rubocop](https://github.com/smockle-archive/brackets-rubocop)
737
808
  extension displays RuboCop results in Brackets.
738
809
  It can be installed via the extension manager in Brackets.
739
810
 
@@ -749,7 +820,7 @@ The [atom-lint](https://github.com/yujinakayama/atom-lint) package
749
820
  runs RuboCop and highlights the offenses in Atom.
750
821
 
751
822
  You can also use the [linter-rubocop](https://github.com/AtomLinter/linter-rubocop)
752
- plugin for Atom's [linter](https://github.com/AtomLinter/Linter).
823
+ plugin for Atom's [linter](https://github.com/atom-community/linter).
753
824
 
754
825
  ### LightTable
755
826
 
@@ -836,6 +907,7 @@ are no changes in:
836
907
  * RuboCop configuration for the file
837
908
  * the options given to `rubocop`, with some exceptions that have no
838
909
  bearing on which offenses are reported
910
+ * the Ruby version used to invoke `rubocop`
839
911
  * version of the `rubocop` program (or to be precise, anything in the
840
912
  source code of the invoked `rubocop` program)
841
913
 
@@ -910,9 +982,9 @@ or implement all formatter API methods by duck typing.
910
982
 
911
983
  Please see the documents below for more formatter API details.
912
984
 
913
- * [RuboCop::Formatter::BaseFormatter](http://rubydoc.info/gems/rubocop/RuboCop/Formatter/BaseFormatter)
914
- * [RuboCop::Cop::Offense](http://rubydoc.info/gems/rubocop/RuboCop/Cop/Offense)
915
- * [Parser::Source::Range](http://rubydoc.info/github/whitequark/parser/Parser/Source/Range)
985
+ * [RuboCop::Formatter::BaseFormatter](http://www.rubydoc.info/gems/rubocop/RuboCop/Formatter/BaseFormatter)
986
+ * [RuboCop::Cop::Offense](http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Offense)
987
+ * [Parser::Source::Range](http://www.rubydoc.info/github/whitequark/parser/Parser/Source/Range)
916
988
 
917
989
  #### Using Custom Formatter in Command Line
918
990
 
@@ -921,7 +993,7 @@ You can tell RuboCop to use your custom formatter with a combination of
921
993
  For example, when you have defined `MyCustomFormatter` in
922
994
  `./path/to/my_custom_formatter.rb`, you would type this command:
923
995
 
924
- ```
996
+ ```sh
925
997
  $ rubocop --require ./path/to/my_custom_formatter --format MyCustomFormatter
926
998
  ```
927
999
 
@@ -944,7 +1016,7 @@ The logo is licensed under a
944
1016
 
945
1017
  ## Contributors
946
1018
 
947
- Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
1019
+ Here's a [list](https://github.com/bbatsov/rubocop/graphs/contributors) of
948
1020
  all the people who have contributed to the development of RuboCop.
949
1021
 
950
1022
  I'm extremely grateful to each and every one of them!
@@ -961,9 +1033,9 @@ welcome. GitHub pull requests are even better! :-)
961
1033
 
962
1034
  You can also support my work on RuboCop via
963
1035
  [Salt](https://salt.bountysource.com/teams/rubocop) and
964
- [Gratipay](https://www.gratipay.com/rubocop).
1036
+ [Gratipay](https://gratipay.com/rubocop/).
965
1037
 
966
- [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop)
1038
+ [![Support via Gratipay](https://cdn.rawgit.com/gratipay/gratipay-badge/2.1.3/dist/gratipay.png)](https://gratipay.com/rubocop/)
967
1039
 
968
1040
  ## Mailing List
969
1041
 
@@ -38,6 +38,10 @@ AllCops:
38
38
  # behavior by overriding DisplayStyleGuide, or by giving the
39
39
  # -S/--display-style-guide option.
40
40
  DisplayStyleGuide: false
41
+ # Extra details are not displayed in offense messages by default. Change
42
+ # behaviour by overriding ExtraDetails, or by giving the
43
+ # -E/--extra-details option.
44
+ ExtraDetails: false
41
45
  # Additional cops that do not reference a style guide rule may be enabled by
42
46
  # default. Change behavior by overriding StyleGuideCopsOnly, or by giving
43
47
  # the --only-guide-cops option.
@@ -183,6 +187,11 @@ Style/BlockDelimiters:
183
187
  # method) but exceptions are permitted in the `ProceduralMethods`,
184
188
  # `FunctionalMethods` and `IgnoredMethods` sections below.
185
189
  - semantic
190
+ # The `braces_for_chaining` style enforces braces around single line blocks
191
+ # and do..end around multi-line blocks, except for multi-line blocks whose
192
+ # return value is being chained with another method (in which case braces
193
+ # are enforced).
194
+ - braces_for_chaining
186
195
  ProceduralMethods:
187
196
  # Methods that are known to be procedural in nature but look functional from
188
197
  # their usage, e.g.
@@ -485,6 +494,7 @@ Style/IndentHash:
485
494
  SupportedStyles:
486
495
  - special_inside_parentheses
487
496
  - consistent
497
+ - align_braces
488
498
 
489
499
  Style/LambdaCall:
490
500
  EnforcedStyle: call
@@ -518,6 +528,7 @@ Style/MethodDefParentheses:
518
528
  SupportedStyles:
519
529
  - require_parentheses
520
530
  - require_no_parentheses
531
+ - require_no_parentheses_except_multiline
521
532
 
522
533
  Style/MethodName:
523
534
  EnforcedStyle: snake_case
@@ -566,16 +577,20 @@ Style/PercentQLiterals:
566
577
  - upper_case_q # Always use %Q
567
578
 
568
579
  Style/PredicateName:
569
- # Predicate name prefices.
580
+ # Predicate name prefixes.
570
581
  NamePrefix:
571
582
  - is_
572
583
  - has_
573
584
  - have_
574
- # Predicate name prefices that should be removed.
585
+ # Predicate name prefixes that should be removed.
575
586
  NamePrefixBlacklist:
576
587
  - is_
577
588
  - has_
578
589
  - have_
590
+ # Predicate names which, despite having a blacklisted prefix, or no ?,
591
+ # should still be accepted
592
+ NameWhitelist:
593
+ - is_a?
579
594
 
580
595
  Style/RaiseArgs:
581
596
  EnforcedStyle: exploded
@@ -624,6 +639,12 @@ Style/SingleLineBlockParams:
624
639
  Style/SingleLineMethods:
625
640
  AllowIfMethodIsEmpty: true
626
641
 
642
+ Style/StabbyLambdaParentheses:
643
+ EnforcedStyle: require_parentheses
644
+ SupportedStyles:
645
+ - require_parentheses
646
+ - require_no_parentheses
647
+
627
648
  Style/StringLiterals:
628
649
  EnforcedStyle: single_quotes
629
650
  SupportedStyles:
@@ -843,6 +864,15 @@ Lint/DefEndAlignment:
843
864
  - def
844
865
  AutoCorrect: false
845
866
 
867
+ # Checks for unused block arguments
868
+ Lint/UnusedBlockArgument:
869
+ IgnoreEmptyBlocks: true
870
+
871
+ # Checks for unused method arguments.
872
+ Lint/UnusedMethodArgument:
873
+ AllowUnusedKeywordArguments: false
874
+ IgnoreEmptyMethods: true
875
+
846
876
  ##################### Rails ##################################
847
877
 
848
878
  Rails/ActionFilter: