rubocop 0.3.0 → 0.6.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 (139) hide show
  1. data/.rubocop.yml +176 -0
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +60 -0
  4. data/CONTRIBUTING.md +13 -6
  5. data/Gemfile +1 -13
  6. data/README.md +131 -6
  7. data/Rakefile +1 -15
  8. data/bin/rubocop +2 -1
  9. data/lib/rubocop/cli.rb +133 -21
  10. data/lib/rubocop/cop/alias.rb +18 -0
  11. data/lib/rubocop/cop/align_parameters.rb +5 -4
  12. data/lib/rubocop/cop/array_literal.rb +22 -0
  13. data/lib/rubocop/cop/ascii_identifiers_and_comments.rb +18 -0
  14. data/lib/rubocop/cop/avoid_class_vars.rb +20 -0
  15. data/lib/rubocop/cop/avoid_for.rb +17 -0
  16. data/lib/rubocop/cop/avoid_perl_backrefs.rb +20 -0
  17. data/lib/rubocop/cop/avoid_perlisms.rb +46 -0
  18. data/lib/rubocop/cop/blocks.rb +1 -1
  19. data/lib/rubocop/cop/brace_after_percent.rb +28 -0
  20. data/lib/rubocop/cop/class_and_module_camel_case.rb +20 -0
  21. data/lib/rubocop/cop/collection_methods.rb +29 -0
  22. data/lib/rubocop/cop/cop.rb +16 -4
  23. data/lib/rubocop/cop/def_parentheses.rb +4 -1
  24. data/lib/rubocop/cop/encoding.rb +7 -5
  25. data/lib/rubocop/cop/end_of_line.rb +1 -3
  26. data/lib/rubocop/cop/ensure_return.rb +36 -0
  27. data/lib/rubocop/cop/favor_modifier.rb +82 -0
  28. data/lib/rubocop/cop/favor_percent_r.rb +19 -0
  29. data/lib/rubocop/cop/favor_sprintf.rb +37 -0
  30. data/lib/rubocop/cop/favor_unless_over_negated_if.rb +47 -0
  31. data/lib/rubocop/cop/grammar.rb +12 -8
  32. data/lib/rubocop/cop/handle_exceptions.rb +21 -0
  33. data/lib/rubocop/cop/hash_literal.rb +22 -0
  34. data/lib/rubocop/cop/indentation.rb +1 -1
  35. data/lib/rubocop/cop/line_length.rb +7 -3
  36. data/lib/rubocop/cop/method_and_variable_snake_case.rb +31 -0
  37. data/lib/rubocop/cop/method_length.rb +66 -0
  38. data/lib/rubocop/cop/new_lambda_literal.rb +17 -0
  39. data/lib/rubocop/cop/offence.rb +3 -1
  40. data/lib/rubocop/cop/op_method.rb +23 -0
  41. data/lib/rubocop/cop/parentheses_around_condition.rb +24 -0
  42. data/lib/rubocop/cop/percent_literals.rb +25 -0
  43. data/lib/rubocop/cop/percent_r.rb +19 -0
  44. data/lib/rubocop/cop/reduce_arguments.rb +67 -0
  45. data/lib/rubocop/cop/rescue_exception.rb +39 -0
  46. data/lib/rubocop/cop/rescue_modifier.rb +20 -0
  47. data/lib/rubocop/cop/semicolon.rb +18 -0
  48. data/lib/rubocop/cop/space_after_comma_etc.rb +2 -1
  49. data/lib/rubocop/cop/string_literals.rb +12 -0
  50. data/lib/rubocop/cop/surrounding_space.rb +48 -47
  51. data/lib/rubocop/cop/symbol_snake_case.rb +27 -0
  52. data/lib/rubocop/cop/syntax.rb +42 -0
  53. data/lib/rubocop/cop/tab.rb +1 -3
  54. data/lib/rubocop/cop/variable_interpolation.rb +20 -0
  55. data/lib/rubocop/cop/when_then.rb +3 -0
  56. data/lib/rubocop/report/emacs_style.rb +2 -2
  57. data/lib/rubocop/report/plain_text.rb +1 -1
  58. data/lib/rubocop/report/report.rb +5 -2
  59. data/lib/rubocop/version.rb +3 -1
  60. data/lib/rubocop.rb +37 -0
  61. data/rubocop.gemspec +36 -134
  62. data/spec/rubocop/cli_spec.rb +326 -48
  63. data/spec/rubocop/cops/alias_spec.rb +36 -0
  64. data/spec/rubocop/cops/align_parameters_spec.rb +43 -34
  65. data/spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb +4 -4
  66. data/spec/rubocop/cops/array_literal_spec.rb +29 -0
  67. data/spec/rubocop/cops/ascii_identifiers_and_comments_spec.rb +38 -0
  68. data/spec/rubocop/cops/avoid_class_vars_spec.rb +20 -0
  69. data/spec/rubocop/cops/avoid_for_spec.rb +22 -0
  70. data/spec/rubocop/cops/avoid_perl_backrefs_spec.rb +18 -0
  71. data/spec/rubocop/cops/avoid_perlisms_spec.rb +44 -0
  72. data/spec/rubocop/cops/brace_after_percent_spec.rb +27 -0
  73. data/spec/rubocop/cops/class_and_module_camel_case_spec.rb +34 -0
  74. data/spec/rubocop/cops/collection_methods_spec.rb +39 -0
  75. data/spec/rubocop/cops/cop_spec.rb +5 -5
  76. data/spec/rubocop/cops/def_with_parentheses_spec.rb +5 -5
  77. data/spec/rubocop/cops/def_without_parentheses_spec.rb +4 -4
  78. data/spec/rubocop/cops/empty_lines_spec.rb +8 -8
  79. data/spec/rubocop/cops/encoding_spec.rb +17 -11
  80. data/spec/rubocop/cops/end_of_line_spec.rb +5 -5
  81. data/spec/rubocop/cops/ensure_return_spec.rb +37 -0
  82. data/spec/rubocop/cops/favor_modifier_spec.rb +112 -0
  83. data/spec/rubocop/cops/favor_percent_r.rb +29 -0
  84. data/spec/rubocop/cops/favor_sprintf_spec.rb +57 -0
  85. data/spec/rubocop/cops/favor_unless_over_negated_if_spec.rb +62 -0
  86. data/spec/rubocop/cops/favor_until_over_negated_while_spec.rb +45 -0
  87. data/spec/rubocop/cops/grammar_spec.rb +59 -44
  88. data/spec/rubocop/cops/handle_exceptions_spec.rb +36 -0
  89. data/spec/rubocop/cops/hash_literal_spec.rb +29 -0
  90. data/spec/rubocop/cops/hash_syntax_spec.rb +10 -10
  91. data/spec/rubocop/cops/if_with_semicolon_spec.rb +3 -3
  92. data/spec/rubocop/cops/indentation_spec.rb +7 -7
  93. data/spec/rubocop/cops/line_length_spec.rb +4 -4
  94. data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +47 -0
  95. data/spec/rubocop/cops/method_length_spec.rb +150 -0
  96. data/spec/rubocop/cops/multiline_blocks_spec.rb +4 -4
  97. data/spec/rubocop/cops/multiline_if_then_spec.rb +7 -7
  98. data/spec/rubocop/cops/new_lambda_literal_spec.rb +23 -0
  99. data/spec/rubocop/cops/numeric_literals_spec.rb +10 -10
  100. data/spec/rubocop/cops/offence_spec.rb +10 -4
  101. data/spec/rubocop/cops/one_line_conditional_spec.rb +2 -3
  102. data/spec/rubocop/cops/op_method_spec.rb +58 -0
  103. data/spec/rubocop/cops/parameter_lists_spec.rb +4 -4
  104. data/spec/rubocop/cops/parentheses_around_condition_spec.rb +64 -0
  105. data/spec/rubocop/cops/percent_literals_spec.rb +47 -0
  106. data/spec/rubocop/cops/percent_r_spec.rb +29 -0
  107. data/spec/rubocop/cops/reduce_arguments_spec.rb +57 -0
  108. data/spec/rubocop/cops/rescue_exception_spec.rb +73 -0
  109. data/spec/rubocop/cops/rescue_modifier.rb +40 -0
  110. data/spec/rubocop/cops/semicolon_spec.rb +29 -0
  111. data/spec/rubocop/cops/single_line_blocks_spec.rb +4 -4
  112. data/spec/rubocop/cops/space_after_colon_spec.rb +5 -5
  113. data/spec/rubocop/cops/space_after_comma_spec.rb +3 -3
  114. data/spec/rubocop/cops/space_after_semicolon_spec.rb +3 -3
  115. data/spec/rubocop/cops/space_around_braces_spec.rb +6 -6
  116. data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +22 -0
  117. data/spec/rubocop/cops/space_around_operators_spec.rb +57 -25
  118. data/spec/rubocop/cops/space_inside_brackets_spec.rb +8 -8
  119. data/spec/rubocop/cops/space_inside_parens_spec.rb +4 -4
  120. data/spec/rubocop/cops/string_literals_spec.rb +9 -6
  121. data/spec/rubocop/cops/symbol_snake_case_spec.rb +74 -0
  122. data/spec/rubocop/cops/syntax_spec.rb +34 -0
  123. data/spec/rubocop/cops/tab_spec.rb +4 -4
  124. data/spec/rubocop/cops/ternary_operator_spec.rb +8 -8
  125. data/spec/rubocop/cops/trailing_whitespace_spec.rb +4 -4
  126. data/spec/rubocop/cops/unless_else_spec.rb +4 -4
  127. data/spec/rubocop/cops/variable_interpolation_spec.rb +45 -0
  128. data/spec/rubocop/cops/when_then_spec.rb +12 -5
  129. data/spec/rubocop/reports/emacs_style_spec.rb +3 -3
  130. data/spec/rubocop/reports/report_spec.rb +5 -5
  131. data/spec/spec_helper.rb +6 -0
  132. metadata +165 -36
  133. data/.rbenv-version +0 -1
  134. data/.rvmrc +0 -1
  135. data/Gemfile.lock +0 -39
  136. data/VERSION +0 -1
  137. data/features/rubocop.feature +0 -9
  138. data/features/step_definitions/rubocop_steps.rb +0 -1
  139. data/features/support/env.rb +0 -15
data/.rubocop.yml CHANGED
@@ -1,89 +1,265 @@
1
1
  # This is the default configuration file with all checking enabled. It is also
2
2
  # the configuration used to check the rubocop source code.
3
3
 
4
+ # Use UTF-8 as the source file encoding.
4
5
  Encoding:
5
6
  Enabled: true
6
7
 
8
+ # Limit lines to 80 characters.
7
9
  LineLength:
8
10
  Enabled: true
11
+ Max: 79
9
12
 
13
+ # Avoid methods longer than 10 lines of code
14
+ MethodLength:
15
+ Enabled: true
16
+ CountComments: false # count full line comments?
17
+ Max: 65
18
+
19
+ # No hard tabs.
10
20
  Tab:
11
21
  Enabled: true
12
22
 
23
+ # Avoid trailing whitespace.
13
24
  TrailingWhitespace:
14
25
  Enabled: true
15
26
 
27
+ # Indent when as deep as case.
16
28
  Indentation:
17
29
  Enabled: true
18
30
 
31
+ # Use empty lines between defs.
19
32
  EmptyLines:
20
33
  Enabled: true
21
34
 
35
+ # Use spaces around operators.
22
36
  SpaceAroundOperators:
23
37
  Enabled: true
24
38
 
39
+ # Use spaces around { and before }.
25
40
  SpaceAroundBraces:
26
41
  Enabled: true
27
42
 
43
+ # No spaces after ( or before ).
28
44
  SpaceInsideParens:
29
45
  Enabled: true
30
46
 
47
+ # No spaces after [ or before ].
31
48
  SpaceInsideBrackets:
32
49
  Enabled: true
33
50
 
51
+ # Use spaces after commas.
34
52
  SpaceAfterComma:
35
53
  Enabled: true
36
54
 
55
+ # Use spaces after semicolons.
37
56
  SpaceAfterSemicolon:
38
57
  Enabled: true
39
58
 
59
+ # Use spaces after colons.
40
60
  SpaceAfterColon:
41
61
  Enabled: true
42
62
 
63
+ # Prefer symbols instead of strings as hash keys.
43
64
  HashSyntax:
44
65
  Enabled: true
45
66
 
67
+ # Use Unix-style line endings.
46
68
  EndOfLine:
47
69
  Enabled: true
48
70
 
71
+ # Add underscores to large numeric literals to improve their readability.
49
72
  NumericLiterals:
50
73
  Enabled: true
51
74
 
75
+ # Align the parameters of a method call if they span more than one line.
52
76
  AlignParameters:
53
77
  Enabled: true
54
78
 
79
+ # Use def with parentheses when there are arguments.
55
80
  DefWithParentheses:
56
81
  Enabled: true
57
82
 
83
+ # Omit the parentheses when the method doesn't accept any arguments.
58
84
  DefWithoutParentheses:
59
85
  Enabled: true
60
86
 
87
+ # Never use if x; .... Use the ternary operator instead.
61
88
  IfWithSemicolon:
62
89
  Enabled: true
63
90
 
91
+ # Never use then for multi-line if/unless.
64
92
  MultilineIfThen:
65
93
  Enabled: true
66
94
 
95
+ # Favor the ternary operator(?:) over if/then/else/end constructs.
67
96
  OneLineConditional:
68
97
  Enabled: true
69
98
 
99
+ # Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
70
100
  MultilineBlocks:
71
101
  Enabled: true
72
102
 
103
+ # Prefer {...} over do...end for single-line blocks.
73
104
  SingleLineBlocks:
74
105
  Enabled: true
75
106
 
107
+ # Avoid parameter lists longer than three or four parameters.
76
108
  ParameterLists:
77
109
  Enabled: true
78
110
 
111
+ # Prefer ' strings when you don't need string interpolation or special symbols.
79
112
  StringLiterals:
80
113
  Enabled: true
81
114
 
115
+ # Avoid multi-line ?: (the ternary operator); use if/unless instead.
82
116
  MultilineTernaryOperator:
83
117
  Enabled: true
84
118
 
119
+ # Use one expression per branch in a ternary operator.
85
120
  NestedTernaryOperator:
86
121
  Enabled: true
87
122
 
123
+ # Never use unless with else. Rewrite these with the positive case first.
88
124
  UnlessElse:
89
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
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
+ - 2.0.0
4
5
  script: bundle exec rspec
data/CHANGELOG.md ADDED
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ ## master (unreleased)
4
+
5
+ ### New features
6
+
7
+ ### Bugs fixed
8
+
9
+ ## 0.6.0 (04/23/2013)
10
+
11
+ ### New features
12
+
13
+ * New cop `ReduceArguments` tracks argument names in reduce calls
14
+ * New cop `MethodLength` tracks number of LOC (lines of code) in methods
15
+ * New cop `RescueModifier` tracks uses of `rescue` in modifier form.
16
+ * New cop `PercentLiterals` tracks uses of `%q`, `%Q`, `%s` and `%x`.
17
+ * New cop `BraceAfterPercent` tracks uses of % literals with
18
+ delimiters other than ().
19
+ * Support for disabling cops locally in a file with rubocop:disable comments.
20
+ * New cop `EnsureReturn` tracks usages of `return` in `ensure` blocks.
21
+ * New cop `HandleExceptions` tracks suppressed exceptions.
22
+ * New cop `AsciiIdentifiersAndComments` tracks uses of non-ascii
23
+ characters in identifiers and comments.
24
+ * New cop `RescueException` tracks uses of rescuing the `Exception` class.
25
+ * New cop `ArrayLiteral` tracks uses of Array.new.
26
+ * New cop `HashLiteral` tracks uses of Hash.new.
27
+ * New cop `OpMethod` tracks the argument name in operator methods.
28
+ * New cop `PercentR` tracks uses of %r literals with zero or one slash in the regexp.
29
+ * New cop `FavorPercentR` tracks uses of // literals with more than one slash in the regexp.
30
+
31
+ ### Bugs fixed
32
+
33
+ * [#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
35
+ * [#66](https://github.com/bbatsov/rubocop/issues/66) - Does not crash on unreadable or unparseable files
36
+ * [#70](https://github.com/bbatsov/rubocop/issues/70) - Support `alias` with bareword arguments
37
+ * [#64](https://github.com/bbatsov/rubocop/issues/64) - Performance issue with Bundler
38
+ * [#75](https://github.com/bbatsov/rubocop/issues/75) - Make it clear that some global variables require the use of the English library
39
+ * [#79](https://github.com/bbatsov/rubocop/issues/79) - Ternary operator missing whitespace detection
40
+
41
+ ### Misc
42
+
43
+ * Dropped Jeweler for gem release management since it's no longer
44
+ actively maintained.
45
+ * Handle pluralization properly in the final summary.
46
+
47
+ ## 0.5.0 (04/17/2013)
48
+
49
+ ### New features
50
+
51
+ * New cop `FavorSprintf` that checks for usages of `String#%`
52
+ * New cop `Semicolon` that checks for usages of `;` as expression separator
53
+ * New cop `VariableInterpolation` that checks for variable interpolation in double quoted strings
54
+ * New cop `Alias` that checks for uses of the keyword `alias`
55
+ * Automatically detect extensionless Ruby files with shebangs when search for Ruby source files in a directory
56
+
57
+ ### Bugs fixed
58
+
59
+ * [#59](https://github.com/bbatsov/rubocop/issues/59) - Interpolated variables not enclosed in braces are not noticed
60
+ * [#42](https://github.com/bbatsov/rubocop/issues/42) - Received malformed format string ArgumentError from rubocop
data/CONTRIBUTING.md CHANGED
@@ -1,9 +1,16 @@
1
- # Contributing to Rubocop
2
-
3
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
4
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
1
+ # Contributing to RuboCop
2
+
3
+ * Check out the latest master to make sure the feature hasn't been
4
+ implemented or the bug hasn't been fixed yet.
5
+ * Check out the issue tracker to make sure someone already hasn't
6
+ requested it and/or contributed it.
5
7
  * Fork the project.
6
8
  * Start a feature/bugfix branch.
7
9
  * Commit and push until you are happy with your contribution.
8
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
9
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
10
+ * Make sure to add tests for it. This is important so I don't break it
11
+ in a future version unintentionally.
12
+ * Update the [Changelog](CHANGELOG.md) accordingly.
13
+ * Please try not to mess with the Rakefile, version, or history. If
14
+ you want to have your own version, or is otherwise necessary, that
15
+ is fine, but please isolate to its own commit so I can cherry-pick
16
+ around it.
data/Gemfile CHANGED
@@ -1,15 +1,3 @@
1
1
  source 'http://rubygems.org'
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem 'rake', '~> 10.0.0'
10
- gem 'rspec', '~> 2.12.0'
11
- gem 'yard', '~> 0.8.0'
12
- gem 'bundler', '~> 1.2.0'
13
- gem 'jeweler', '~> 1.8.3'
14
- gem 'simplecov'
15
- end
3
+ gemspec
data/README.md CHANGED
@@ -1,25 +1,150 @@
1
+ [![Gem Version](https://badge.fury.io/rb/rubocop.png)](http://badge.fury.io/rb/rubocop)
1
2
  [![Build Status](https://travis-ci.org/bbatsov/rubocop.png?branch=master)](https://travis-ci.org/bbatsov/rubocop)
2
3
 
3
- # rubocop
4
+ # RuboCop
4
5
 
5
- Ruby code style checker based on the [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
6
+ > Role models are important. <br/>
7
+ > -- Officer Alex J. Murphy / RoboCop
8
+
9
+ **RuboCop** is a Ruby code style checker based on the
10
+ [Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
11
+
12
+ ## Installation
13
+
14
+ **RuboCop**'s installation is pretty standard:
15
+
16
+ ```bash
17
+ $ gem install rubocop
18
+ ```
6
19
 
7
20
  ## Basic Usage
8
21
 
9
- Running `rubocop` with no arguments will check all Ruby source files in the current folder:
22
+ Running `rubocop` with no arguments will check all Ruby source files
23
+ in the current folder:
10
24
 
11
25
  ```bash
12
26
  $ rubocop
13
27
  ```
14
28
 
15
- Alternatively you can `rubocop` a list of files and folders to check:
29
+ Alternatively you can pass `rubocop` a list of files and folders to check:
16
30
 
17
31
  ```bash
18
32
  $ rubocop app spec lib/something.rb
19
33
  ```
20
34
 
35
+ For more details check the available command-line options:
36
+
37
+ ```bash
38
+ $ rubocop -h
39
+ ```
40
+
41
+ Command flag | Description
42
+ -------------------|------------------------------------------------------------
43
+ `-v/--version` | Displays the current version and exits
44
+ `-d/--debug` | Displays some extra debug output
45
+ `-e/--emacs` | Output the results in Emacs format
46
+ `-c/--config` | Run with specified config file
47
+ `-s/--silent` | Suppress the final summary
48
+
49
+ ## Configuration
50
+
51
+ The behavior of RuboCop can be controlled via the
52
+ [.rubocop.yml](https://github.com/bbatsov/rubocop/blob/master/.rubocop.yml)
53
+ configuration file. The file can be placed either in your home folder
54
+ or in some project folder.
55
+
56
+ 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.
58
+
59
+ The file has the following format:
60
+
61
+ ```yml
62
+ Encoding:
63
+ Enabled: true
64
+
65
+ LineLength:
66
+ Enabled: true
67
+ Max: 79
68
+ ```
69
+
70
+ It allows to enable/disable certain cops (checks) and to alter their
71
+ behavior if they accept any parameters.
72
+
73
+ One or more individual cops can be disabled locally in a section of a
74
+ file by adding a comment such as
75
+
76
+ ```ruby
77
+ # rubocop:disable LineLength, StringLiterals
78
+ [...]
79
+ # rubocop:enable LineLength, StringLiterals
80
+ ```
81
+
82
+ You can also disable *all* cops with
83
+
84
+ ```ruby
85
+ # rubocop:disable all
86
+ [...]
87
+ # rubocop:enable all
88
+ ```
89
+
90
+ One or more cops can be disabled on a single line with an end-of-line
91
+ comment.
92
+
93
+ ```ruby
94
+ for x in (0..19) # rubocop:disable AvoidFor
95
+ ```
96
+
97
+ ## Compatibility
98
+
99
+ Unfortunately every major Ruby implementation has its own code
100
+ analysis tooling, which makes the development of a portable code
101
+ analyzer a daunting task.
102
+
103
+ RuboCop currently supports MRI 1.9 and MRI 2.0. Support for JRuby and
104
+ Rubinius is not planned at this point.
105
+
106
+ ## Editor integration
107
+
108
+ ### Emacs
109
+
110
+ [rubocop.el](https://github.com/bbatsov/rubocop-emacs) is a simple
111
+ Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
112
+ and quickly jump between problems in your code.
113
+
114
+ [flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports
115
+ RuboCop and uses it by default when available.
116
+
117
+ ### Other Editors
118
+
119
+ Here's one great opportunity to contribute to RuboCop - implement
120
+ RuboCop integration for your favorite editor.
121
+
122
+ ## Contributors
123
+
124
+ Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
125
+ all the people who have contributed to the development of RuboCop.
126
+
127
+ I'm extremely grateful to each and every one of them!
128
+
129
+ I'd like to single out [Jonas Arvidsson](https://github.com/jonas054)
130
+ for his many excellent code contributions as well as valuable feedback
131
+ and ideas!
132
+
133
+ If you'd like to contribute to RuboCop, please take the time to go
134
+ through our short
135
+ [contribution guidelines](CONTRIBUTING.md).
136
+
137
+ Converting more of the Ruby Style Guide into RuboCop cops is our top
138
+ priority right now. Writing a new cop is a great way to dive into RuboCop!
139
+
140
+ Of course, bug reports and suggestions for improvements are always
141
+ welcome. GitHub pull requests are even better! :-)
142
+
143
+ ## Changelog
144
+
145
+ RuboCop's changelog is available [here](CHANGELOG.md).
146
+
21
147
  ## Copyright
22
148
 
23
- Copyright (c) 2012-2013 Bozhidar Batsov. See LICENSE.txt for
149
+ Copyright (c) 2012-2013 Bozhidar Batsov. See [LICENSE.txt](LICENSE.txt) for
24
150
  further details.
25
-
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'bundler'
5
+ require 'bundler/gem_tasks'
5
6
  begin
6
7
  Bundler.setup(:default, :development)
7
8
  rescue Bundler::BundlerError => e
@@ -10,21 +11,6 @@ rescue Bundler::BundlerError => e
10
11
  exit e.status_code
11
12
  end
12
13
  require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "rubocop"
18
- gem.homepage = "http://github.com/bbatsov/rubocop"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Automatic Ruby code style checking tool.}
21
- gem.description = %Q{Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.}
22
- gem.email = "bozhidar@batsov.com"
23
- gem.authors = ["Bozhidar Batsov"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
14
  require 'rspec/core'
29
15
  require 'rspec/core/rake_task'
30
16
  RSpec::Core::RakeTask.new(:spec) do |spec|
data/bin/rubocop CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # encoding: utf-8
2
3
 
3
4
  $LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
4
5
 
@@ -12,5 +13,5 @@ time = Benchmark.realtime do
12
13
  result = cli.run
13
14
  end
14
15
 
15
- puts "Finished in #{time} seconds" if $options[:verbose]
16
+ puts "Finished in #{time} seconds" if $options[:debug]
16
17
  exit result