rubocop 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +4 -262
  3. data/CHANGELOG.md +65 -1
  4. data/Gemfile +4 -0
  5. data/README.md +89 -2
  6. data/Rakefile +2 -2
  7. data/bin/rubocop +15 -10
  8. data/lib/rubocop/cli.rb +156 -114
  9. data/lib/rubocop/config.rb +202 -0
  10. data/lib/rubocop/config_store.rb +37 -0
  11. data/lib/rubocop/cop/alias.rb +2 -5
  12. data/lib/rubocop/cop/align_parameters.rb +1 -1
  13. data/lib/rubocop/cop/array_literal.rb +43 -4
  14. data/lib/rubocop/cop/{ascii_identifiers_and_comments.rb → ascii_comments.rb} +3 -3
  15. data/lib/rubocop/cop/ascii_identifiers.rb +18 -0
  16. data/lib/rubocop/cop/avoid_for.rb +2 -4
  17. data/lib/rubocop/cop/avoid_global_vars.rb +49 -0
  18. data/lib/rubocop/cop/block_comments.rb +17 -0
  19. data/lib/rubocop/cop/brace_after_percent.rb +9 -5
  20. data/lib/rubocop/cop/{indentation.rb → case_indentation.rb} +1 -1
  21. data/lib/rubocop/cop/class_methods.rb +20 -0
  22. data/lib/rubocop/cop/colon_method_call.rb +44 -0
  23. data/lib/rubocop/cop/cop.rb +33 -0
  24. data/lib/rubocop/cop/def_parentheses.rb +1 -1
  25. data/lib/rubocop/cop/empty_line_between_defs.rb +26 -0
  26. data/lib/rubocop/cop/empty_lines.rb +10 -13
  27. data/lib/rubocop/cop/eval.rb +22 -0
  28. data/lib/rubocop/cop/favor_join.rb +37 -0
  29. data/lib/rubocop/cop/grammar.rb +2 -2
  30. data/lib/rubocop/cop/hash_literal.rb +43 -4
  31. data/lib/rubocop/cop/hash_syntax.rb +2 -2
  32. data/lib/rubocop/cop/if_then_else.rb +1 -1
  33. data/lib/rubocop/cop/leading_comment_space.rb +20 -0
  34. data/lib/rubocop/cop/line_continuation.rb +18 -0
  35. data/lib/rubocop/cop/line_length.rb +1 -1
  36. data/lib/rubocop/cop/method_and_variable_snake_case.rb +7 -6
  37. data/lib/rubocop/cop/method_length.rb +4 -15
  38. data/lib/rubocop/cop/not.rb +15 -0
  39. data/lib/rubocop/cop/offence.rb +9 -0
  40. data/lib/rubocop/cop/op_method.rb +6 -1
  41. data/lib/rubocop/cop/semicolon.rb +74 -3
  42. data/lib/rubocop/cop/single_line_methods.rb +60 -0
  43. data/lib/rubocop/cop/space_after_comma_etc.rb +4 -5
  44. data/lib/rubocop/cop/space_after_control_keyword.rb +28 -0
  45. data/lib/rubocop/cop/surrounding_space.rb +48 -9
  46. data/lib/rubocop/cop/symbol_array.rb +29 -0
  47. data/lib/rubocop/cop/symbol_snake_case.rb +20 -0
  48. data/lib/rubocop/cop/trivial_accessors.rb +103 -0
  49. data/lib/rubocop/cop/unless_else.rb +1 -1
  50. data/lib/rubocop/cop/variable_interpolation.rb +3 -2
  51. data/lib/rubocop/cop/word_array.rb +38 -0
  52. data/lib/rubocop/report/plain_text.rb +1 -1
  53. data/lib/rubocop/version.rb +1 -1
  54. data/lib/rubocop.rb +22 -7
  55. data/rubocop.gemspec +11 -7
  56. data/spec/project_spec.rb +27 -0
  57. data/spec/rubocop/cli_spec.rb +556 -388
  58. data/spec/rubocop/config_spec.rb +399 -0
  59. data/spec/rubocop/config_store_spec.rb +66 -0
  60. data/spec/rubocop/cops/alias_spec.rb +7 -0
  61. data/spec/rubocop/cops/array_literal_spec.rb +18 -1
  62. data/spec/rubocop/cops/ascii_comments_spec.rb +27 -0
  63. data/spec/rubocop/cops/ascii_identifiers_spec.rb +27 -0
  64. data/spec/rubocop/cops/avoid_for_spec.rb +15 -1
  65. data/spec/rubocop/cops/avoid_global_vars.rb +32 -0
  66. data/spec/rubocop/cops/block_comments_spec.rb +29 -0
  67. data/spec/rubocop/cops/brace_after_percent_spec.rb +19 -13
  68. data/spec/rubocop/cops/{indentation_spec.rb → case_indentation_spec.rb} +2 -2
  69. data/spec/rubocop/cops/class_methods_spec.rb +49 -0
  70. data/spec/rubocop/cops/colon_method_call_spec.rb +47 -0
  71. data/spec/rubocop/cops/empty_line_between_defs_spec.rb +83 -0
  72. data/spec/rubocop/cops/empty_lines_spec.rb +6 -63
  73. data/spec/rubocop/cops/eval_spec.rb +36 -0
  74. data/spec/rubocop/cops/favor_join_spec.rb +39 -0
  75. data/spec/rubocop/cops/hash_literal_spec.rb +18 -1
  76. data/spec/rubocop/cops/leading_comment_space_spec.rb +60 -0
  77. data/spec/rubocop/cops/line_continuation_spec.rb +24 -0
  78. data/spec/rubocop/cops/line_length_spec.rb +1 -0
  79. data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +20 -0
  80. data/spec/rubocop/cops/method_length_spec.rb +2 -5
  81. data/spec/rubocop/cops/new_lambda_literal_spec.rb +2 -3
  82. data/spec/rubocop/cops/not_spec.rb +34 -0
  83. data/spec/rubocop/cops/offence_spec.rb +7 -0
  84. data/spec/rubocop/cops/op_method_spec.rb +11 -0
  85. data/spec/rubocop/cops/semicolon_spec.rb +79 -4
  86. data/spec/rubocop/cops/single_line_methods_spec.rb +50 -0
  87. data/spec/rubocop/cops/space_after_control_keyword_spec.rb +28 -0
  88. data/spec/rubocop/cops/space_after_semicolon_spec.rb +5 -0
  89. data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +11 -1
  90. data/spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb +74 -0
  91. data/spec/rubocop/cops/symbol_array_spec.rb +25 -0
  92. data/spec/rubocop/cops/symbol_snake_case_spec.rb +13 -0
  93. data/spec/rubocop/cops/trivial_accessors_spec.rb +332 -0
  94. data/spec/rubocop/cops/variable_interpolation_spec.rb +10 -1
  95. data/spec/rubocop/cops/word_array_spec.rb +39 -0
  96. data/spec/spec_helper.rb +18 -5
  97. data/spec/support/file_helper.rb +21 -0
  98. data/spec/support/isolated_environment.rb +27 -0
  99. metadata +82 -36
  100. data/spec/rubocop/cops/ascii_identifiers_and_comments_spec.rb +0 -38
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 821a707cffadfcc5e7996087447ced23fb3d3767
4
+ data.tar.gz: 0c2efc8203808c7b7b04fdf94c6c5d587b2fdcaa
5
+ SHA512:
6
+ metadata.gz: 19fab984add9357970945fd82006ac71069958b117979b0fef6d3aade60111eec6c10d213e73a82a180a3cf87225d2a4db6341827f36d556b57570a4147c6613
7
+ data.tar.gz: 6c222ea27957f3cb861fd3ccf31a0795a8a8cd46b0e2d5712aa0d5bebe92a5cfa442f275599ab7810d739019941a4f2cc961c2269548dfa13fd0d7e1744ee391
data/.rubocop.yml CHANGED
@@ -1,265 +1,7 @@
1
- # This is the default configuration file with all checking enabled. It is also
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
- # Use UTF-8 as the source file encoding.
5
- Encoding:
6
- Enabled: true
3
+ inherit_from: config/default.yml
7
4
 
8
- # Limit lines to 80 characters.
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
- Enabled: true
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 and comments.
236
- AsciiIdentifiersAndComments:
237
- Enabled: true
238
-
239
- # Avoid rescuing the Exception class.
240
- RescueException:
241
- Enabled: true
242
-
243
- # Prefer array literal to Array.new.
244
- ArrayLiteral:
245
- Enabled: true
246
-
247
- # Prefer hash {} literail to Hash.new.
248
- HashLiteral:
249
- Enabled: true
250
-
251
- # When defining binary operators, name the argument other.
252
- OpMethod:
253
- Enabled: true
254
-
255
- # Name reduce arguments |a, e| (accumulator, element)
256
- ReduceArguments:
257
- Enabled: true
258
-
259
- # Use %r only for regular expressions matching more than one '/' character.
260
- PercentR:
261
- Enabled: true
262
-
263
- # Use %r for regular expressions matching more than one '/' character.
264
- FavorPercentR:
265
- Enabled: true
7
+ Max: 30
data/CHANGELOG.md CHANGED
@@ -6,6 +6,70 @@
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
+
51
+ ## 0.6.1 (04/28/2013)
52
+
53
+ ### New features
54
+
55
+ * Split `AsciiIdentifiersAndComments` cop in two separate cops
56
+
57
+ ### Bugs fixed
58
+
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`
61
+ * [#97](https://github.com/bbatsov/rubocop/issues/97) Build fails
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
64
+
65
+ ### Misc
66
+
67
+ * [#88](https://github.com/bbatsov/rubocop/issues/88) Abort gracefully when interrupted with Ctrl-C
68
+ * No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed.
69
+ * Replaced `Term::ANSIColor` with `Rainbow`.
70
+ * Add an option to disable colors in the output.
71
+ * Cop names are now displayed alongside messages when `-d/--debug` is passed.
72
+
9
73
  ## 0.6.0 (04/23/2013)
10
74
 
11
75
  ### New features
@@ -31,7 +95,7 @@
31
95
  ### Bugs fixed
32
96
 
33
97
  * [#62](https://github.com/bbatsov/rubocop/issues/62) - Config files in ancestor directories are ignored if another exists in home directory
34
- * [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols :==, :<=> and the like to snake_case
98
+ * [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols `:==`, `:<=>` and the like to snake_case
35
99
  * [#66](https://github.com/bbatsov/rubocop/issues/66) - Does not crash on unreadable or unparseable files
36
100
  * [#70](https://github.com/bbatsov/rubocop/issues/70) - Support `alias` with bareword arguments
37
101
  * [#64](https://github.com/bbatsov/rubocop/issues/64) - Performance issue with Bundler
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :test do
6
+ gem 'coveralls', require: false
7
+ end
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rubocop.png)](http://badge.fury.io/rb/rubocop)
2
2
  [![Build Status](https://travis-ci.org/bbatsov/rubocop.png?branch=master)](https://travis-ci.org/bbatsov/rubocop)
3
+ [![Coverage Status](https://coveralls.io/repos/bbatsov/rubocop/badge.png?branch=master)](https://coveralls.io/r/bbatsov/rubocop)
3
4
 
4
5
  # RuboCop
5
6
 
@@ -45,6 +46,7 @@ Command flag | Description
45
46
  `-e/--emacs` | Output the results in Emacs format
46
47
  `-c/--config` | Run with specified config file
47
48
  `-s/--silent` | Suppress the final summary
49
+ `--only` | Run only the specified cop
48
50
 
49
51
  ## Configuration
50
52
 
@@ -54,11 +56,13 @@ configuration file. The file can be placed either in your home folder
54
56
  or in some project folder.
55
57
 
56
58
  RuboCop will start looking for the configuration file in the directory
57
- it was started in and continue its way up to the home folder.
59
+ where the inspected file is and continue its way up to the root folder.
58
60
 
59
61
  The file has the following format:
60
62
 
61
- ```yml
63
+ ```yaml
64
+ inherit_from: ../.rubocop.yml
65
+
62
66
  Encoding:
63
67
  Enabled: true
64
68
 
@@ -70,6 +74,34 @@ LineLength:
70
74
  It allows to enable/disable certain cops (checks) and to alter their
71
75
  behavior if they accept any parameters.
72
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
+
73
105
  One or more individual cops can be disabled locally in a section of a
74
106
  file by adding a comment such as
75
107
 
@@ -94,6 +126,33 @@ comment.
94
126
  for x in (0..19) # rubocop:disable AvoidFor
95
127
  ```
96
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
+
97
156
  ## Compatibility
98
157
 
99
158
  Unfortunately every major Ruby implementation has its own code
@@ -114,11 +173,33 @@ and quickly jump between problems in your code.
114
173
  [flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports
115
174
  RuboCop and uses it by default when available.
116
175
 
176
+ ### Vim
177
+
178
+ The [vim-rubocop](https://github.com/ngmy/vim-rubocop) plugin runs
179
+ RuboCop and displays the results in Vim.
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
+
117
190
  ### Other Editors
118
191
 
119
192
  Here's one great opportunity to contribute to RuboCop - implement
120
193
  RuboCop integration for your favorite editor.
121
194
 
195
+ ## Guard integration
196
+
197
+ If you're fond of [Guard](https://github.com/guard/guard) you might
198
+ like
199
+ [guard-rubocop](https://github.com/yujinakayama/guard-rubocop). It
200
+ allows you to automatically check Ruby code style with RuboCop when
201
+ files are modified.
202
+
122
203
  ## Contributors
123
204
 
124
205
  Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
@@ -140,6 +221,12 @@ priority right now. Writing a new cop is a great way to dive into RuboCop!
140
221
  Of course, bug reports and suggestions for improvements are always
141
222
  welcome. GitHub pull requests are even better! :-)
142
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
+
143
230
  ## Changelog
144
231
 
145
232
  RuboCop's changelog is available [here](CHANGELOG.md).
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ begin
7
7
  Bundler.setup(:default, :development)
8
8
  rescue Bundler::BundlerError => e
9
9
  $stderr.puts e.message
10
- $stderr.puts "Run `bundle install` to install missing gems"
10
+ $stderr.puts 'Run `bundle install` to install missing gems'
11
11
  exit e.status_code
12
12
  end
13
13
  require 'rake'
@@ -23,7 +23,7 @@ task :coverage do
23
23
  Rake::Task['spec'].execute
24
24
  end
25
25
 
26
- task :default => :spec
26
+ task default: :spec
27
27
 
28
28
  require 'yard'
29
29
  YARD::Rake::YardocTask.new
data/bin/rubocop CHANGED
@@ -1,17 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
4
+ if RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9.2'
5
+ $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
5
6
 
6
- require 'rubocop'
7
- require 'benchmark'
7
+ require 'rubocop'
8
+ require 'benchmark'
8
9
 
9
- cli = Rubocop::CLI.new
10
- result = 0
10
+ cli = Rubocop::CLI.new
11
+ result = 0
11
12
 
12
- time = Benchmark.realtime do
13
- result = cli.run
14
- end
13
+ time = Benchmark.realtime do
14
+ result = cli.run
15
+ end
15
16
 
16
- puts "Finished in #{time} seconds" if $options[:debug]
17
- exit result
17
+ puts "Finished in #{time} seconds" if cli.options[:debug]
18
+ exit result
19
+ else
20
+ puts 'RuboCop supports only MRI 1.9.2+'
21
+ exit(-1)
22
+ end