rubocop 0.23.0 → 0.24.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +35 -1
- data/CONTRIBUTING.md +1 -1
- data/README.md +6 -6
- data/config/default.yml +25 -6
- data/config/enabled.yml +20 -0
- data/lib/rubocop.rb +10 -13
- data/lib/rubocop/cli.rb +23 -20
- data/lib/rubocop/cop/lint/def_end_alignment.rb +47 -0
- data/lib/rubocop/cop/lint/end_alignment.rb +18 -65
- data/lib/rubocop/cop/lint/shadowing_outer_local_variable.rb +1 -1
- data/lib/rubocop/cop/lint/syntax.rb +28 -4
- data/lib/rubocop/cop/lint/underscore_prefixed_variable_name.rb +1 -1
- data/lib/rubocop/cop/lint/unused_block_argument.rb +13 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +3 -2
- data/lib/rubocop/cop/lint/useless_assignment.rb +1 -9
- data/lib/rubocop/cop/lint/useless_setter_call.rb +28 -20
- data/lib/rubocop/cop/mixin/access_modifier_node.rb +18 -0
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +4 -2
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +42 -0
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +32 -0
- data/lib/rubocop/cop/mixin/surrounding_space.rb +7 -8
- data/lib/rubocop/cop/mixin/unused_argument.rb +1 -1
- data/lib/rubocop/cop/offense.rb +27 -14
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +2 -9
- data/lib/rubocop/cop/style/attr.rb +3 -1
- data/lib/rubocop/cop/style/class_check.rb +42 -0
- data/lib/rubocop/cop/style/each_with_object.rb +5 -1
- data/lib/rubocop/cop/style/empty_lines.rb +1 -4
- data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +2 -8
- data/lib/rubocop/cop/style/empty_lines_around_body.rb +1 -4
- data/lib/rubocop/cop/style/encoding.rb +3 -5
- data/lib/rubocop/cop/style/end_of_line.rb +2 -5
- data/lib/rubocop/cop/style/file_name.rb +2 -4
- data/lib/rubocop/cop/style/if_with_semicolon.rb +2 -1
- data/lib/rubocop/cop/style/indentation_consistency.rb +2 -1
- data/lib/rubocop/cop/style/indentation_width.rb +25 -5
- data/lib/rubocop/cop/style/line_length.rb +59 -5
- data/lib/rubocop/cop/style/next.rb +18 -18
- data/lib/rubocop/cop/style/numeric_literals.rb +22 -9
- data/lib/rubocop/cop/style/parentheses_around_condition.rb +1 -0
- data/lib/rubocop/cop/style/redundant_self.rb +1 -1
- data/lib/rubocop/cop/style/semicolon.rb +1 -3
- data/lib/rubocop/cop/style/space_after_colon.rb +7 -3
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +3 -1
- data/lib/rubocop/cop/style/space_before_comma.rb +16 -0
- data/lib/rubocop/cop/style/space_before_semicolon.rb +16 -0
- data/lib/rubocop/cop/style/tab.rb +6 -5
- data/lib/rubocop/cop/style/trailing_comma.rb +33 -6
- data/lib/rubocop/cop/style/trailing_whitespace.rb +4 -3
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +6 -0
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +45 -0
- data/lib/rubocop/cop/style/unneeded_percent_x.rb +2 -3
- data/lib/rubocop/cop/style/word_array.rb +1 -1
- data/lib/rubocop/cop/team.rb +6 -12
- data/lib/rubocop/cop/util.rb +26 -8
- data/lib/rubocop/cop/variable_force.rb +3 -6
- data/lib/rubocop/cop/variable_force/variable.rb +7 -3
- data/lib/rubocop/processed_source.rb +52 -12
- data/lib/rubocop/{file_inspector.rb → runner.rb} +50 -59
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.24.0.md +77 -0
- data/rubocop.gemspec +4 -4
- data/spec/rubocop/cli_spec.rb +38 -21
- data/spec/rubocop/config_loader_spec.rb +7 -6
- data/spec/rubocop/config_spec.rb +8 -8
- data/spec/rubocop/cop/cop_spec.rb +1 -1
- data/spec/rubocop/cop/lint/def_end_alignment_spec.rb +108 -0
- data/spec/rubocop/cop/lint/end_alignment_spec.rb +0 -47
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +6 -7
- data/spec/rubocop/cop/lint/unused_block_argument_spec.rb +19 -0
- data/spec/rubocop/cop/lint/useless_assignment_spec.rb +8 -18
- data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +99 -51
- data/spec/rubocop/cop/offense_spec.rb +3 -3
- data/spec/rubocop/cop/rails/delegate_spec.rb +1 -1
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +12 -0
- data/spec/rubocop/cop/style/align_hash_spec.rb +4 -4
- data/spec/rubocop/cop/style/align_parameters_spec.rb +1 -1
- data/spec/rubocop/cop/style/attr_spec.rb +12 -2
- data/spec/rubocop/cop/style/class_check_spec.rb +41 -0
- data/spec/rubocop/cop/style/each_with_object_spec.rb +5 -0
- data/spec/rubocop/cop/style/if_with_semicolon_spec.rb +5 -0
- data/spec/rubocop/cop/style/indentation_width_spec.rb +95 -0
- data/spec/rubocop/cop/style/line_length_spec.rb +75 -0
- data/spec/rubocop/cop/style/next_spec.rb +28 -0
- data/spec/rubocop/cop/style/numeric_literals_spec.rb +10 -0
- data/spec/rubocop/cop/style/parentheses_around_condition_spec.rb +5 -0
- data/spec/rubocop/cop/style/space_after_colon_spec.rb +17 -0
- data/spec/rubocop/cop/style/space_around_equals_in_parameter_default_spec.rb +11 -0
- data/spec/rubocop/cop/style/space_around_operators_spec.rb +1 -0
- data/spec/rubocop/cop/style/space_before_comma_spec.rb +42 -0
- data/spec/rubocop/cop/style/space_before_semicolon_spec.rb +28 -0
- data/spec/rubocop/cop/style/trailing_comma_spec.rb +37 -15
- data/spec/rubocop/cop/style/unneeded_capital_w_spec.rb +8 -10
- data/spec/rubocop/cop/style/unneeded_percent_q_spec.rb +72 -0
- data/spec/rubocop/cop/style/word_array_spec.rb +6 -0
- data/spec/rubocop/cop/team_spec.rb +8 -8
- data/spec/rubocop/cop/util_spec.rb +10 -0
- data/spec/rubocop/cop/variable_force/assignment_spec.rb +1 -1
- data/spec/rubocop/cop/variable_force/locatable_spec.rb +1 -1
- data/spec/rubocop/cop/variable_force/scope_spec.rb +1 -1
- data/spec/rubocop/cop/variable_force/variable_spec.rb +4 -4
- data/spec/rubocop/formatter/base_formatter_spec.rb +5 -5
- data/spec/rubocop/formatter/colorizable_spec.rb +2 -2
- data/spec/rubocop/formatter/json_formatter_spec.rb +1 -1
- data/spec/rubocop/path_util_spec.rb +15 -15
- data/spec/rubocop/processed_source_spec.rb +104 -50
- data/spec/rubocop/runner_spec.rb +64 -0
- data/spec/spec_helper.rb +8 -10
- data/spec/support/shared_examples.rb +22 -0
- metadata +39 -15
- data/lib/rubocop/source_parser.rb +0 -47
- data/spec/rubocop/file_inspector_spec.rb +0 -84
- data/spec/rubocop/source_parser_spec.rb +0 -85
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa14a751d9a506d14ddc238a96b32436f59694d7
|
4
|
+
data.tar.gz: f522a8666bb49b81317c707e8a279ea1e31d49b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3c12cd56fa480bf29ada0d78e2790016756a12d6c545238c14b621a95a5d74cab15f2628663f943042a3658021058e6d8337fd3181365fa6d57604552e65983
|
7
|
+
data.tar.gz: ac12f065a8921d0de5152716e5796cbe30621b6791103dfab15e97675ad7594ed3553579b12b34c29efd20d605d72e6b4a1d756631048021709216e10a614e5f
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,39 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.24.0 (25/06/2014)
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* [#639](https://github.com/bbatsov/rubocop/issues/639): Support square bracket setters in `UselessSetterCall`. ([@yujinakayama][])
|
10
|
+
* [#835](https://github.com/bbatsov/rubocop/issues/835): `UnneededCapitalW` cop does auto-correction. ([@sfeldon][])
|
11
|
+
* [#1092](https://github.com/bbatsov/rubocop/issues/1092): New cop `DefEndAlignment` takes over responsibility for checkng alignment of method definition `end`s from `EndAlignment`, and is configurable. ([@jonas054][])
|
12
|
+
* [#1145](https://github.com/bbatsov/rubocop/issues/1145): New cop `ClassCheck` enforces consistent use of `is_a?` or `kind_of?`. ([@bbatsov][])
|
13
|
+
* [#1161](https://github.com/bbatsov/rubocop/pull/1161): New cop `SpaceBeforeComma` detects spaces before a comma. ([@agrimm][])
|
14
|
+
* [#1161](https://github.com/bbatsov/rubocop/pull/1161): New cop `SpaceBeforeSemicolon` detects spaces before a semicolon. ([@agrimm][])
|
15
|
+
* [#835](https://github.com/bbatsov/rubocop/issues/835): New cop `UnneededPercentQ` checks for usage of the `%q`/`%Q` syntax when `''` or `""` would do. ([@jonas054][])
|
16
|
+
* [#977](https://github.com/bbatsov/rubocop/issues/977): Add `AllowURI` option (enabled by default) to `LineLength` cop. ([@yujinakayama][])
|
17
|
+
|
18
|
+
### Changes
|
19
|
+
|
20
|
+
* Unused block local variables (`obj.each { |arg; this| }`) are now handled by `UnusedBlockArgument` cop instead of `UselessAssignment` cop. ([@yujinakayama][])
|
21
|
+
* [#1141](https://github.com/bbatsov/rubocop/issues/1141): Clarify in the message from `TrailingComma` that a trailing comma is never allowed for lists where some items share a line. ([@jonas054][])
|
22
|
+
|
23
|
+
### Bugs fixed
|
24
|
+
|
25
|
+
* [#1133](https://github.com/bbatsov/rubocop/issues/1133): Handle `reduce/inject` with no arguments in `EachWithObject`. ([@bbatsov][])
|
26
|
+
* [#1152](https://github.com/bbatsov/rubocop/issues/1152): Handle `while/until` with no body in `Next`. ([@tamird][])
|
27
|
+
* Fix a false positive in `UselessSetterCall` for setter call on a local variable that contains a non-local object. ([@yujinakayama][])
|
28
|
+
* [#1158](https://github.com/bbatsov/rubocop/issues/1158): Fix auto-correction of floating-point numbers. ([@bbatsov][])
|
29
|
+
* [#1159](https://github.com/bbatsov/rubocop/issues/1159): Fix checking of `begin`..`end` structures, blocks, and parenthesized expressions in `IndentationWidth`. ([@jonas054][])
|
30
|
+
* [#1159](https://github.com/bbatsov/rubocop/issues/1159): More rigid conditions for when `attr` is considered an offense. ([@jonas054][])
|
31
|
+
* [#1167](https://github.com/bbatsov/rubocop/issues/1167): Fix handling of parameters spanning multiple lines in `TrailingComma`. ([@jonas054][])
|
32
|
+
* [#1169](https://github.com/bbatsov/rubocop/issues/1169): Fix handling of ternary op conditions in `ParenthesesAroundCondition`. ([@bbatsov][])
|
33
|
+
* [#1147](https://github.com/bbatsov/rubocop/issues/1147): WordArray checks arrays with special characters. ([@camilleldn][])
|
34
|
+
* Fix a false positive against `return` in a loop in `Next` cop. ([@yujinakayama][])
|
35
|
+
* [#1165](https://github.com/bbatsov/rubocop/issues/1165): Support `rescue`/`else`/`ensure` bodies in `IndentationWidth`. ([@jonas054][])
|
36
|
+
* Fix false positive for aligned list of values after `when` in `IndentationWidth`. ([@jonas054][])
|
37
|
+
|
5
38
|
## 0.23.0 (02/06/2014)
|
6
39
|
|
7
40
|
### New features
|
@@ -32,7 +65,7 @@
|
|
32
65
|
* [#1120](https://github.com/bbatsov/rubocop/issues/1120): Don't change indentation of heredoc strings in auto-correct. ([@jonas054][])
|
33
66
|
* [#1109](https://github.com/bbatsov/rubocop/issues/1109): Handle conditions with modifier ops in them in `ParenthesesAroundCondition`. ([@bbatsov][])
|
34
67
|
|
35
|
-
## 0.22.0 (20/
|
68
|
+
## 0.22.0 (20/05/2014)
|
36
69
|
|
37
70
|
### New features
|
38
71
|
|
@@ -969,3 +1002,4 @@
|
|
969
1002
|
[@wndhydrnt]: https://github.com/wndhydrnt
|
970
1003
|
[@ggilder]: https://github.com/ggilder
|
971
1004
|
[@salbertson]: https://github.com/salbertson
|
1005
|
+
[@camilleldn]: https://github.com/camilleldn
|
data/CONTRIBUTING.md
CHANGED
@@ -38,7 +38,7 @@ $ rubocop -V
|
|
38
38
|
is fine, but please isolate to its own commit so I can cherry-pick
|
39
39
|
around it.
|
40
40
|
* Make sure the test suite is passing ([including rbx and jruby][7]) and the code you wrote doesn't produce
|
41
|
-
RuboCop
|
41
|
+
RuboCop offenses.
|
42
42
|
* [Squash related commits together][5].
|
43
43
|
* Open a [pull request][4] that relates to *only* one subject with a clear title
|
44
44
|
and description in grammatically correct, complete sentences.
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/bbatsov/rubocop.svg?branch=master)](https://travis-ci.org/bbatsov/rubocop)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/bbatsov/rubocop/badge.png?branch=master)](https://coveralls.io/r/bbatsov/rubocop)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/bbatsov/rubocop.png)](https://codeclimate.com/github/bbatsov/rubocop)
|
6
|
-
[![Inline docs](http://inch-
|
6
|
+
[![Inline docs](http://inch-ci.org/github/bbatsov/rubocop.svg)](http://inch-ci.org/github/bbatsov/rubocop)
|
7
7
|
|
8
8
|
# RuboCop
|
9
9
|
|
@@ -257,12 +257,12 @@ Here is an example that might be used for a Rails project:
|
|
257
257
|
```yaml
|
258
258
|
AllCops:
|
259
259
|
Include:
|
260
|
-
- Rakefile
|
261
|
-
- config.ru
|
260
|
+
- '**/Rakefile'
|
261
|
+
- '**/config.ru'
|
262
262
|
Exclude:
|
263
|
-
- db/**/*
|
264
|
-
- config/**/*
|
265
|
-
- script/**/*
|
263
|
+
- 'db/**/*'
|
264
|
+
- 'config/**/*'
|
265
|
+
- 'script/**/*'
|
266
266
|
- !ruby/regexp /old_and_unused\.rb$/
|
267
267
|
|
268
268
|
# other configuration
|
data/config/default.yml
CHANGED
@@ -54,10 +54,10 @@ Style/AlignHash:
|
|
54
54
|
# inspected? Valid values are:
|
55
55
|
#
|
56
56
|
# always_inspect - Inspect both implicit and explicit hashes.
|
57
|
-
# Registers an
|
57
|
+
# Registers an offense for:
|
58
58
|
# function(a: 1,
|
59
59
|
# b: 2)
|
60
|
-
# Registers an
|
60
|
+
# Registers an offense for:
|
61
61
|
# function({a: 1,
|
62
62
|
# b: 2})
|
63
63
|
# always_ignore - Ignore both implicit and explicit hashes.
|
@@ -71,14 +71,14 @@ Style/AlignHash:
|
|
71
71
|
# Accepts:
|
72
72
|
# function(a: 1,
|
73
73
|
# b: 2)
|
74
|
-
# Registers an
|
74
|
+
# Registers an offense for:
|
75
75
|
# function({a: 1,
|
76
76
|
# b: 2})
|
77
77
|
# ignore_explicit - Ignore only explicit hashes.
|
78
78
|
# Accepts:
|
79
79
|
# function({a: 1,
|
80
80
|
# b: 2})
|
81
|
-
# Registers an
|
81
|
+
# Registers an offense for:
|
82
82
|
# function(a: 1,
|
83
83
|
# b: 2)
|
84
84
|
EnforcedLastArgumentHashStyle: always_inspect
|
@@ -145,6 +145,12 @@ Style/ClassAndModuleChildren:
|
|
145
145
|
- nested
|
146
146
|
- compact
|
147
147
|
|
148
|
+
Style/ClassCheck:
|
149
|
+
EnforcedStyle: is_a?
|
150
|
+
SupportedStyles:
|
151
|
+
- is_a?
|
152
|
+
- kind_of?
|
153
|
+
|
148
154
|
Style/ClassLength:
|
149
155
|
CountComments: false # count full line comments?
|
150
156
|
Max: 100
|
@@ -258,6 +264,7 @@ Style/LambdaCall:
|
|
258
264
|
|
259
265
|
Style/LineLength:
|
260
266
|
Max: 80
|
267
|
+
AllowURI: true
|
261
268
|
|
262
269
|
Style/Next:
|
263
270
|
# With `always` all conditions at the end of an iteration needs to be
|
@@ -269,12 +276,12 @@ Style/Next:
|
|
269
276
|
- always
|
270
277
|
|
271
278
|
Style/NonNilCheck:
|
272
|
-
# With `IncludeSemanticChanges` set to `true`, this cop reports
|
279
|
+
# With `IncludeSemanticChanges` set to `true`, this cop reports offenses for
|
273
280
|
# `!x.nil?` and autocorrects that and `x != nil` to solely `x`, which is
|
274
281
|
# **usually** OK, but might change behavior.
|
275
282
|
#
|
276
283
|
# With `IncludeSemanticChanges` set to `false`, this cop does not report
|
277
|
-
#
|
284
|
+
# offenses for `!x.nil?` and does no changes that might change behavior.
|
278
285
|
IncludeSemanticChanges: false
|
279
286
|
|
280
287
|
Style/MethodDefParentheses:
|
@@ -404,6 +411,8 @@ Style/TrailingBlankLines:
|
|
404
411
|
- final_blank_line
|
405
412
|
|
406
413
|
Style/TrailingComma:
|
414
|
+
# If EnforcedStyleForMultiline is comma, the cop allows a comma after the
|
415
|
+
# last item of a list, but only for lists where each item is on its own line.
|
407
416
|
EnforcedStyleForMultiline: no_comma
|
408
417
|
SupportedStyles:
|
409
418
|
- comma
|
@@ -472,6 +481,16 @@ Lint/EndAlignment:
|
|
472
481
|
- keyword
|
473
482
|
- variable
|
474
483
|
|
484
|
+
Lint/DefEndAlignment:
|
485
|
+
# The value `def` means that `end` should be aligned with the def keyword.
|
486
|
+
# The value `start_of_line` means that `end` should be aligned with method
|
487
|
+
# calls like `private`, `public`, etc, if present in front of the `def`
|
488
|
+
# keyword on the same line.
|
489
|
+
AlignWith: start_of_line
|
490
|
+
SupportedStyles:
|
491
|
+
- start_of_line
|
492
|
+
- def
|
493
|
+
|
475
494
|
##################### Rails ##################################
|
476
495
|
|
477
496
|
Rails/ActionFilter:
|
data/config/enabled.yml
CHANGED
@@ -93,6 +93,10 @@ Style/ClassAndModuleChildren:
|
|
93
93
|
Description: 'Checks style of children classes and modules.'
|
94
94
|
Enabled: true
|
95
95
|
|
96
|
+
Style/ClassCheck:
|
97
|
+
Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.'
|
98
|
+
Enabled: true
|
99
|
+
|
96
100
|
Style/ClassLength:
|
97
101
|
Description: 'Avoid classes longer than 100 lines of code.'
|
98
102
|
Enabled: true
|
@@ -469,12 +473,20 @@ Style/SpaceBeforeBlockBraces:
|
|
469
473
|
before it.
|
470
474
|
Enabled: true
|
471
475
|
|
476
|
+
Style/SpaceBeforeComma:
|
477
|
+
Description: 'No spaces before commas.'
|
478
|
+
Enabled: true
|
479
|
+
|
472
480
|
Style/SpaceBeforeComment:
|
473
481
|
Description: >-
|
474
482
|
Checks for missing space between code and a comment on the
|
475
483
|
same line.
|
476
484
|
Enabled: true
|
477
485
|
|
486
|
+
Style/SpaceBeforeSemicolon:
|
487
|
+
Description: 'No spaces before semicolons.'
|
488
|
+
Enabled: true
|
489
|
+
|
478
490
|
Style/SpaceInsideBlockBraces:
|
479
491
|
Description: >-
|
480
492
|
Checks that block braces have or don't have surrounding space.
|
@@ -547,6 +559,10 @@ Style/UnneededCapitalW:
|
|
547
559
|
Description: 'Checks for %W when interpolation is not needed.'
|
548
560
|
Enabled: true
|
549
561
|
|
562
|
+
Style/UnneededPercentQ:
|
563
|
+
Description: 'Checks for %q/%Q when single quotes or double quotes would do.'
|
564
|
+
Enabled: true
|
565
|
+
|
550
566
|
Style/UnneededPercentX:
|
551
567
|
Description: 'Checks for %x when `` would do.'
|
552
568
|
Enabled: true
|
@@ -610,6 +626,10 @@ Lint/Debugger:
|
|
610
626
|
Description: 'Check for debugger calls.'
|
611
627
|
Enabled: true
|
612
628
|
|
629
|
+
Lint/DefEndAlignment:
|
630
|
+
Description: 'Align ends corresponding to defs correctly.'
|
631
|
+
Enabled: true
|
632
|
+
|
613
633
|
Lint/DeprecatedClassMethods:
|
614
634
|
Description: 'Check for deprecated class method calls.'
|
615
635
|
Enabled: true
|
data/lib/rubocop.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
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)
|
@@ -45,6 +35,7 @@ require 'rubocop/cop/variable_force/reference'
|
|
45
35
|
require 'rubocop/cop/variable_force/scope'
|
46
36
|
require 'rubocop/cop/variable_force/variable_table'
|
47
37
|
|
38
|
+
require 'rubocop/cop/mixin/access_modifier_node'
|
48
39
|
require 'rubocop/cop/mixin/annotation_comment'
|
49
40
|
require 'rubocop/cop/mixin/array_syntax'
|
50
41
|
require 'rubocop/cop/mixin/autocorrect_alignment'
|
@@ -55,6 +46,7 @@ require 'rubocop/cop/mixin/configurable_max'
|
|
55
46
|
require 'rubocop/cop/mixin/code_length'
|
56
47
|
require 'rubocop/cop/mixin/configurable_enforced_style'
|
57
48
|
require 'rubocop/cop/mixin/configurable_naming'
|
49
|
+
require 'rubocop/cop/mixin/end_keyword_alignment'
|
58
50
|
require 'rubocop/cop/mixin/if_node'
|
59
51
|
require 'rubocop/cop/mixin/if_then_else'
|
60
52
|
require 'rubocop/cop/mixin/negative_conditional'
|
@@ -64,6 +56,7 @@ require 'rubocop/cop/mixin/safe_assignment'
|
|
64
56
|
require 'rubocop/cop/mixin/surrounding_space'
|
65
57
|
require 'rubocop/cop/mixin/space_inside'
|
66
58
|
require 'rubocop/cop/mixin/space_after_punctuation'
|
59
|
+
require 'rubocop/cop/mixin/space_before_punctuation'
|
67
60
|
require 'rubocop/cop/mixin/statement_modifier'
|
68
61
|
require 'rubocop/cop/mixin/string_help'
|
69
62
|
require 'rubocop/cop/mixin/unused_argument'
|
@@ -74,6 +67,7 @@ require 'rubocop/cop/lint/assignment_in_condition'
|
|
74
67
|
require 'rubocop/cop/lint/block_alignment'
|
75
68
|
require 'rubocop/cop/lint/condition_position'
|
76
69
|
require 'rubocop/cop/lint/debugger'
|
70
|
+
require 'rubocop/cop/lint/def_end_alignment'
|
77
71
|
require 'rubocop/cop/lint/deprecated_class_methods'
|
78
72
|
require 'rubocop/cop/lint/else_layout'
|
79
73
|
require 'rubocop/cop/lint/empty_ensure'
|
@@ -126,6 +120,7 @@ require 'rubocop/cop/style/case_indentation'
|
|
126
120
|
require 'rubocop/cop/style/character_literal'
|
127
121
|
require 'rubocop/cop/style/class_and_module_camel_case'
|
128
122
|
require 'rubocop/cop/style/class_and_module_children'
|
123
|
+
require 'rubocop/cop/style/class_check'
|
129
124
|
require 'rubocop/cop/style/class_length'
|
130
125
|
require 'rubocop/cop/style/class_methods'
|
131
126
|
require 'rubocop/cop/style/class_vars'
|
@@ -216,8 +211,10 @@ require 'rubocop/cop/style/space_after_semicolon'
|
|
216
211
|
require 'rubocop/cop/style/space_around_equals_in_parameter_default'
|
217
212
|
require 'rubocop/cop/style/space_around_operators'
|
218
213
|
require 'rubocop/cop/style/space_before_block_braces'
|
214
|
+
require 'rubocop/cop/style/space_before_comma'
|
219
215
|
require 'rubocop/cop/style/space_before_comment'
|
220
216
|
require 'rubocop/cop/style/space_before_modifier_keyword'
|
217
|
+
require 'rubocop/cop/style/space_before_semicolon'
|
221
218
|
require 'rubocop/cop/style/space_inside_block_braces'
|
222
219
|
require 'rubocop/cop/style/space_inside_brackets'
|
223
220
|
require 'rubocop/cop/style/space_inside_hash_literal_braces'
|
@@ -232,6 +229,7 @@ require 'rubocop/cop/style/trailing_whitespace'
|
|
232
229
|
require 'rubocop/cop/style/trivial_accessors'
|
233
230
|
require 'rubocop/cop/style/unless_else'
|
234
231
|
require 'rubocop/cop/style/unneeded_capital_w'
|
232
|
+
require 'rubocop/cop/style/unneeded_percent_q'
|
235
233
|
require 'rubocop/cop/style/unneeded_percent_x'
|
236
234
|
require 'rubocop/cop/style/variable_interpolation'
|
237
235
|
require 'rubocop/cop/style/variable_name'
|
@@ -269,7 +267,6 @@ require 'rubocop/target_finder'
|
|
269
267
|
require 'rubocop/token'
|
270
268
|
require 'rubocop/comment_config'
|
271
269
|
require 'rubocop/processed_source'
|
272
|
-
require 'rubocop/
|
273
|
-
require 'rubocop/file_inspector'
|
270
|
+
require 'rubocop/runner'
|
274
271
|
require 'rubocop/cli'
|
275
272
|
require 'rubocop/options'
|
data/lib/rubocop/cli.rb
CHANGED
@@ -4,13 +4,8 @@ module RuboCop
|
|
4
4
|
# The CLI is a class responsible of handling all the command line interface
|
5
5
|
# logic.
|
6
6
|
class CLI
|
7
|
-
# If set true while running,
|
8
|
-
# RuboCop will abort processing and exit gracefully.
|
9
|
-
attr_accessor :wants_to_quit
|
10
7
|
attr_reader :options, :config_store
|
11
8
|
|
12
|
-
alias_method :wants_to_quit?, :wants_to_quit
|
13
|
-
|
14
9
|
def initialize
|
15
10
|
@options = {}
|
16
11
|
@config_store = ConfigStore.new
|
@@ -21,19 +16,15 @@ module RuboCop
|
|
21
16
|
# the target files
|
22
17
|
# @return [Fixnum] UNIX exit code
|
23
18
|
def run(args = ARGV)
|
24
|
-
|
25
|
-
|
26
|
-
@options, remaining_args = Options.new.parse(args)
|
19
|
+
@options, paths = Options.new.parse(args)
|
27
20
|
act_on_options
|
28
|
-
target_files = target_finder.find(remaining_args)
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
inspector.display_error_summary
|
22
|
+
runner = Runner.new(@options, @config_store)
|
23
|
+
trap_interrupt(runner)
|
24
|
+
all_passed = runner.run(paths)
|
25
|
+
display_error_summary(runner.errors)
|
35
26
|
|
36
|
-
|
27
|
+
all_passed && !runner.aborting? ? 0 : 1
|
37
28
|
rescue Cop::AmbiguousCopName => e
|
38
29
|
$stderr.puts "Ambiguous cop name #{e.message} needs namespace " \
|
39
30
|
'qualifier.'
|
@@ -44,10 +35,10 @@ module RuboCop
|
|
44
35
|
return 1
|
45
36
|
end
|
46
37
|
|
47
|
-
def trap_interrupt
|
38
|
+
def trap_interrupt(runner)
|
48
39
|
Signal.trap('INT') do
|
49
|
-
exit!(1) if
|
50
|
-
|
40
|
+
exit!(1) if runner.aborting?
|
41
|
+
runner.abort
|
51
42
|
$stderr.puts
|
52
43
|
$stderr.puts 'Exiting... Interrupt again to exit immediately.'
|
53
44
|
end
|
@@ -106,8 +97,20 @@ module RuboCop
|
|
106
97
|
end
|
107
98
|
end
|
108
99
|
|
109
|
-
def
|
110
|
-
|
100
|
+
def display_error_summary(errors)
|
101
|
+
return if errors.empty?
|
102
|
+
|
103
|
+
plural = errors.count > 1 ? 's' : ''
|
104
|
+
warn "\n#{errors.count} error#{plural} occurred:".color(:red)
|
105
|
+
|
106
|
+
errors.each { |error| warn error }
|
107
|
+
|
108
|
+
warn <<-END.strip_indent
|
109
|
+
Errors are usually caused by RuboCop bugs.
|
110
|
+
Please, report your problems to RuboCop's issue tracker.
|
111
|
+
Mention the following information in the issue report:
|
112
|
+
#{RuboCop::Version.version(true)}
|
113
|
+
END
|
111
114
|
end
|
112
115
|
end
|
113
116
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Lint
|
6
|
+
# This cop checks whether the end keywords of method definitions are
|
7
|
+
# aligned properly.
|
8
|
+
#
|
9
|
+
# Two modes are supported through the AlignWith configuration
|
10
|
+
# parameter. If it's set to `start_of_line` (which is the default), the
|
11
|
+
# `end` shall be aligned with the start of the line where the `def`
|
12
|
+
# keyword is. If it's set to `def`, the `end` shall be aligned with the
|
13
|
+
# `def` keyword.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# private def foo
|
18
|
+
# end
|
19
|
+
class DefEndAlignment < Cop
|
20
|
+
include CheckMethods
|
21
|
+
include EndKeywordAlignment
|
22
|
+
|
23
|
+
MSG = '`end` at %d, %d is not aligned with `%s` at %d, %d'
|
24
|
+
|
25
|
+
def on_send(node)
|
26
|
+
receiver, method_name, *args = *node
|
27
|
+
return unless visibility_and_def_on_same_line?(receiver, method_name,
|
28
|
+
args)
|
29
|
+
|
30
|
+
method_def = args.first
|
31
|
+
if style == :start_of_line
|
32
|
+
expr = node.loc.expression
|
33
|
+
range = Parser::Source::Range.new(expr.source_buffer,
|
34
|
+
expr.begin_pos,
|
35
|
+
method_def.loc.keyword.end_pos)
|
36
|
+
check_offset(method_def, range.source,
|
37
|
+
method_def.loc.keyword.begin_pos - expr.begin_pos)
|
38
|
+
else
|
39
|
+
check_offset(method_def, 'def', 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
ignore_node(method_def) # Don't check the same `end` again.
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|