rubocop 0.20.1 → 0.21.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 (128) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +16 -4
  4. data/config/default.yml +37 -10
  5. data/config/enabled.yml +25 -7
  6. data/lib/rubocop.rb +15 -19
  7. data/lib/rubocop/cli.rb +2 -2
  8. data/lib/rubocop/config.rb +40 -3
  9. data/lib/rubocop/config_loader.rb +6 -37
  10. data/lib/rubocop/config_store.rb +0 -1
  11. data/lib/rubocop/cop/commissioner.rb +12 -9
  12. data/lib/rubocop/cop/cop.rb +17 -5
  13. data/lib/rubocop/cop/force.rb +41 -0
  14. data/lib/rubocop/cop/ignored_node.rb +10 -10
  15. data/lib/rubocop/cop/lint/ambiguous_operator.rb +1 -1
  16. data/lib/rubocop/cop/lint/ambiguous_regexp_literal.rb +2 -2
  17. data/lib/rubocop/cop/lint/block_alignment.rb +2 -2
  18. data/lib/rubocop/cop/lint/condition_position.rb +2 -0
  19. data/lib/rubocop/cop/lint/debugger.rb +17 -3
  20. data/lib/rubocop/cop/lint/end_alignment.rb +3 -11
  21. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
  22. data/lib/rubocop/cop/lint/rescue_exception.rb +11 -0
  23. data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +4 -6
  24. data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +39 -0
  25. data/lib/rubocop/cop/lint/unused_block_argument.rb +81 -0
  26. data/lib/rubocop/cop/lint/unused_method_argument.rb +52 -0
  27. data/lib/rubocop/cop/lint/useless_assignment.rb +6 -8
  28. data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +6 -0
  29. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  30. data/lib/rubocop/cop/lint/void.rb +1 -1
  31. data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +2 -2
  32. data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +7 -3
  33. data/lib/rubocop/cop/mixin/check_assignment.rb +11 -0
  34. data/lib/rubocop/cop/mixin/check_methods.rb +12 -0
  35. data/lib/rubocop/cop/mixin/percent_literal.rb +26 -0
  36. data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -2
  37. data/lib/rubocop/cop/mixin/string_help.rb +0 -4
  38. data/lib/rubocop/cop/rails/delegate.rb +109 -0
  39. data/lib/rubocop/cop/style/align_hash.rb +3 -3
  40. data/lib/rubocop/cop/style/class_and_module_children.rb +2 -2
  41. data/lib/rubocop/cop/style/colon_method_call.rb +2 -2
  42. data/lib/rubocop/cop/style/dot_position.rb +1 -1
  43. data/lib/rubocop/cop/style/encoding.rb +44 -16
  44. data/lib/rubocop/cop/style/indentation_width.rb +29 -19
  45. data/lib/rubocop/cop/style/lambda_call.rb +1 -1
  46. data/lib/rubocop/cop/style/line_end_concatenation.rb +1 -1
  47. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +3 -21
  48. data/lib/rubocop/cop/style/predicate_name.rb +1 -1
  49. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  50. data/lib/rubocop/cop/style/redundant_begin.rb +18 -2
  51. data/lib/rubocop/cop/style/redundant_self.rb +2 -2
  52. data/lib/rubocop/cop/style/regexp_literal.rb +29 -37
  53. data/lib/rubocop/cop/style/space_after_method_name.rb +1 -1
  54. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  55. data/lib/rubocop/cop/style/trailing_blank_lines.rb +37 -23
  56. data/lib/rubocop/cop/style/trailing_comma.rb +2 -3
  57. data/lib/rubocop/cop/style/trivial_accessors.rb +40 -4
  58. data/lib/rubocop/cop/style/unneeded_capital_w.rb +29 -0
  59. data/lib/rubocop/cop/team.rb +10 -2
  60. data/lib/rubocop/cop/util.rb +2 -2
  61. data/lib/rubocop/cop/{variable_inspector.rb → variable_force.rb} +45 -37
  62. data/lib/rubocop/cop/{variable_inspector → variable_force}/assignment.rb +1 -1
  63. data/lib/rubocop/cop/{variable_inspector → variable_force}/locatable.rb +1 -1
  64. data/lib/rubocop/cop/{variable_inspector → variable_force}/reference.rb +13 -1
  65. data/lib/rubocop/cop/{variable_inspector → variable_force}/scope.rb +9 -1
  66. data/lib/rubocop/cop/{variable_inspector → variable_force}/variable.rb +14 -4
  67. data/lib/rubocop/cop/{variable_inspector → variable_force}/variable_table.rb +1 -1
  68. data/lib/rubocop/file_inspector.rb +3 -1
  69. data/lib/rubocop/formatter/base_formatter.rb +1 -1
  70. data/lib/rubocop/formatter/disabled_config_formatter.rb +2 -2
  71. data/lib/rubocop/formatter/disabled_lines_formatter.rb +2 -2
  72. data/lib/rubocop/formatter/offense_count_formatter.rb +11 -10
  73. data/lib/rubocop/formatter/progress_formatter.rb +2 -2
  74. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -1
  75. data/lib/rubocop/options.rb +74 -58
  76. data/lib/rubocop/path_util.rb +17 -2
  77. data/lib/rubocop/rake_task.rb +23 -5
  78. data/lib/rubocop/version.rb +1 -1
  79. data/relnotes/v0.21.0.md +45 -0
  80. data/rubocop-todo.yml +6 -6
  81. data/rubocop.gemspec +1 -1
  82. data/spec/rubocop/cli_spec.rb +170 -59
  83. data/spec/rubocop/config_spec.rb +48 -3
  84. data/spec/rubocop/config_store_spec.rb +3 -3
  85. data/spec/rubocop/cop/commissioner_spec.rb +9 -7
  86. data/spec/rubocop/cop/cop_spec.rb +0 -2
  87. data/spec/rubocop/cop/force_spec.rb +29 -0
  88. data/spec/rubocop/cop/lint/ambiguous_operator_spec.rb +2 -2
  89. data/spec/rubocop/cop/lint/ambiguous_regexp_literal_spec.rb +1 -1
  90. data/spec/rubocop/cop/lint/block_alignment_spec.rb +24 -24
  91. data/spec/rubocop/cop/lint/condition_position_spec.rb +7 -5
  92. data/spec/rubocop/cop/lint/debugger_spec.rb +26 -9
  93. data/spec/rubocop/cop/lint/end_alignment_spec.rb +6 -3
  94. data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +7 -6
  95. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +36 -0
  96. data/spec/rubocop/cop/lint/shadowing_outer_local_variable_spec.rb +4 -4
  97. data/spec/rubocop/cop/lint/underscore_prefixed_variable_name_spec.rb +179 -0
  98. data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +147 -0
  99. data/spec/rubocop/cop/lint/unused_method_argument_spec.rb +140 -0
  100. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +50 -48
  101. data/spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb +1 -1
  102. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +2 -0
  103. data/spec/rubocop/cop/rails/delegate_spec.rb +152 -0
  104. data/spec/rubocop/cop/style/encoding_spec.rb +131 -36
  105. data/spec/rubocop/cop/style/indentation_width_spec.rb +79 -0
  106. data/spec/rubocop/cop/style/redundant_begin_spec.rb +32 -0
  107. data/spec/rubocop/cop/style/regexp_literal_spec.rb +83 -13
  108. data/spec/rubocop/cop/style/string_literals_spec.rb +9 -3
  109. data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +65 -25
  110. data/spec/rubocop/cop/style/trivial_accessors_spec.rb +76 -0
  111. data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +85 -0
  112. data/spec/rubocop/cop/team_spec.rb +43 -0
  113. data/spec/rubocop/cop/{variable_inspector → variable_force}/assignment_spec.rb +3 -3
  114. data/spec/rubocop/cop/{variable_inspector → variable_force}/locatable_spec.rb +3 -3
  115. data/spec/rubocop/cop/{variable_inspector → variable_force}/scope_spec.rb +30 -2
  116. data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_spec.rb +12 -27
  117. data/spec/rubocop/cop/{variable_inspector → variable_force}/variable_table_spec.rb +1 -1
  118. data/spec/rubocop/cop/{variable_inspector_spec.rb → variable_force_spec.rb} +4 -8
  119. data/spec/rubocop/formatter/base_formatter_spec.rb +2 -2
  120. data/spec/rubocop/formatter/offense_count_formatter_spec.rb +1 -1
  121. data/spec/rubocop/formatter/progress_formatter_spec.rb +1 -1
  122. data/spec/rubocop/options_spec.rb +2 -2
  123. data/spec/rubocop/path_util_spec.rb +47 -14
  124. data/spec/spec_helper.rb +9 -3
  125. data/spec/support/file_helper.rb +2 -0
  126. metadata +43 -26
  127. data/lib/rubocop/cop/style/final_newline.rb +0 -29
  128. data/spec/rubocop/cop/style/final_newline_spec.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e091003352d55c98a9579dc743d9ab5542a32229
4
- data.tar.gz: a1840b93e9ee0d9cac37c4a9e3749acf17fca02b
3
+ metadata.gz: 18bb71a6ddd6cdd142c68e789a70b0baf5704d79
4
+ data.tar.gz: f239d5e80896196e17211fa6834e3d7a261cb0e7
5
5
  SHA512:
6
- metadata.gz: 6f9ac51993ab31b7b6c0a9ffdd1ab5136a024cf5d341891e71ad5af0f1ef08cbb09f77759dbe8aefd0a64f04a306b64649f1c53c6977b0c2d4436786d04ed5ef
7
- data.tar.gz: 8a78d285ece4159fade45e13ee06af7286632a1176130760dbd8c2599efc288ee6d7abf88775a1a3127e2879b2fe475219ed19fadd069125a7763ee00352e724
6
+ metadata.gz: 1bac37f99223a0c20c2e7ba29c4dbbc1fc907962102962679153f6a55c5f1b1a5bdb2d482029aef3b7abf63242a31ebce47be9ea55f40ba3ccb858bf8951f69e
7
+ data.tar.gz: acf9e58f556f5fcc298584233e2ed12afc8ebe7f434fc7a0ac747a5f0cb1ef1579d5d14e9e4dad065eec13c9e3d39bd103b85790d4ce455f92f6210f026d1650
data/CHANGELOG.md CHANGED
@@ -2,6 +2,48 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.21.0 (24/04/2014)
6
+
7
+ ### New features
8
+
9
+ * [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededCapitalW` checks for `%W` when interpolation not necessary and `%w` would do. ([@sfeldon][])
10
+ * [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnderscorePrefixedVariableName` checks for `_`-prefixed variables that are actually used. ([@yujinakayama][])
11
+ * [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnusedMethodArgument` checks for unused method arguments. ([@yujinakayama][])
12
+ * [#934](https://github.com/bbatsov/rubocop/issues/934): New cop `UnusedBlockArgument` checks for unused block arguments. ([@yujinakayama][])
13
+ * [#964](https://github.com/bbatsov/rubocop/issues/964): `RedundantBegin` cop does auto-correction. ([@tamird][])
14
+ * [#966](https://github.com/bbatsov/rubocop/issues/966): `RescueException` cop does auto-correction. ([@tamird][])
15
+ * [#967](https://github.com/bbatsov/rubocop/issues/967): `TrivialAccessors` cop does auto-correction. ([@tamird][])
16
+ * [#963](https://github.com/bbatsov/rubocop/issues/963): Add `AllowDSLWriters` options to `TrivialAccessors`. ([@tamird][])
17
+ * [#969](https://github.com/bbatsov/rubocop/issues/969): Let the `Debugger` cop check for forgotten calls to byebug. ([@bquorning][])
18
+ * [#971](https://github.com/bbatsov/rubocop/issues/971): Configuration format deprecation warnings include the path to the problematic config file. ([@bcobb][])
19
+ * [#490](https://github.com/bbatsov/rubocop/issues/490): Add EnforcedStyle config option to TrailingBlankLines. ([@jonas054][])
20
+ * Add `auto_correct` task to Rake integration. ([@irrationalfab][])
21
+ * [#986](https://github.com/bbatsov/rubocop/issues/986): The `--only` option can take a comma-separated list of cops. ([@jonas054][])
22
+ * New Rails cop `Delegate` that checks for delegations that could be replaced by the `delegate` method. ([@geniou][])
23
+ * Add configuration to `Encoding` cop to only enforce encoding comment if there are non ASCII characters. ([@geniou][])
24
+
25
+ ### Changes
26
+
27
+ * Removed `FinalNewline` cop as its check is now performed by `TrailingBlankLines`. ([@jonas054][])
28
+ * [#1011](https://github.com/bbatsov/rubocop/issues/1011): Pattern matching with `Dir#[]` for config parameters added. ([@jonas054][])
29
+
30
+ ### Bugs fixed
31
+
32
+ * Update description on `LineEndConcatenation` cop. ([@mockdeep][])
33
+ * [#978](https://github.com/bbatsov/rubocop/issues/978): Fix regression in `IndentationWidth` handling method calls. ([@tamird][])
34
+ * [#976](https://github.com/bbatsov/rubocop/issues/976): Fix `EndAlignment` not handling element assignment correctly. ([@tamird][])
35
+ * [#976](https://github.com/bbatsov/rubocop/issues/976): Fix `IndentationWidth` not handling element assignment correctly. ([@tamird][])
36
+ * [#800](https://github.com/bbatsov/rubocop/issues/800): Do not report `[Corrected]` in `--auto-correct` mode if correction wasn't done. ([@jonas054][])
37
+ * [#968](https://github.com/bbatsov/rubocop/issues/968): Fix bug when running Rubocop with `-c .rubocop.yml`. ([@bquorning][])
38
+ * [#975](https://github.com/bbatsov/rubocop/pull/975): Fix infinite correction in `IndentationWidth`. ([@jonas054][])
39
+ * [#986](https://github.com/bbatsov/rubocop/issues/986): When `--lint` is used together with `--only`, all lint cops are run in addition to the given cops. ([@jonas054][])
40
+ * [#997](https://github.com/bbatsov/rubocop/issues/997): Fix handling of file paths for matching against `Exclude` property when `rubocop .` is called. ([@jonas054][])
41
+ * [#1000](https://github.com/bbatsov/rubocop/issues/1000): Support modifier (e.g., `private`) and `def` on the same line (Ruby >= 2.1) in `IndentationWidth`. ([@jonas054][])
42
+ * [#1001](https://github.com/bbatsov/rubocop/issues/1001): Fix `--auto-gen-config` logic for `RegexpLiteral`. ([@jonas054][])
43
+ * [#993](https://github.com/bbatsov/rubocop/issues/993): Do not report any offenses for the contents of an empty file. ([@jonas054][])
44
+ * [#1016](https://github.com/bbatsov/rubocop/issues/1016): Fix a false positive in `ConditionPosition` regarding statement modifiers. ([@bbatsov][])
45
+ * [#1014](https://github.com/bbatsov/rubocop/issues/1014): Fix handling of strings nested in `dstr` nodes. ([@bbatsov][])
46
+
5
47
  ## 0.20.1 (05/04/2014)
6
48
 
7
49
  ### Bugs fixed
@@ -849,3 +891,7 @@
849
891
  [@tamird]: https://github.com/tamird
850
892
  [@fshowalter]: https://github.com/fshowalter
851
893
  [@cschramm]: https://github.com/cschramm
894
+ [@bquorning]: https://github.com/bquorning
895
+ [@bcobb]: https://github.com/bcobb
896
+ [@irrationalfab]: https://github.com/irrationalfab
897
+ [@sfeldon]: https://github.com/sfeldon
data/README.md CHANGED
@@ -138,7 +138,7 @@ Command flag | Description
138
138
  `-R/--rails` | Run extra Rails cops
139
139
  `-l/--lint` | Run only lint cops
140
140
  `-a/--auto-correct` | Auto-correct certain offenses *Note:* Experimental - use with caution
141
- `--only` | Run only the specified cop
141
+ `--only` | Run only the specified cop(s)
142
142
  `--auto-gen-config` | Generate a configuration file acting as a TODO list
143
143
  `--show-cops` | Shows available cops and their configuration
144
144
  `--fail-level` | Minimum severity for exit with error code
@@ -166,6 +166,9 @@ own. You can run only the lint cops like this:
166
166
  $ rubocop -l
167
167
  ```
168
168
 
169
+ The `-l`/`--lint` option can be used together with `--only` to run all the
170
+ enabled lint cops plus a selection of other cops.
171
+
169
172
  Disabling any of the lint cops is generally a bad idea.
170
173
 
171
174
  #### Rails
@@ -247,9 +250,9 @@ AllCops:
247
250
  - Rakefile
248
251
  - config.ru
249
252
  Exclude:
250
- - db/**
251
- - config/**
252
- - script/**
253
+ - db/**/*
254
+ - config/**/*
255
+ - script/**/*
253
256
  - !ruby/regexp /old_and_unused\.rb$/
254
257
 
255
258
  # other configuration
@@ -258,6 +261,15 @@ AllCops:
258
261
 
259
262
  Files and directories are specified relative to the `.rubocop.yml` file.
260
263
 
264
+ **Note**: Patterns that are just a file name, e.g. `Rakefile`, will match
265
+ that file name in any directory, but this pattern style deprecated. The
266
+ correct way to match the file in any directory, including the current, is
267
+ `**/Rakefile`.
268
+
269
+ **Note**: The pattern `config/**` will match any file recursively under
270
+ `config`, but this pattern style is deprecated and should be replaced by
271
+ `config/**/*`.
272
+
261
273
  **Note**: The `Exclude` parameter is special. It is valid for the
262
274
  directory tree starting where it is defined. It is not shadowed by the
263
275
  setting of `Exclude` in other `.rubocop.yml` files in
data/config/default.yml CHANGED
@@ -155,6 +155,12 @@ ClassLength:
155
155
 
156
156
  # Align with the style guide.
157
157
  CollectionMethods:
158
+ # Mapping from undesired method to desired_method
159
+ # e.g. to use `detect` over `find`:
160
+ #
161
+ # CollectionMethods:
162
+ # PreferredMethods:
163
+ # find: detect
158
164
  PreferredMethods:
159
165
  collect: 'map'
160
166
  collect!: 'map!'
@@ -188,6 +194,13 @@ EmptyLineBetweenDefs:
188
194
  # need an empty line between them.
189
195
  AllowAdjacentOneLineDefs: false
190
196
 
197
+ # Checks whether the source file has a utf-8 encoding comment or not
198
+ Encoding:
199
+ EnforcedStyle: always
200
+ SupportedStyles:
201
+ - when_needed
202
+ - always
203
+
191
204
  # Align ends correctly.
192
205
  EndAlignment:
193
206
  # The value `keyword` means that `end` should be aligned with the matching
@@ -202,9 +215,9 @@ EndAlignment:
202
215
 
203
216
  FileName:
204
217
  Exclude:
205
- - Rakefile
206
- - Gemfile
207
- - Capfile
218
+ - '**/Rakefile'
219
+ - '**/Gemfile'
220
+ - '**/Capfile'
208
221
 
209
222
  # Checks use of for or each in multiline loops.
210
223
  For:
@@ -377,6 +390,12 @@ SpaceInsideHashLiteralBraces:
377
390
  - space
378
391
  - no_space
379
392
 
393
+ TrailingBlankLines:
394
+ EnforcedStyle: final_newline
395
+ SupportedStyles:
396
+ - final_newline
397
+ - final_blank_line
398
+
380
399
  TrailingComma:
381
400
  EnforcedStyleForMultiline: no_comma
382
401
  SupportedStyles:
@@ -388,6 +407,15 @@ TrailingComma:
388
407
  TrivialAccessors:
389
408
  ExactNameMatch: false
390
409
  AllowPredicates: false
410
+ # Allows trivial writers that don't end in an equal sign. e.g.
411
+ #
412
+ # def on_exception(action)
413
+ # @on_exception=action
414
+ # end
415
+ # on_exception :restart
416
+ #
417
+ # Commonly used in DSLs
418
+ AllowDSLWriters: false
391
419
  Whitelist:
392
420
  - to_ary
393
421
  - to_a
@@ -427,25 +455,24 @@ ActionFilter:
427
455
  - action
428
456
  - filter
429
457
  Include:
430
- - app/controllers/*.rb
458
+ - app/controllers/**/*.rb
431
459
 
432
460
  DefaultScope:
433
461
  Include:
434
- - app/models/*.rb
462
+ - app/models/**/*.rb
435
463
 
436
464
  HasAndBelongsToMany:
437
465
  Include:
438
- - app/models/*.rb
466
+ - app/models/**/*.rb
439
467
 
440
468
  ReadWriteAttribute:
441
469
  Include:
442
- - app/models/*.rb
470
+ - app/models/**/*.rb
443
471
 
444
472
  ScopeArgs:
445
473
  Include:
446
- - app/models/*.rb
474
+ - app/models/**/*.rb
447
475
 
448
476
  Validation:
449
477
  Include:
450
- - app/models/*.rb
451
-
478
+ - app/models/**/*.rb
data/config/enabled.yml CHANGED
@@ -131,6 +131,10 @@ DefWithParentheses:
131
131
  Description: 'Use def with parentheses when there are arguments.'
132
132
  Enabled: true
133
133
 
134
+ Delegate:
135
+ Description: 'Prefer delegate method for delegations.'
136
+ Enabled: true
137
+
134
138
  DeprecatedHashMethods:
135
139
  Description: 'Checks for use of deprecated Hash methods.'
136
140
  Enabled: true
@@ -187,10 +191,6 @@ FileName:
187
191
  Description: 'Use snake_case for source file names.'
188
192
  Enabled: true
189
193
 
190
- FinalNewline:
191
- Description: 'Checks for a final newline in a source file.'
192
- Enabled: true
193
-
194
194
  FlipFlop:
195
195
  Description: 'Checks for flip flops'
196
196
  Enabled: true
@@ -254,7 +254,9 @@ LeadingCommentSpace:
254
254
  Enabled: true
255
255
 
256
256
  LineEndConcatenation:
257
- Description: 'Use \\ instead of + to concatenate two string literals at line end.'
257
+ Description: >-
258
+ Use \ instead of + or << to concatenate two string literals at
259
+ line end.
258
260
  Enabled: true
259
261
 
260
262
  LineLength:
@@ -502,7 +504,7 @@ Tab:
502
504
  Enabled: true
503
505
 
504
506
  TrailingBlankLines:
505
- Description: 'Checks for superfluous trailing blank lines.'
507
+ Description: 'Checks trailing blank lines and final newline.'
506
508
  Enabled: true
507
509
 
508
510
  TrailingComma:
@@ -523,6 +525,10 @@ UnlessElse:
523
525
  case first.
524
526
  Enabled: true
525
527
 
528
+ UnneededCapitalW:
529
+ Description: 'Checks for %W when interpolation is not needed.'
530
+ Enabled: true
531
+
526
532
  VariableInterpolation:
527
533
  Description: >-
528
534
  Don't interpolate global, instance and class variables
@@ -663,13 +669,25 @@ ShadowingOuterLocalVariable:
663
669
  SpaceBeforeFirstArg:
664
670
  Description: >-
665
671
  Put a space between a method name and the first argument
666
- in a method call wihtout parentheses.
672
+ in a method call without parentheses.
667
673
  Enabled: true
668
674
 
669
675
  StringConversionInInterpolation:
670
676
  Description: 'Checks for Object#to_s usage in string interpolation.'
671
677
  Enabled: true
672
678
 
679
+ UnderscorePrefixedVariableName:
680
+ Description: 'Do not use prefix `_` for a variable that is used.'
681
+ Enabled: true
682
+
683
+ UnusedBlockArgument:
684
+ Description: 'Checks for unused block arguments.'
685
+ Enabled: true
686
+
687
+ UnusedMethodArgument:
688
+ Description: 'Checks for unused method arguments.'
689
+ Enabled: true
690
+
673
691
  UnreachableCode:
674
692
  Description: 'Unreachable code.'
675
693
  Enabled: true
data/lib/rubocop.rb CHANGED
@@ -1,16 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Try to load the latest parser and fall back to the latest supported version,
4
- # if parser does not yet support the current Ruby version.
5
- # This should only be problem when using development Ruby builds.
6
- begin
7
- require 'parser/current'
8
- rescue NotImplementedError => error
9
- warn "Falling back to Ruby 2.1 parser: #{error.message}"
10
- require 'parser/ruby21'
11
- Parser::CurrentRuby = Parser::Ruby21
12
- end
13
-
3
+ require 'parser/current'
14
4
  require 'rainbow'
15
5
  # Rainbow 2.0 does not load the monkey-patch for String by default.
16
6
  require 'rainbow/ext/string' unless String.method_defined?(:color)
@@ -33,16 +23,17 @@ require 'rubocop/cop/ignored_node'
33
23
  require 'rubocop/cop/cop'
34
24
  require 'rubocop/cop/commissioner'
35
25
  require 'rubocop/cop/corrector'
26
+ require 'rubocop/cop/force'
36
27
  require 'rubocop/cop/team'
37
28
  require 'rubocop/cop/severity'
38
29
 
39
- require 'rubocop/cop/variable_inspector'
40
- require 'rubocop/cop/variable_inspector/locatable'
41
- require 'rubocop/cop/variable_inspector/variable'
42
- require 'rubocop/cop/variable_inspector/assignment'
43
- require 'rubocop/cop/variable_inspector/reference'
44
- require 'rubocop/cop/variable_inspector/scope'
45
- require 'rubocop/cop/variable_inspector/variable_table'
30
+ require 'rubocop/cop/variable_force'
31
+ require 'rubocop/cop/variable_force/locatable'
32
+ require 'rubocop/cop/variable_force/variable'
33
+ require 'rubocop/cop/variable_force/assignment'
34
+ require 'rubocop/cop/variable_force/reference'
35
+ require 'rubocop/cop/variable_force/scope'
36
+ require 'rubocop/cop/variable_force/variable_table'
46
37
 
47
38
  require 'rubocop/cop/mixin/annotation_comment'
48
39
  require 'rubocop/cop/mixin/array_syntax'
@@ -58,6 +49,7 @@ require 'rubocop/cop/mixin/if_node'
58
49
  require 'rubocop/cop/mixin/if_then_else'
59
50
  require 'rubocop/cop/mixin/negative_conditional'
60
51
  require 'rubocop/cop/mixin/parser_diagnostic'
52
+ require 'rubocop/cop/mixin/percent_literal'
61
53
  require 'rubocop/cop/mixin/safe_assignment'
62
54
  require 'rubocop/cop/mixin/surrounding_space'
63
55
  require 'rubocop/cop/mixin/space_inside'
@@ -91,7 +83,10 @@ require 'rubocop/cop/lint/shadowing_outer_local_variable'
91
83
  require 'rubocop/cop/lint/space_before_first_arg'
92
84
  require 'rubocop/cop/lint/string_conversion_in_interpolation'
93
85
  require 'rubocop/cop/lint/syntax'
86
+ require 'rubocop/cop/lint/underscore_prefixed_variable_name'
94
87
  require 'rubocop/cop/lint/unreachable_code'
88
+ require 'rubocop/cop/lint/unused_block_argument'
89
+ require 'rubocop/cop/lint/unused_method_argument'
95
90
  require 'rubocop/cop/lint/useless_access_modifier'
96
91
  require 'rubocop/cop/lint/useless_assignment'
97
92
  require 'rubocop/cop/lint/useless_comparison'
@@ -143,7 +138,6 @@ require 'rubocop/cop/style/end_block'
143
138
  require 'rubocop/cop/style/end_of_line'
144
139
  require 'rubocop/cop/style/even_odd'
145
140
  require 'rubocop/cop/style/file_name'
146
- require 'rubocop/cop/style/final_newline'
147
141
  require 'rubocop/cop/style/flip_flop'
148
142
  require 'rubocop/cop/style/for'
149
143
  require 'rubocop/cop/style/format_string'
@@ -221,6 +215,7 @@ require 'rubocop/cop/style/trailing_comma'
221
215
  require 'rubocop/cop/style/trailing_whitespace'
222
216
  require 'rubocop/cop/style/trivial_accessors'
223
217
  require 'rubocop/cop/style/unless_else'
218
+ require 'rubocop/cop/style/unneeded_capital_w'
224
219
  require 'rubocop/cop/style/variable_interpolation'
225
220
  require 'rubocop/cop/style/variable_name'
226
221
  require 'rubocop/cop/style/when_then'
@@ -230,6 +225,7 @@ require 'rubocop/cop/style/word_array'
230
225
 
231
226
  require 'rubocop/cop/rails/action_filter'
232
227
  require 'rubocop/cop/rails/default_scope'
228
+ require 'rubocop/cop/rails/delegate'
233
229
  require 'rubocop/cop/rails/has_and_belongs_to_many'
234
230
  require 'rubocop/cop/rails/output'
235
231
  require 'rubocop/cop/rails/read_write_attribute'
data/lib/rubocop/cli.rb CHANGED
@@ -24,7 +24,7 @@ module Rubocop
24
24
  trap_interrupt
25
25
 
26
26
  @options, remaining_args = Options.new.parse(args)
27
- act_on_options(remaining_args)
27
+ act_on_options
28
28
  target_files = target_finder.find(remaining_args)
29
29
 
30
30
  inspector = FileInspector.new(@options)
@@ -51,7 +51,7 @@ module Rubocop
51
51
 
52
52
  private
53
53
 
54
- def act_on_options(args)
54
+ def act_on_options
55
55
  handle_exiting_options
56
56
 
57
57
  ConfigLoader.debug = @options[:debug]
@@ -24,6 +24,40 @@ module Rubocop
24
24
  super(@hash)
25
25
  end
26
26
 
27
+ def make_excludes_absolute
28
+ if self['AllCops'] && self['AllCops']['Exclude']
29
+ self['AllCops']['Exclude'].map! do |exclude_elem|
30
+ if exclude_elem.is_a?(String) && !exclude_elem.start_with?('/')
31
+ File.join(base_dir_for_path_parameters, exclude_elem)
32
+ else
33
+ exclude_elem
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def add_excludes_from_higher_level(highest_config)
40
+ if highest_config['AllCops'] && highest_config['AllCops']['Exclude']
41
+ self['AllCops'] ||= {}
42
+ excludes = self['AllCops']['Exclude'] ||= []
43
+ highest_config['AllCops']['Exclude'].each do |path|
44
+ unless path.is_a?(Regexp) || path.start_with?('/')
45
+ path = File.join(File.dirname(highest_config.loaded_path), path)
46
+ end
47
+ excludes << path unless excludes.include?(path)
48
+ end
49
+ end
50
+ end
51
+
52
+ def deprecation_check
53
+ return unless self['AllCops']
54
+ if self['AllCops']['Excludes']
55
+ yield 'AllCops/Excludes was renamed to AllCops/Exclude'
56
+ elsif self['AllCops']['Includes']
57
+ yield 'AllCops/Includes was renamed to AllCops/Include'
58
+ end
59
+ end
60
+
27
61
  def for_cop(cop)
28
62
  cop = cop.cop_name if cop.respond_to?(:cop_name)
29
63
  self[cop]
@@ -70,13 +104,16 @@ module Rubocop
70
104
  def file_to_include?(file)
71
105
  relative_file_path = path_relative_to_config(file)
72
106
  patterns_to_include.any? do |pattern|
73
- match_path?(pattern, relative_file_path)
107
+ match_path?(pattern, relative_file_path, loaded_path)
74
108
  end
75
109
  end
76
110
 
77
111
  def file_to_exclude?(file)
78
112
  file = File.join(Dir.pwd, file) unless file.start_with?('/')
79
- patterns_to_exclude.any? { |pattern| match_path?(pattern, file) }
113
+ file = File.expand_path(file)
114
+ patterns_to_exclude.any? do |pattern|
115
+ match_path?(pattern, file, loaded_path)
116
+ end
80
117
  end
81
118
 
82
119
  def patterns_to_include
@@ -97,7 +134,7 @@ module Rubocop
97
134
  # not relative to RuboCop's config directory since that wouldn't work.
98
135
  def base_dir_for_path_parameters
99
136
  if File.basename(loaded_path) == ConfigLoader::DOTFILE
100
- File.dirname(loaded_path)
137
+ File.expand_path(File.dirname(loaded_path))
101
138
  else
102
139
  Dir.pwd
103
140
  end