rubocop 0.6.1 → 0.7.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/.rubocop.yml +4 -266
- data/CHANGELOG.md +49 -7
- data/README.md +75 -2
- data/Rakefile +2 -2
- data/bin/rubocop +15 -10
- data/lib/rubocop.rb +19 -1
- data/lib/rubocop/cli.rb +113 -116
- data/lib/rubocop/config.rb +202 -0
- data/lib/rubocop/config_store.rb +37 -0
- data/lib/rubocop/cop/alias.rb +2 -5
- data/lib/rubocop/cop/align_parameters.rb +1 -1
- data/lib/rubocop/cop/array_literal.rb +43 -4
- data/lib/rubocop/cop/avoid_for.rb +2 -4
- data/lib/rubocop/cop/avoid_global_vars.rb +49 -0
- data/lib/rubocop/cop/block_comments.rb +17 -0
- data/lib/rubocop/cop/brace_after_percent.rb +9 -5
- data/lib/rubocop/cop/{indentation.rb → case_indentation.rb} +1 -1
- data/lib/rubocop/cop/class_methods.rb +20 -0
- data/lib/rubocop/cop/colon_method_call.rb +44 -0
- data/lib/rubocop/cop/cop.rb +30 -2
- data/lib/rubocop/cop/def_parentheses.rb +1 -1
- data/lib/rubocop/cop/empty_line_between_defs.rb +26 -0
- data/lib/rubocop/cop/empty_lines.rb +10 -13
- data/lib/rubocop/cop/eval.rb +22 -0
- data/lib/rubocop/cop/favor_join.rb +37 -0
- data/lib/rubocop/cop/grammar.rb +2 -2
- data/lib/rubocop/cop/hash_literal.rb +43 -4
- data/lib/rubocop/cop/hash_syntax.rb +2 -2
- data/lib/rubocop/cop/if_then_else.rb +1 -1
- data/lib/rubocop/cop/leading_comment_space.rb +20 -0
- data/lib/rubocop/cop/line_continuation.rb +18 -0
- data/lib/rubocop/cop/line_length.rb +1 -1
- data/lib/rubocop/cop/method_and_variable_snake_case.rb +7 -6
- data/lib/rubocop/cop/method_length.rb +4 -15
- data/lib/rubocop/cop/not.rb +15 -0
- data/lib/rubocop/cop/offence.rb +9 -0
- data/lib/rubocop/cop/semicolon.rb +74 -3
- data/lib/rubocop/cop/single_line_methods.rb +60 -0
- data/lib/rubocop/cop/space_after_control_keyword.rb +28 -0
- data/lib/rubocop/cop/surrounding_space.rb +48 -9
- data/lib/rubocop/cop/symbol_array.rb +29 -0
- data/lib/rubocop/cop/trivial_accessors.rb +103 -0
- data/lib/rubocop/cop/unless_else.rb +1 -1
- data/lib/rubocop/cop/variable_interpolation.rb +3 -2
- data/lib/rubocop/cop/word_array.rb +38 -0
- data/lib/rubocop/version.rb +1 -1
- data/rubocop.gemspec +11 -7
- data/spec/project_spec.rb +27 -0
- data/spec/rubocop/cli_spec.rb +549 -487
- data/spec/rubocop/config_spec.rb +399 -0
- data/spec/rubocop/config_store_spec.rb +66 -0
- data/spec/rubocop/cops/alias_spec.rb +7 -0
- data/spec/rubocop/cops/array_literal_spec.rb +8 -1
- data/spec/rubocop/cops/avoid_for_spec.rb +15 -1
- data/spec/rubocop/cops/avoid_global_vars.rb +32 -0
- data/spec/rubocop/cops/block_comments_spec.rb +29 -0
- data/spec/rubocop/cops/brace_after_percent_spec.rb +19 -13
- data/spec/rubocop/cops/{indentation_spec.rb → case_indentation_spec.rb} +2 -2
- data/spec/rubocop/cops/class_methods_spec.rb +49 -0
- data/spec/rubocop/cops/colon_method_call_spec.rb +47 -0
- data/spec/rubocop/cops/empty_line_between_defs_spec.rb +83 -0
- data/spec/rubocop/cops/empty_lines_spec.rb +6 -63
- data/spec/rubocop/cops/eval_spec.rb +36 -0
- data/spec/rubocop/cops/favor_join_spec.rb +39 -0
- data/spec/rubocop/cops/hash_literal_spec.rb +8 -1
- data/spec/rubocop/cops/leading_comment_space_spec.rb +60 -0
- data/spec/rubocop/cops/line_continuation_spec.rb +24 -0
- data/spec/rubocop/cops/line_length_spec.rb +1 -0
- data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +20 -0
- data/spec/rubocop/cops/method_length_spec.rb +2 -5
- data/spec/rubocop/cops/new_lambda_literal_spec.rb +2 -3
- data/spec/rubocop/cops/not_spec.rb +34 -0
- data/spec/rubocop/cops/offence_spec.rb +7 -0
- data/spec/rubocop/cops/semicolon_spec.rb +79 -4
- data/spec/rubocop/cops/single_line_methods_spec.rb +50 -0
- data/spec/rubocop/cops/space_after_control_keyword_spec.rb +28 -0
- data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +11 -1
- data/spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb +74 -0
- data/spec/rubocop/cops/symbol_array_spec.rb +25 -0
- data/spec/rubocop/cops/trivial_accessors_spec.rb +332 -0
- data/spec/rubocop/cops/variable_interpolation_spec.rb +10 -1
- data/spec/rubocop/cops/word_array_spec.rb +39 -0
- data/spec/spec_helper.rb +16 -9
- data/spec/support/file_helper.rb +21 -0
- data/spec/support/isolated_environment.rb +27 -0
- metadata +66 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 821a707cffadfcc5e7996087447ced23fb3d3767
|
4
|
+
data.tar.gz: 0c2efc8203808c7b7b04fdf94c6c5d587b2fdcaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19fab984add9357970945fd82006ac71069958b117979b0fef6d3aade60111eec6c10d213e73a82a180a3cf87225d2a4db6341827f36d556b57570a4147c6613
|
7
|
+
data.tar.gz: 6c222ea27957f3cb861fd3ccf31a0795a8a8cd46b0e2d5712aa0d5bebe92a5cfa442f275599ab7810d739019941a4f2cc961c2269548dfa13fd0d7e1744ee391
|
data/.rubocop.yml
CHANGED
@@ -1,269 +1,7 @@
|
|
1
|
-
# This is the
|
2
|
-
# the configuration used to check the rubocop source code.
|
1
|
+
# This is the configuration used to check the rubocop source code.
|
3
2
|
|
4
|
-
|
5
|
-
Encoding:
|
6
|
-
Enabled: true
|
3
|
+
inherit_from: config/default.yml
|
7
4
|
|
8
|
-
#
|
9
|
-
LineLength:
|
10
|
-
Enabled: true
|
11
|
-
Max: 79
|
12
|
-
|
13
|
-
# Avoid methods longer than 10 lines of code
|
5
|
+
# Avoid methods longer than 30 lines of code
|
14
6
|
MethodLength:
|
15
|
-
|
16
|
-
CountComments: false # count full line comments?
|
17
|
-
Max: 65
|
18
|
-
|
19
|
-
# No hard tabs.
|
20
|
-
Tab:
|
21
|
-
Enabled: true
|
22
|
-
|
23
|
-
# Avoid trailing whitespace.
|
24
|
-
TrailingWhitespace:
|
25
|
-
Enabled: true
|
26
|
-
|
27
|
-
# Indent when as deep as case.
|
28
|
-
Indentation:
|
29
|
-
Enabled: true
|
30
|
-
|
31
|
-
# Use empty lines between defs.
|
32
|
-
EmptyLines:
|
33
|
-
Enabled: true
|
34
|
-
|
35
|
-
# Use spaces around operators.
|
36
|
-
SpaceAroundOperators:
|
37
|
-
Enabled: true
|
38
|
-
|
39
|
-
# Use spaces around { and before }.
|
40
|
-
SpaceAroundBraces:
|
41
|
-
Enabled: true
|
42
|
-
|
43
|
-
# No spaces after ( or before ).
|
44
|
-
SpaceInsideParens:
|
45
|
-
Enabled: true
|
46
|
-
|
47
|
-
# No spaces after [ or before ].
|
48
|
-
SpaceInsideBrackets:
|
49
|
-
Enabled: true
|
50
|
-
|
51
|
-
# Use spaces after commas.
|
52
|
-
SpaceAfterComma:
|
53
|
-
Enabled: true
|
54
|
-
|
55
|
-
# Use spaces after semicolons.
|
56
|
-
SpaceAfterSemicolon:
|
57
|
-
Enabled: true
|
58
|
-
|
59
|
-
# Use spaces after colons.
|
60
|
-
SpaceAfterColon:
|
61
|
-
Enabled: true
|
62
|
-
|
63
|
-
# Prefer symbols instead of strings as hash keys.
|
64
|
-
HashSyntax:
|
65
|
-
Enabled: true
|
66
|
-
|
67
|
-
# Use Unix-style line endings.
|
68
|
-
EndOfLine:
|
69
|
-
Enabled: true
|
70
|
-
|
71
|
-
# Add underscores to large numeric literals to improve their readability.
|
72
|
-
NumericLiterals:
|
73
|
-
Enabled: true
|
74
|
-
|
75
|
-
# Align the parameters of a method call if they span more than one line.
|
76
|
-
AlignParameters:
|
77
|
-
Enabled: true
|
78
|
-
|
79
|
-
# Use def with parentheses when there are arguments.
|
80
|
-
DefWithParentheses:
|
81
|
-
Enabled: true
|
82
|
-
|
83
|
-
# Omit the parentheses when the method doesn't accept any arguments.
|
84
|
-
DefWithoutParentheses:
|
85
|
-
Enabled: true
|
86
|
-
|
87
|
-
# Never use if x; .... Use the ternary operator instead.
|
88
|
-
IfWithSemicolon:
|
89
|
-
Enabled: true
|
90
|
-
|
91
|
-
# Never use then for multi-line if/unless.
|
92
|
-
MultilineIfThen:
|
93
|
-
Enabled: true
|
94
|
-
|
95
|
-
# Favor the ternary operator(?:) over if/then/else/end constructs.
|
96
|
-
OneLineConditional:
|
97
|
-
Enabled: true
|
98
|
-
|
99
|
-
# Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
|
100
|
-
MultilineBlocks:
|
101
|
-
Enabled: true
|
102
|
-
|
103
|
-
# Prefer {...} over do...end for single-line blocks.
|
104
|
-
SingleLineBlocks:
|
105
|
-
Enabled: true
|
106
|
-
|
107
|
-
# Avoid parameter lists longer than three or four parameters.
|
108
|
-
ParameterLists:
|
109
|
-
Enabled: true
|
110
|
-
|
111
|
-
# Prefer ' strings when you don't need string interpolation or special symbols.
|
112
|
-
StringLiterals:
|
113
|
-
Enabled: true
|
114
|
-
|
115
|
-
# Avoid multi-line ?: (the ternary operator); use if/unless instead.
|
116
|
-
MultilineTernaryOperator:
|
117
|
-
Enabled: true
|
118
|
-
|
119
|
-
# Use one expression per branch in a ternary operator.
|
120
|
-
NestedTernaryOperator:
|
121
|
-
Enabled: true
|
122
|
-
|
123
|
-
# Never use unless with else. Rewrite these with the positive case first.
|
124
|
-
UnlessElse:
|
125
|
-
Enabled: true
|
126
|
-
|
127
|
-
# Use &&/|| for boolean expressions, and/or for control flow.
|
128
|
-
AmpersandsPipesVsAndOr:
|
129
|
-
Enabled: true
|
130
|
-
|
131
|
-
# Use when x then ... for one-line cases.
|
132
|
-
WhenThen:
|
133
|
-
Enabled: true
|
134
|
-
|
135
|
-
# Favor modifier if/unless usage when you have a single-line body.
|
136
|
-
IfUnlessModifier:
|
137
|
-
Enabled: true
|
138
|
-
|
139
|
-
# Favor modifier while/until usage when you have a single-line body.
|
140
|
-
WhileUntilModifier:
|
141
|
-
Enabled: true
|
142
|
-
|
143
|
-
# Favor unless over if for negative conditions (or control flow or).
|
144
|
-
FavorUnlessOverNegatedIf:
|
145
|
-
Enabled: true
|
146
|
-
|
147
|
-
# Favor until over while for negative conditions.
|
148
|
-
FavorUntilOverNegatedWhile:
|
149
|
-
Enabled: true
|
150
|
-
|
151
|
-
# Use spaces around the = operator when assigning default values in def params.
|
152
|
-
SpaceAroundEqualsInParameterDefault:
|
153
|
-
Enabled: true
|
154
|
-
|
155
|
-
# Use the new lambda literal syntax.
|
156
|
-
NewLambdaLiteral:
|
157
|
-
Enabled: true
|
158
|
-
|
159
|
-
# Don't use parentheses around the condition of an if/unless/while.
|
160
|
-
ParenthesesAroundCondition:
|
161
|
-
Enabled: true
|
162
|
-
|
163
|
-
# Use snake_case for symbols, methods and variables.
|
164
|
-
MethodAndVariableSnakeCase:
|
165
|
-
Enabled: true
|
166
|
-
|
167
|
-
# Use CamelCase for classes and modules.
|
168
|
-
ClassAndModuleCamelCase:
|
169
|
-
Enabled: true
|
170
|
-
|
171
|
-
# Causes Ruby to check the syntax of the script and exit without executing.
|
172
|
-
Syntax:
|
173
|
-
Enabled: true
|
174
|
-
|
175
|
-
# Preferred collection methods.
|
176
|
-
CollectionMethods:
|
177
|
-
Enabled: true
|
178
|
-
|
179
|
-
# Prefer each over for.
|
180
|
-
AvoidFor:
|
181
|
-
Enabled: true
|
182
|
-
|
183
|
-
# Avoid Perl-style global variables.
|
184
|
-
AvoidPerlisms:
|
185
|
-
Enabled: true
|
186
|
-
|
187
|
-
# Avoid Perl-style regex back references.
|
188
|
-
AvoidPerlBackrefs:
|
189
|
-
Enabled: true
|
190
|
-
|
191
|
-
# Avoid the use of class variables.
|
192
|
-
AvoidClassVars:
|
193
|
-
Enabled: true
|
194
|
-
|
195
|
-
# Symbol literals should use snake_case.
|
196
|
-
SymbolSnakeCase:
|
197
|
-
Enabled: true
|
198
|
-
|
199
|
-
# Don't interpolate global, instance and class variables directly in strings.
|
200
|
-
VariableInterpolation:
|
201
|
-
Enabled: true
|
202
|
-
|
203
|
-
# Don't use semicolons to terminate expressions.
|
204
|
-
Semicolon:
|
205
|
-
Enabled: true
|
206
|
-
|
207
|
-
# Use sprintf instead of %
|
208
|
-
FavorSprintf:
|
209
|
-
Enabled: true
|
210
|
-
|
211
|
-
# Use alias_method instead of alias.
|
212
|
-
Alias:
|
213
|
-
Enabled: true
|
214
|
-
|
215
|
-
# Avoid using rescue in its modifier form.
|
216
|
-
RescueModifier:
|
217
|
-
Enabled: true
|
218
|
-
|
219
|
-
# Avoid the use of %q, %Q, %s and %x.
|
220
|
-
PercentLiterals:
|
221
|
-
Enabled: true
|
222
|
-
|
223
|
-
# Prefer () as delimiters for all % literals.
|
224
|
-
BraceAfterPercent:
|
225
|
-
Enabled: true
|
226
|
-
|
227
|
-
# Never use return in an ensure block.
|
228
|
-
EnsureReturn:
|
229
|
-
Enabled: true
|
230
|
-
|
231
|
-
# Don't suppress exception.
|
232
|
-
HandleExceptions:
|
233
|
-
Enabled: true
|
234
|
-
|
235
|
-
# Use only ascii symbols in identifiers.
|
236
|
-
AsciiIdentifiers:
|
237
|
-
Enabled: true
|
238
|
-
|
239
|
-
# Use only ascii symbols in comments.
|
240
|
-
AsciiComments:
|
241
|
-
Enabled: true
|
242
|
-
|
243
|
-
# Avoid rescuing the Exception class.
|
244
|
-
RescueException:
|
245
|
-
Enabled: true
|
246
|
-
|
247
|
-
# Prefer array literal to Array.new.
|
248
|
-
ArrayLiteral:
|
249
|
-
Enabled: true
|
250
|
-
|
251
|
-
# Prefer hash {} literail to Hash.new.
|
252
|
-
HashLiteral:
|
253
|
-
Enabled: true
|
254
|
-
|
255
|
-
# When defining binary operators, name the argument other.
|
256
|
-
OpMethod:
|
257
|
-
Enabled: true
|
258
|
-
|
259
|
-
# Name reduce arguments |a, e| (accumulator, element)
|
260
|
-
ReduceArguments:
|
261
|
-
Enabled: true
|
262
|
-
|
263
|
-
# Use %r only for regular expressions matching more than one '/' character.
|
264
|
-
PercentR:
|
265
|
-
Enabled: true
|
266
|
-
|
267
|
-
# Use %r for regular expressions matching more than one '/' character.
|
268
|
-
FavorPercentR:
|
269
|
-
Enabled: true
|
7
|
+
Max: 30
|
data/CHANGELOG.md
CHANGED
@@ -6,25 +6,67 @@
|
|
6
6
|
|
7
7
|
### Bugs fixed
|
8
8
|
|
9
|
+
## 0.7.0 (05/11/2013)
|
10
|
+
|
11
|
+
### New features
|
12
|
+
|
13
|
+
* Added ability to include or exclude files/directories through `.rubocop.yml`
|
14
|
+
* Added option --only for running a single cop.
|
15
|
+
* Relax semicolon rule for one line methods, classes and modules
|
16
|
+
* Configuration files, such as `.rubocop.yml`, can now include configuration from other files through the `inherit_from` directive. All configuration files implicitly inherit from `config/default.yml`.
|
17
|
+
* New cop `ClassMethods` checks for uses for class/module names in definitions of class/module methods
|
18
|
+
* New cop `SingleLineMethods` checks for methods implemented on a single line
|
19
|
+
* New cop `FavorJoin` checks for usages of `Array#*` with a string argument
|
20
|
+
* New cop `BlockComments` tracks uses of block comments(`=begin/=end` comments)
|
21
|
+
* New cop `EmptyLines` tracks consecutive blank lines
|
22
|
+
* New cop `WordArray` tracks arrays of words.
|
23
|
+
* [#108](https://github.com/bbatsov/rubocop/issues/108) New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable
|
24
|
+
* New cop `LineContinuation` tracks uses of the line continuation character (`\`)
|
25
|
+
* New cop `SymbolArray` tracks arrays of symbols.
|
26
|
+
* Print warnings for unrecognized names in configuration files.
|
27
|
+
* New cop `TrivialAccessors` tracks method definitions that could be automatically generated with `attr_*` methods.
|
28
|
+
* New cop `LeadingCommentSpace` checks for missing space after `#` in comments.
|
29
|
+
* New cop `ColonMethodCall` tracks uses of `::` for method calls.
|
30
|
+
* New cop `AvoidGlobalVars` tracks uses of non built-in global variables.
|
31
|
+
* New cop `SpaceAfterControlKeyword` tracks missing spaces after `if/elsif/case/when/until/unless/while`.
|
32
|
+
* New cop `Not` tracks uses of the `not` keyword.
|
33
|
+
* New cop `Eval` tracks uses of the `eval` function.
|
34
|
+
|
35
|
+
### Bugs fixed
|
36
|
+
|
37
|
+
* [#101](https://github.com/bbatsov/rubocop/issues/101) `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string
|
38
|
+
* Fix `BraceAfterPercent` for `%W`, `%i` and `%I` and added more tests
|
39
|
+
* Fix a false positive in the `Alias` cop. `:alias` is no longer treated as keyword
|
40
|
+
* `ArrayLiteral` now properly detects `Array.new`
|
41
|
+
* `HashLiteral` now properly detects `Hash.new`
|
42
|
+
* `VariableInterpolation` now detects regexp back references and doesn't crash.
|
43
|
+
* Don't generate pathnames like some/project//some.rb
|
44
|
+
* [#151](https://github.com/bbatsov/rubocop/issues/151) Don't print the unrecognized cop warning several times for the same `.rubocop.yml`
|
45
|
+
|
46
|
+
### Misc
|
47
|
+
|
48
|
+
* Renamed `Indentation` cop to `CaseIndentation` to avoid confusion
|
49
|
+
* Renamed `EmptyLines` cop to `EmptyLineBetweenDefs` to avoid confusion
|
50
|
+
|
9
51
|
## 0.6.1 (04/28/2013)
|
10
52
|
|
11
53
|
### New features
|
12
54
|
|
13
|
-
* Split AsciiIdentifiersAndComments cop in two separate cops
|
55
|
+
* Split `AsciiIdentifiersAndComments` cop in two separate cops
|
14
56
|
|
15
57
|
### Bugs fixed
|
16
58
|
|
17
|
-
* [#90](https://github.com/bbatsov/rubocop/issues/90) Two cops crash when scanning code using super
|
18
|
-
* [#93](https://github.com/bbatsov/rubocop/issues/93) Issue with whitespace?': undefined method
|
59
|
+
* [#90](https://github.com/bbatsov/rubocop/issues/90) Two cops crash when scanning code using `super`
|
60
|
+
* [#93](https://github.com/bbatsov/rubocop/issues/93) Issue with `whitespace?': undefined method`
|
19
61
|
* [#97](https://github.com/bbatsov/rubocop/issues/97) Build fails
|
20
|
-
* [#100](https://github.com/bbatsov/rubocop/issues/100) OpMethod cop doesn't work if method arg is not in braces
|
21
|
-
* SymbolSnakeCase now tracks Ruby 1.9 hash labels as well as regular symbols
|
62
|
+
* [#100](https://github.com/bbatsov/rubocop/issues/100) `OpMethod` cop doesn't work if method arg is not in braces
|
63
|
+
* `SymbolSnakeCase` now tracks Ruby 1.9 hash labels as well as regular symbols
|
22
64
|
|
23
65
|
### Misc
|
24
66
|
|
25
67
|
* [#88](https://github.com/bbatsov/rubocop/issues/88) Abort gracefully when interrupted with Ctrl-C
|
26
68
|
* No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed.
|
27
|
-
* Replaced Term::ANSIColor with Rainbow
|
69
|
+
* Replaced `Term::ANSIColor` with `Rainbow`.
|
28
70
|
* Add an option to disable colors in the output.
|
29
71
|
* Cop names are now displayed alongside messages when `-d/--debug` is passed.
|
30
72
|
|
@@ -53,7 +95,7 @@
|
|
53
95
|
### Bugs fixed
|
54
96
|
|
55
97
|
* [#62](https://github.com/bbatsov/rubocop/issues/62) - Config files in ancestor directories are ignored if another exists in home directory
|
56
|
-
* [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols
|
98
|
+
* [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols `:==`, `:<=>` and the like to snake_case
|
57
99
|
* [#66](https://github.com/bbatsov/rubocop/issues/66) - Does not crash on unreadable or unparseable files
|
58
100
|
* [#70](https://github.com/bbatsov/rubocop/issues/70) - Support `alias` with bareword arguments
|
59
101
|
* [#64](https://github.com/bbatsov/rubocop/issues/64) - Performance issue with Bundler
|
data/README.md
CHANGED
@@ -46,6 +46,7 @@ Command flag | Description
|
|
46
46
|
`-e/--emacs` | Output the results in Emacs format
|
47
47
|
`-c/--config` | Run with specified config file
|
48
48
|
`-s/--silent` | Suppress the final summary
|
49
|
+
`--only` | Run only the specified cop
|
49
50
|
|
50
51
|
## Configuration
|
51
52
|
|
@@ -55,11 +56,13 @@ configuration file. The file can be placed either in your home folder
|
|
55
56
|
or in some project folder.
|
56
57
|
|
57
58
|
RuboCop will start looking for the configuration file in the directory
|
58
|
-
|
59
|
+
where the inspected file is and continue its way up to the root folder.
|
59
60
|
|
60
61
|
The file has the following format:
|
61
62
|
|
62
|
-
```
|
63
|
+
```yaml
|
64
|
+
inherit_from: ../.rubocop.yml
|
65
|
+
|
63
66
|
Encoding:
|
64
67
|
Enabled: true
|
65
68
|
|
@@ -71,6 +74,34 @@ LineLength:
|
|
71
74
|
It allows to enable/disable certain cops (checks) and to alter their
|
72
75
|
behavior if they accept any parameters.
|
73
76
|
|
77
|
+
The optional `inherit_from` directive is used to include configuration
|
78
|
+
from one or more files. This makes it possible to have the common
|
79
|
+
project settings in the `.rubocop.yml` file at the project root, and
|
80
|
+
then only the deviations from those rules in the subdirectories. The
|
81
|
+
included files can be given with absolute paths or paths relative to
|
82
|
+
the file where they are referenced. The settings after an
|
83
|
+
`inherit_from` directive override any settings in the included
|
84
|
+
file(s). When multiple files are included, the first file in the list
|
85
|
+
has the lowest precedence and the last one has the highest. The format
|
86
|
+
for multiple inclusion is:
|
87
|
+
|
88
|
+
```yaml
|
89
|
+
inherit_from:
|
90
|
+
- ../.rubocop.yml
|
91
|
+
- ../conf/.rubocop.yml
|
92
|
+
```
|
93
|
+
|
94
|
+
### Defaults
|
95
|
+
|
96
|
+
The file `config/default.yml` under the RuboCop home directory
|
97
|
+
contains the default settings that all configurations inherit
|
98
|
+
from. Project and personal `.rubocop.yml` files need only make
|
99
|
+
settings that are different from the default ones. If there is no
|
100
|
+
`.rubocop.yml` file in the project or home direcotry,
|
101
|
+
`config/default.yml` will be used.
|
102
|
+
|
103
|
+
### Disabling Cops within Source Code
|
104
|
+
|
74
105
|
One or more individual cops can be disabled locally in a section of a
|
75
106
|
file by adding a comment such as
|
76
107
|
|
@@ -95,6 +126,33 @@ comment.
|
|
95
126
|
for x in (0..19) # rubocop:disable AvoidFor
|
96
127
|
```
|
97
128
|
|
129
|
+
### Including/Excluding files
|
130
|
+
|
131
|
+
RuboCop checks all files recursively within the directory it is run
|
132
|
+
on. However, it does not recognize some files as Ruby(only files
|
133
|
+
ending with `.rb` or extensionless files with a `#!.*ruby` declaration
|
134
|
+
are automatically detected) files, and if you'd like it to check these
|
135
|
+
you'll need to manually pass them in. Files and directories can be
|
136
|
+
also be ignored through `.rubocop.yml`.
|
137
|
+
|
138
|
+
Here is an example that might be used for a Rails project:
|
139
|
+
|
140
|
+
```yaml
|
141
|
+
AllCops:
|
142
|
+
Includes:
|
143
|
+
- Rakefile
|
144
|
+
- config.ru
|
145
|
+
Excludes:
|
146
|
+
- db/**
|
147
|
+
- config/**
|
148
|
+
- script/**
|
149
|
+
|
150
|
+
# other configuration
|
151
|
+
# ...
|
152
|
+
```
|
153
|
+
|
154
|
+
Note: Files and directories are specified relative to the `.rubocop.yml` file.
|
155
|
+
|
98
156
|
## Compatibility
|
99
157
|
|
100
158
|
Unfortunately every major Ruby implementation has its own code
|
@@ -120,6 +178,15 @@ RuboCop and uses it by default when available.
|
|
120
178
|
The [vim-rubocop](https://github.com/ngmy/vim-rubocop) plugin runs
|
121
179
|
RuboCop and displays the results in Vim.
|
122
180
|
|
181
|
+
There's also a RuboCop checker in
|
182
|
+
[syntastic](https://github.com/scrooloose/syntastic).
|
183
|
+
|
184
|
+
### Sublime Text 2
|
185
|
+
|
186
|
+
If you're a ST2 user you might find the
|
187
|
+
[Sublime RuboCop plugin](https://github.com/pderichs/sublime_rubocop)
|
188
|
+
useful.
|
189
|
+
|
123
190
|
### Other Editors
|
124
191
|
|
125
192
|
Here's one great opportunity to contribute to RuboCop - implement
|
@@ -154,6 +221,12 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
|
|
154
221
|
Of course, bug reports and suggestions for improvements are always
|
155
222
|
welcome. GitHub pull requests are even better! :-)
|
156
223
|
|
224
|
+
## Mailing List
|
225
|
+
|
226
|
+
If you're interested in everything regarding RuboCop's development,
|
227
|
+
consider joining its
|
228
|
+
[Google Group](https://groups.google.com/forum/?fromgroups#!forum/rubocop).
|
229
|
+
|
157
230
|
## Changelog
|
158
231
|
|
159
232
|
RuboCop's changelog is available [here](CHANGELOG.md).
|