rubocop 0.4.0 → 0.8.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 +7 -0
- data/.gitignore +50 -0
- data/.rubocop.yml +5 -127
- data/.travis.yml +7 -1
- data/CHANGELOG.md +157 -0
- data/CONTRIBUTING.md +13 -6
- data/Gemfile +3 -8
- data/README.md +160 -9
- data/Rakefile +3 -17
- data/bin/rubocop +16 -10
- data/config/default.yml +46 -0
- data/config/disabled.yml +5 -0
- data/config/enabled.yml +322 -0
- data/lib/rubocop/cli.rb +248 -93
- data/lib/rubocop/config.rb +205 -0
- data/lib/rubocop/config_store.rb +37 -0
- data/lib/rubocop/cop/access_control.rb +41 -0
- data/lib/rubocop/cop/alias.rb +17 -0
- data/lib/rubocop/cop/align_parameters.rb +20 -95
- data/lib/rubocop/cop/and_or.rb +26 -0
- data/lib/rubocop/cop/ascii_comments.rb +13 -0
- data/lib/rubocop/cop/ascii_identifiers.rb +19 -0
- data/lib/rubocop/cop/avoid_class_vars.rb +15 -0
- data/lib/rubocop/cop/avoid_for.rb +17 -0
- data/lib/rubocop/cop/avoid_global_vars.rb +61 -0
- data/lib/rubocop/cop/avoid_perl_backrefs.rb +17 -0
- data/lib/rubocop/cop/avoid_perlisms.rb +47 -0
- data/lib/rubocop/cop/block_comments.rb +15 -0
- data/lib/rubocop/cop/blocks.rb +11 -47
- data/lib/rubocop/cop/case_indentation.rb +22 -0
- data/lib/rubocop/cop/class_and_module_camel_case.rb +20 -11
- data/lib/rubocop/cop/class_methods.rb +15 -0
- data/lib/rubocop/cop/collection_methods.rb +16 -16
- data/lib/rubocop/cop/colon_method_call.rb +20 -0
- data/lib/rubocop/cop/constant_name.rb +24 -0
- data/lib/rubocop/cop/cop.rb +34 -47
- data/lib/rubocop/cop/def_parentheses.rb +43 -35
- data/lib/rubocop/cop/empty_line_between_defs.rb +22 -0
- data/lib/rubocop/cop/empty_lines.rb +21 -13
- data/lib/rubocop/cop/empty_literal.rb +47 -0
- data/lib/rubocop/cop/encoding.rb +3 -3
- data/lib/rubocop/cop/end_of_line.rb +3 -3
- data/lib/rubocop/cop/ensure_return.rb +19 -0
- data/lib/rubocop/cop/eval.rb +19 -0
- data/lib/rubocop/cop/favor_join.rb +22 -0
- data/lib/rubocop/cop/favor_modifier.rb +38 -48
- data/lib/rubocop/cop/favor_percent_r.rb +19 -0
- data/lib/rubocop/cop/favor_sprintf.rb +21 -0
- data/lib/rubocop/cop/favor_unless_over_negated_if.rb +19 -17
- data/lib/rubocop/cop/handle_exceptions.rb +17 -0
- data/lib/rubocop/cop/hash_syntax.rb +29 -14
- data/lib/rubocop/cop/if_then_else.rb +32 -29
- data/lib/rubocop/cop/leading_comment_space.rb +17 -0
- data/lib/rubocop/cop/line_continuation.rb +15 -0
- data/lib/rubocop/cop/line_length.rb +4 -4
- data/lib/rubocop/cop/loop.rb +33 -0
- data/lib/rubocop/cop/method_and_variable_snake_case.rb +41 -17
- data/lib/rubocop/cop/method_length.rb +52 -0
- data/lib/rubocop/cop/new_lambda_literal.rb +8 -6
- data/lib/rubocop/cop/not.rb +21 -0
- data/lib/rubocop/cop/numeric_literals.rb +9 -7
- data/lib/rubocop/cop/offence.rb +12 -1
- data/lib/rubocop/cop/op_method.rb +26 -0
- data/lib/rubocop/cop/parameter_lists.rb +12 -6
- data/lib/rubocop/cop/parentheses_around_condition.rb +11 -11
- data/lib/rubocop/cop/percent_r.rb +19 -0
- data/lib/rubocop/cop/reduce_arguments.rb +29 -0
- data/lib/rubocop/cop/rescue_exception.rb +26 -0
- data/lib/rubocop/cop/rescue_modifier.rb +17 -0
- data/lib/rubocop/cop/semicolon.rb +31 -0
- data/lib/rubocop/cop/single_line_methods.rb +44 -0
- data/lib/rubocop/cop/space_after_comma_etc.rb +30 -10
- data/lib/rubocop/cop/space_after_control_keyword.rb +29 -0
- data/lib/rubocop/cop/string_literals.rb +9 -23
- data/lib/rubocop/cop/surrounding_space.rb +223 -83
- data/lib/rubocop/cop/symbol_array.rb +31 -0
- data/lib/rubocop/cop/symbol_name.rb +23 -0
- data/lib/rubocop/cop/syntax.rb +35 -5
- data/lib/rubocop/cop/tab.rb +3 -3
- data/lib/rubocop/cop/ternary_operator.rb +26 -24
- data/lib/rubocop/cop/trailing_whitespace.rb +3 -5
- data/lib/rubocop/cop/trivial_accessors.rb +26 -0
- data/lib/rubocop/cop/unless_else.rb +11 -7
- data/lib/rubocop/cop/util.rb +26 -0
- data/lib/rubocop/cop/variable_interpolation.rb +29 -0
- data/lib/rubocop/cop/when_then.rb +6 -14
- data/lib/rubocop/cop/word_array.rb +37 -0
- data/lib/rubocop/report/emacs_style.rb +2 -2
- data/lib/rubocop/report/plain_text.rb +1 -1
- data/lib/rubocop/version.rb +3 -1
- data/lib/rubocop.rb +48 -8
- data/rubocop.gemspec +32 -151
- data/spec/project_spec.rb +27 -0
- data/spec/rubocop/cli_spec.rb +573 -200
- data/spec/rubocop/config_spec.rb +409 -0
- data/spec/rubocop/config_store_spec.rb +66 -0
- data/spec/rubocop/cops/access_control_spec.rb +129 -0
- data/spec/rubocop/cops/alias_spec.rb +39 -0
- data/spec/rubocop/cops/align_parameters_spec.rb +66 -70
- data/spec/rubocop/cops/and_or_spec.rb +37 -0
- data/spec/rubocop/cops/ascii_comments_spec.rb +26 -0
- data/spec/rubocop/cops/ascii_identifiers_spec.rb +26 -0
- data/spec/rubocop/cops/avoid_class_vars_spec.rb +25 -0
- data/spec/rubocop/cops/avoid_for_spec.rb +35 -0
- data/spec/rubocop/cops/avoid_global_vars_spec.rb +32 -0
- data/spec/rubocop/cops/avoid_perl_backrefs_spec.rb +18 -0
- data/spec/rubocop/cops/avoid_perlisms_spec.rb +44 -0
- data/spec/rubocop/cops/block_comments_spec.rb +25 -0
- data/spec/rubocop/cops/blocks_spec.rb +33 -0
- data/spec/rubocop/cops/{indentation_spec.rb → case_indentation_spec.rb} +7 -7
- data/spec/rubocop/cops/class_and_module_camel_case_spec.rb +15 -5
- data/spec/rubocop/cops/class_methods_spec.rb +49 -0
- data/spec/rubocop/cops/collection_methods_spec.rb +9 -4
- data/spec/rubocop/cops/colon_method_call_spec.rb +53 -0
- data/spec/rubocop/cops/constant_name_spec.rb +42 -0
- data/spec/rubocop/cops/def_with_parentheses_spec.rb +13 -8
- data/spec/rubocop/cops/def_without_parentheses_spec.rb +11 -5
- data/spec/rubocop/cops/empty_line_between_defs_spec.rb +83 -0
- data/spec/rubocop/cops/empty_lines_spec.rb +14 -59
- data/spec/rubocop/cops/empty_literal_spec.rb +90 -0
- data/spec/rubocop/cops/encoding_spec.rb +11 -11
- data/spec/rubocop/cops/end_of_line_spec.rb +2 -2
- data/spec/rubocop/cops/ensure_return_spec.rb +35 -0
- data/spec/rubocop/cops/eval_spec.rb +39 -0
- data/spec/rubocop/cops/favor_join_spec.rb +35 -0
- data/spec/rubocop/cops/favor_modifier_spec.rb +16 -14
- data/spec/rubocop/cops/favor_percent_r_spec.rb +29 -0
- data/spec/rubocop/cops/favor_sprintf_spec.rb +51 -0
- data/spec/rubocop/cops/favor_unless_over_negated_if_spec.rb +4 -4
- data/spec/rubocop/cops/favor_until_over_negated_while_spec.rb +3 -3
- data/spec/rubocop/cops/handle_exceptions_spec.rb +34 -0
- data/spec/rubocop/cops/hash_syntax_spec.rb +11 -6
- data/spec/rubocop/cops/if_with_semicolon_spec.rb +7 -1
- data/spec/rubocop/cops/leading_comment_space_spec.rb +54 -0
- data/spec/rubocop/cops/line_continuation_spec.rb +24 -0
- data/spec/rubocop/cops/line_length_spec.rb +3 -2
- data/spec/rubocop/cops/loop_spec.rb +31 -0
- data/spec/rubocop/cops/method_and_variable_snake_case_spec.rb +55 -9
- data/spec/rubocop/cops/method_length_spec.rb +147 -0
- data/spec/rubocop/cops/multiline_if_then_spec.rb +15 -15
- data/spec/rubocop/cops/new_lambda_literal_spec.rb +5 -6
- data/spec/rubocop/cops/not_spec.rb +31 -0
- data/spec/rubocop/cops/numeric_literals_spec.rb +13 -13
- data/spec/rubocop/cops/offence_spec.rb +13 -0
- data/spec/rubocop/cops/one_line_conditional_spec.rb +1 -1
- data/spec/rubocop/cops/op_method_spec.rb +78 -0
- data/spec/rubocop/cops/parameter_lists_spec.rb +7 -7
- data/spec/rubocop/cops/parentheses_around_condition_spec.rb +41 -44
- data/spec/rubocop/cops/percent_r_spec.rb +29 -0
- data/spec/rubocop/cops/reduce_arguments_spec.rb +57 -0
- data/spec/rubocop/cops/rescue_exception_spec.rb +125 -0
- data/spec/rubocop/cops/rescue_modifier_spec.rb +37 -0
- data/spec/rubocop/cops/semicolon_spec.rb +88 -0
- data/spec/rubocop/cops/single_line_methods_spec.rb +50 -0
- data/spec/rubocop/cops/space_after_colon_spec.rb +3 -3
- data/spec/rubocop/cops/space_after_comma_spec.rb +14 -2
- data/spec/rubocop/cops/space_after_control_keyword_spec.rb +67 -0
- data/spec/rubocop/cops/space_after_semicolon_spec.rb +6 -1
- data/spec/rubocop/cops/space_around_braces_spec.rb +18 -3
- data/spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb +12 -2
- data/spec/rubocop/cops/space_around_operators_spec.rb +88 -26
- data/spec/rubocop/cops/space_inside_brackets_spec.rb +13 -7
- data/spec/rubocop/cops/space_inside_hash_literal_braces_spec.rb +79 -0
- data/spec/rubocop/cops/space_inside_parens_spec.rb +7 -3
- data/spec/rubocop/cops/string_literals_spec.rb +21 -6
- data/spec/rubocop/cops/symbol_array_spec.rb +41 -0
- data/spec/rubocop/cops/symbol_name_spec.rb +119 -0
- data/spec/rubocop/cops/syntax_spec.rb +28 -5
- data/spec/rubocop/cops/tab_spec.rb +2 -2
- data/spec/rubocop/cops/ternary_operator_spec.rb +13 -17
- data/spec/rubocop/cops/trailing_whitespace_spec.rb +3 -3
- data/spec/rubocop/cops/trivial_accessors_spec.rb +329 -0
- data/spec/rubocop/cops/unless_else_spec.rb +8 -8
- data/spec/rubocop/cops/variable_interpolation_spec.rb +49 -0
- data/spec/rubocop/cops/when_then_spec.rb +14 -14
- data/spec/rubocop/cops/word_array_spec.rb +47 -0
- data/spec/spec_helper.rb +30 -9
- data/spec/support/file_helper.rb +21 -0
- data/spec/support/isolated_environment.rb +27 -0
- metadata +235 -76
- data/.document +0 -5
- data/Gemfile.lock +0 -41
- data/VERSION +0 -1
- data/lib/rubocop/cop/ampersands_pipes_vs_and_or.rb +0 -25
- data/lib/rubocop/cop/grammar.rb +0 -135
- data/lib/rubocop/cop/indentation.rb +0 -44
- data/spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb +0 -57
- data/spec/rubocop/cops/grammar_spec.rb +0 -71
- data/spec/rubocop/cops/multiline_blocks_spec.rb +0 -24
- data/spec/rubocop/cops/single_line_blocks_spec.rb +0 -22
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c61251297391f7ee7286eb0e4482e975a42122f
|
4
|
+
data.tar.gz: 4375f2e36ceaa75510f7e4cdece56d3f1e22700f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9a6ed60555b7fbc888b9a68190c79bb525ece1e3623e1025fe833016e13b635b947b0cf49fab267ab4bf886bb0c8438bea130011a8c9dd8efa3e6e863b218b8f
|
7
|
+
data.tar.gz: 2f4161c9a52973931d695f900045b46b55e56d62debac661ab25308b031e383906cf33b107f8cf8f6701dba4c251cf9bac7ae49f32550aaca278bae7d556d688
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
Gemfile.lock
|
15
|
+
|
16
|
+
# jeweler generated
|
17
|
+
pkg
|
18
|
+
|
19
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
20
|
+
#
|
21
|
+
# * Create a file at ~/.gitignore
|
22
|
+
# * Include files you want ignored
|
23
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
24
|
+
#
|
25
|
+
# After doing this, these files will be ignored in all your git projects,
|
26
|
+
# saving you from having to 'pollute' every project you touch with them
|
27
|
+
#
|
28
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
29
|
+
#
|
30
|
+
# For MacOS:
|
31
|
+
#
|
32
|
+
#.DS_Store
|
33
|
+
|
34
|
+
# For TextMate
|
35
|
+
#*.tmproj
|
36
|
+
#tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
#*~
|
40
|
+
#\#*
|
41
|
+
#.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
#*.swp
|
45
|
+
|
46
|
+
# For redcar:
|
47
|
+
#.redcar
|
48
|
+
|
49
|
+
# For rubinius:
|
50
|
+
#*.rbc
|
data/.rubocop.yml
CHANGED
@@ -1,129 +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
|
-
Enabled: true
|
3
|
+
inherit_from: config/default.yml
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
Max:
|
10
|
-
|
11
|
-
Tab:
|
12
|
-
Enabled: true
|
13
|
-
|
14
|
-
TrailingWhitespace:
|
15
|
-
Enabled: true
|
16
|
-
|
17
|
-
Indentation:
|
18
|
-
Enabled: true
|
19
|
-
|
20
|
-
EmptyLines:
|
21
|
-
Enabled: true
|
22
|
-
|
23
|
-
SpaceAroundOperators:
|
24
|
-
Enabled: true
|
25
|
-
|
26
|
-
SpaceAroundBraces:
|
27
|
-
Enabled: true
|
28
|
-
|
29
|
-
SpaceInsideParens:
|
30
|
-
Enabled: true
|
31
|
-
|
32
|
-
SpaceInsideBrackets:
|
33
|
-
Enabled: true
|
34
|
-
|
35
|
-
SpaceAfterComma:
|
36
|
-
Enabled: true
|
37
|
-
|
38
|
-
SpaceAfterSemicolon:
|
39
|
-
Enabled: true
|
40
|
-
|
41
|
-
SpaceAfterColon:
|
42
|
-
Enabled: true
|
43
|
-
|
44
|
-
HashSyntax:
|
45
|
-
Enabled: true
|
46
|
-
|
47
|
-
EndOfLine:
|
48
|
-
Enabled: true
|
49
|
-
|
50
|
-
NumericLiterals:
|
51
|
-
Enabled: true
|
52
|
-
|
53
|
-
AlignParameters:
|
54
|
-
Enabled: true
|
55
|
-
|
56
|
-
DefWithParentheses:
|
57
|
-
Enabled: true
|
58
|
-
|
59
|
-
DefWithoutParentheses:
|
60
|
-
Enabled: true
|
61
|
-
|
62
|
-
IfWithSemicolon:
|
63
|
-
Enabled: true
|
64
|
-
|
65
|
-
MultilineIfThen:
|
66
|
-
Enabled: true
|
67
|
-
|
68
|
-
OneLineConditional:
|
69
|
-
Enabled: true
|
70
|
-
|
71
|
-
MultilineBlocks:
|
72
|
-
Enabled: true
|
73
|
-
|
74
|
-
SingleLineBlocks:
|
75
|
-
Enabled: true
|
76
|
-
|
77
|
-
ParameterLists:
|
78
|
-
Enabled: true
|
79
|
-
|
80
|
-
StringLiterals:
|
81
|
-
Enabled: true
|
82
|
-
|
83
|
-
MultilineTernaryOperator:
|
84
|
-
Enabled: true
|
85
|
-
|
86
|
-
NestedTernaryOperator:
|
87
|
-
Enabled: true
|
88
|
-
|
89
|
-
UnlessElse:
|
90
|
-
Enabled: true
|
91
|
-
|
92
|
-
AmpersandsPipesVsAndOr:
|
93
|
-
Enabled: true
|
94
|
-
|
95
|
-
WhenThen:
|
96
|
-
Enabled: true
|
97
|
-
|
98
|
-
IfUnlessModifier:
|
99
|
-
Enabled: true
|
100
|
-
|
101
|
-
WhileUntilModifier:
|
102
|
-
Enabled: true
|
103
|
-
|
104
|
-
FavorUnlessOverNegatedIf:
|
105
|
-
Enabled: true
|
106
|
-
|
107
|
-
FavorUntilOverNegatedWhile:
|
108
|
-
Enabled: true
|
109
|
-
|
110
|
-
SpaceAroundEqualsInParameterDefault:
|
111
|
-
Enabled: true
|
112
|
-
|
113
|
-
NewLambdaLiteral:
|
114
|
-
Enabled: true
|
115
|
-
|
116
|
-
ParenthesesAroundCondition:
|
117
|
-
Enabled: true
|
118
|
-
|
119
|
-
MethodAndVariableSnakeCase:
|
120
|
-
Enabled: true
|
121
|
-
|
122
|
-
ClassAndModuleCamelCase:
|
123
|
-
Enabled: true
|
124
|
-
|
125
|
-
Syntax:
|
126
|
-
Enabled: true
|
127
|
-
|
128
|
-
CollectionMethods:
|
129
|
-
Enabled: true
|
5
|
+
# Avoid methods longer than 30 lines of code
|
6
|
+
MethodLength:
|
7
|
+
Max: 30
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## master (unreleased)
|
4
|
+
|
5
|
+
### New features
|
6
|
+
|
7
|
+
### Changes
|
8
|
+
|
9
|
+
### Bugs fixed
|
10
|
+
|
11
|
+
## 0.8.0 (05/28/2012)
|
12
|
+
|
13
|
+
### Changes
|
14
|
+
|
15
|
+
* Folded `ArrayLiteral` and `HashLiteral` into `EmptyLiteral` cop
|
16
|
+
* The maximum number of params `ParameterLists` accepts in now configurable
|
17
|
+
* Reworked `SymbolSnakeCase` into `SymbolName`, which has an option `AllowCamelCase` enabled by default.
|
18
|
+
* Migrated from `Ripper` to the portable [Parser](https://github.com/whitequark/parser).
|
19
|
+
|
20
|
+
### New features
|
21
|
+
|
22
|
+
* New cop `ConstantName` checks for constant which are not using `SCREAMING_SNAKE_CASE`.
|
23
|
+
* New cop `AccessControl` checks private/protected indentation and surrounding blank lines.
|
24
|
+
* New cop `Loop` checks for `begin/end/while(until)` and suggests the use of `Kernel#loop`.
|
25
|
+
|
26
|
+
## 0.7.2 (05/13/2013)
|
27
|
+
|
28
|
+
### Bugs fixed
|
29
|
+
|
30
|
+
* [#155](https://github.com/bbatsov/rubocop/issues/155) 'Do not use semicolons to terminate expressions.' is not implemented correctly
|
31
|
+
* `OpMethod` now handles definition of unary operators without crashing.
|
32
|
+
* `SymbolSnakeCase` now handles aliasing of operators without crashing.
|
33
|
+
* `RescueException` now handles the splat operator `*` in a `rescue` clause without crashing.
|
34
|
+
* [#159](https://github.com/bbatsov/rubocop/issues/159) AvoidFor cop misses many violations
|
35
|
+
|
36
|
+
## 0.7.1 (05/11/2013)
|
37
|
+
|
38
|
+
### Bugs fixed
|
39
|
+
|
40
|
+
* Added missing files to the gemspec
|
41
|
+
|
42
|
+
## 0.7.0 (05/11/2013)
|
43
|
+
|
44
|
+
### New features
|
45
|
+
|
46
|
+
* Added ability to include or exclude files/directories through `.rubocop.yml`
|
47
|
+
* Added option --only for running a single cop.
|
48
|
+
* Relax semicolon rule for one line methods, classes and modules
|
49
|
+
* 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`.
|
50
|
+
* New cop `ClassMethods` checks for uses for class/module names in definitions of class/module methods
|
51
|
+
* New cop `SingleLineMethods` checks for methods implemented on a single line
|
52
|
+
* New cop `FavorJoin` checks for usages of `Array#*` with a string argument
|
53
|
+
* New cop `BlockComments` tracks uses of block comments(`=begin/=end` comments)
|
54
|
+
* New cop `EmptyLines` tracks consecutive blank lines
|
55
|
+
* New cop `WordArray` tracks arrays of words.
|
56
|
+
* [#108](https://github.com/bbatsov/rubocop/issues/108) New cop `SpaceInsideHashLiteralBraces` checks for spaces inside hash literal braces - style is configurable
|
57
|
+
* New cop `LineContinuation` tracks uses of the line continuation character (`\`)
|
58
|
+
* New cop `SymbolArray` tracks arrays of symbols.
|
59
|
+
* Print warnings for unrecognized names in configuration files.
|
60
|
+
* New cop `TrivialAccessors` tracks method definitions that could be automatically generated with `attr_*` methods.
|
61
|
+
* New cop `LeadingCommentSpace` checks for missing space after `#` in comments.
|
62
|
+
* New cop `ColonMethodCall` tracks uses of `::` for method calls.
|
63
|
+
* New cop `AvoidGlobalVars` tracks uses of non built-in global variables.
|
64
|
+
* New cop `SpaceAfterControlKeyword` tracks missing spaces after `if/elsif/case/when/until/unless/while`.
|
65
|
+
* New cop `Not` tracks uses of the `not` keyword.
|
66
|
+
* New cop `Eval` tracks uses of the `eval` function.
|
67
|
+
|
68
|
+
### Bugs fixed
|
69
|
+
|
70
|
+
* [#101](https://github.com/bbatsov/rubocop/issues/101) `SpaceAroundEqualsInParameterDefault` doesn't work properly with empty string
|
71
|
+
* Fix `BraceAfterPercent` for `%W`, `%i` and `%I` and added more tests
|
72
|
+
* Fix a false positive in the `Alias` cop. `:alias` is no longer treated as keyword
|
73
|
+
* `ArrayLiteral` now properly detects `Array.new`
|
74
|
+
* `HashLiteral` now properly detects `Hash.new`
|
75
|
+
* `VariableInterpolation` now detects regexp back references and doesn't crash.
|
76
|
+
* Don't generate pathnames like some/project//some.rb
|
77
|
+
* [#151](https://github.com/bbatsov/rubocop/issues/151) Don't print the unrecognized cop warning several times for the same `.rubocop.yml`
|
78
|
+
|
79
|
+
### Misc
|
80
|
+
|
81
|
+
* Renamed `Indentation` cop to `CaseIndentation` to avoid confusion
|
82
|
+
* Renamed `EmptyLines` cop to `EmptyLineBetweenDefs` to avoid confusion
|
83
|
+
|
84
|
+
## 0.6.1 (04/28/2013)
|
85
|
+
|
86
|
+
### New features
|
87
|
+
|
88
|
+
* Split `AsciiIdentifiersAndComments` cop in two separate cops
|
89
|
+
|
90
|
+
### Bugs fixed
|
91
|
+
|
92
|
+
* [#90](https://github.com/bbatsov/rubocop/issues/90) Two cops crash when scanning code using `super`
|
93
|
+
* [#93](https://github.com/bbatsov/rubocop/issues/93) Issue with `whitespace?': undefined method`
|
94
|
+
* [#97](https://github.com/bbatsov/rubocop/issues/97) Build fails
|
95
|
+
* [#100](https://github.com/bbatsov/rubocop/issues/100) `OpMethod` cop doesn't work if method arg is not in braces
|
96
|
+
* `SymbolSnakeCase` now tracks Ruby 1.9 hash labels as well as regular symbols
|
97
|
+
|
98
|
+
### Misc
|
99
|
+
|
100
|
+
* [#88](https://github.com/bbatsov/rubocop/issues/88) Abort gracefully when interrupted with Ctrl-C
|
101
|
+
* No longer crashes on bugs within cops. Now problematic checks are skipped and a message is displayed.
|
102
|
+
* Replaced `Term::ANSIColor` with `Rainbow`.
|
103
|
+
* Add an option to disable colors in the output.
|
104
|
+
* Cop names are now displayed alongside messages when `-d/--debug` is passed.
|
105
|
+
|
106
|
+
## 0.6.0 (04/23/2013)
|
107
|
+
|
108
|
+
### New features
|
109
|
+
|
110
|
+
* New cop `ReduceArguments` tracks argument names in reduce calls
|
111
|
+
* New cop `MethodLength` tracks number of LOC (lines of code) in methods
|
112
|
+
* New cop `RescueModifier` tracks uses of `rescue` in modifier form.
|
113
|
+
* New cop `PercentLiterals` tracks uses of `%q`, `%Q`, `%s` and `%x`.
|
114
|
+
* New cop `BraceAfterPercent` tracks uses of % literals with
|
115
|
+
delimiters other than ().
|
116
|
+
* Support for disabling cops locally in a file with rubocop:disable comments.
|
117
|
+
* New cop `EnsureReturn` tracks usages of `return` in `ensure` blocks.
|
118
|
+
* New cop `HandleExceptions` tracks suppressed exceptions.
|
119
|
+
* New cop `AsciiIdentifiersAndComments` tracks uses of non-ascii
|
120
|
+
characters in identifiers and comments.
|
121
|
+
* New cop `RescueException` tracks uses of rescuing the `Exception` class.
|
122
|
+
* New cop `ArrayLiteral` tracks uses of Array.new.
|
123
|
+
* New cop `HashLiteral` tracks uses of Hash.new.
|
124
|
+
* New cop `OpMethod` tracks the argument name in operator methods.
|
125
|
+
* New cop `PercentR` tracks uses of %r literals with zero or one slash in the regexp.
|
126
|
+
* New cop `FavorPercentR` tracks uses of // literals with more than one slash in the regexp.
|
127
|
+
|
128
|
+
### Bugs fixed
|
129
|
+
|
130
|
+
* [#62](https://github.com/bbatsov/rubocop/issues/62) - Config files in ancestor directories are ignored if another exists in home directory
|
131
|
+
* [#65](https://github.com/bbatsov/rubocop/issues/65) - Suggests to convert symbols `:==`, `:<=>` and the like to snake_case
|
132
|
+
* [#66](https://github.com/bbatsov/rubocop/issues/66) - Does not crash on unreadable or unparseable files
|
133
|
+
* [#70](https://github.com/bbatsov/rubocop/issues/70) - Support `alias` with bareword arguments
|
134
|
+
* [#64](https://github.com/bbatsov/rubocop/issues/64) - Performance issue with Bundler
|
135
|
+
* [#75](https://github.com/bbatsov/rubocop/issues/75) - Make it clear that some global variables require the use of the English library
|
136
|
+
* [#79](https://github.com/bbatsov/rubocop/issues/79) - Ternary operator missing whitespace detection
|
137
|
+
|
138
|
+
### Misc
|
139
|
+
|
140
|
+
* Dropped Jeweler for gem release management since it's no longer
|
141
|
+
actively maintained.
|
142
|
+
* Handle pluralization properly in the final summary.
|
143
|
+
|
144
|
+
## 0.5.0 (04/17/2013)
|
145
|
+
|
146
|
+
### New features
|
147
|
+
|
148
|
+
* New cop `FavorSprintf` that checks for usages of `String#%`
|
149
|
+
* New cop `Semicolon` that checks for usages of `;` as expression separator
|
150
|
+
* New cop `VariableInterpolation` that checks for variable interpolation in double quoted strings
|
151
|
+
* New cop `Alias` that checks for uses of the keyword `alias`
|
152
|
+
* Automatically detect extensionless Ruby files with shebangs when search for Ruby source files in a directory
|
153
|
+
|
154
|
+
### Bugs fixed
|
155
|
+
|
156
|
+
* [#59](https://github.com/bbatsov/rubocop/issues/59) - Interpolated variables not enclosed in braces are not noticed
|
157
|
+
* [#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
|
2
|
-
|
3
|
-
* Check out the latest master to make sure the feature hasn't been
|
4
|
-
|
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
|
9
|
-
|
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
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
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
|
|
7
|
+
> Role models are important. <br/>
|
8
|
+
> -- Officer Alex J. Murphy / RoboCop
|
9
|
+
|
6
10
|
**RuboCop** is a Ruby code style checker based on the
|
7
11
|
[Ruby Style Guide](https://github.com/bbatsov/ruby-style-guide).
|
8
12
|
|
@@ -23,7 +27,7 @@ in the current folder:
|
|
23
27
|
$ rubocop
|
24
28
|
```
|
25
29
|
|
26
|
-
Alternatively you can `rubocop` a list of files and folders to check:
|
30
|
+
Alternatively you can pass `rubocop` a list of files and folders to check:
|
27
31
|
|
28
32
|
```bash
|
29
33
|
$ rubocop app spec lib/something.rb
|
@@ -41,7 +45,8 @@ Command flag | Description
|
|
41
45
|
`-d/--debug` | Displays some extra debug output
|
42
46
|
`-e/--emacs` | Output the results in Emacs format
|
43
47
|
`-c/--config` | Run with specified config file
|
44
|
-
`-s
|
48
|
+
`-s/--silent` | Suppress the final summary
|
49
|
+
`--only` | Run only the specified cop
|
45
50
|
|
46
51
|
## Configuration
|
47
52
|
|
@@ -51,11 +56,13 @@ configuration file. The file can be placed either in your home folder
|
|
51
56
|
or in some project folder.
|
52
57
|
|
53
58
|
RuboCop will start looking for the configuration file in the directory
|
54
|
-
|
59
|
+
where the inspected file is and continue its way up to the root folder.
|
55
60
|
|
56
61
|
The file has the following format:
|
57
62
|
|
58
|
-
```
|
63
|
+
```yaml
|
64
|
+
inherit_from: ../.rubocop.yml
|
65
|
+
|
59
66
|
Encoding:
|
60
67
|
Enabled: true
|
61
68
|
|
@@ -67,14 +74,158 @@ LineLength:
|
|
67
74
|
It allows to enable/disable certain cops (checks) and to alter their
|
68
75
|
behavior if they accept any parameters.
|
69
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 directory,
|
101
|
+
`config/default.yml` will be used.
|
102
|
+
|
103
|
+
### Disabling Cops within Source Code
|
104
|
+
|
105
|
+
One or more individual cops can be disabled locally in a section of a
|
106
|
+
file by adding a comment such as
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
# rubocop:disable LineLength, StringLiterals
|
110
|
+
[...]
|
111
|
+
# rubocop:enable LineLength, StringLiterals
|
112
|
+
```
|
113
|
+
|
114
|
+
You can also disable *all* cops with
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
# rubocop:disable all
|
118
|
+
[...]
|
119
|
+
# rubocop:enable all
|
120
|
+
```
|
121
|
+
|
122
|
+
One or more cops can be disabled on a single line with an end-of-line
|
123
|
+
comment.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
for x in (0..19) # rubocop:disable AvoidFor
|
127
|
+
```
|
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
|
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
|
+
|
70
156
|
## Compatibility
|
71
157
|
|
72
|
-
|
73
|
-
|
74
|
-
|
158
|
+
RuboCop supported only MRI 1.9 & MRI 2.0 prior to version 0.8. After
|
159
|
+
RuboCop 0.8, JRuby and Rubinius in 1.9 modes are also supported.
|
160
|
+
|
161
|
+
## Editor integration
|
162
|
+
|
163
|
+
### Emacs
|
164
|
+
|
165
|
+
[rubocop.el](https://github.com/bbatsov/rubocop-emacs) is a simple
|
166
|
+
Emacs interface for RuboCop. It allows you to run RuboCop inside Emacs
|
167
|
+
and quickly jump between problems in your code.
|
168
|
+
|
169
|
+
[flycheck](https://github.com/lunaryorn/flycheck) > 0.9 also supports
|
170
|
+
RuboCop and uses it by default when available.
|
171
|
+
|
172
|
+
### Vim
|
173
|
+
|
174
|
+
The [vim-rubocop](https://github.com/ngmy/vim-rubocop) plugin runs
|
175
|
+
RuboCop and displays the results in Vim.
|
176
|
+
|
177
|
+
There's also a RuboCop checker in
|
178
|
+
[syntastic](https://github.com/scrooloose/syntastic).
|
179
|
+
|
180
|
+
### Sublime Text 2
|
181
|
+
|
182
|
+
If you're a ST2 user you might find the
|
183
|
+
[Sublime RuboCop plugin](https://github.com/pderichs/sublime_rubocop)
|
184
|
+
useful.
|
185
|
+
|
186
|
+
### Other Editors
|
187
|
+
|
188
|
+
Here's one great opportunity to contribute to RuboCop - implement
|
189
|
+
RuboCop integration for your favorite editor.
|
190
|
+
|
191
|
+
## Guard integration
|
192
|
+
|
193
|
+
If you're fond of [Guard](https://github.com/guard/guard) you might
|
194
|
+
like
|
195
|
+
[guard-rubocop](https://github.com/yujinakayama/guard-rubocop). It
|
196
|
+
allows you to automatically check Ruby code style with RuboCop when
|
197
|
+
files are modified.
|
198
|
+
|
199
|
+
## Contributors
|
200
|
+
|
201
|
+
Here's a [list](https://github.com/bbatsov/rubocop/contributors) of
|
202
|
+
all the people who have contributed to the development of RuboCop.
|
203
|
+
|
204
|
+
I'm extremely grateful to each and every one of them!
|
205
|
+
|
206
|
+
I'd like to single out [Jonas Arvidsson](https://github.com/jonas054)
|
207
|
+
for his many excellent code contributions as well as valuable feedback
|
208
|
+
and ideas!
|
209
|
+
|
210
|
+
If you'd like to contribute to RuboCop, please take the time to go
|
211
|
+
through our short
|
212
|
+
[contribution guidelines](CONTRIBUTING.md).
|
213
|
+
|
214
|
+
Converting more of the Ruby Style Guide into RuboCop cops is our top
|
215
|
+
priority right now. Writing a new cop is a great way to dive into RuboCop!
|
216
|
+
|
217
|
+
Of course, bug reports and suggestions for improvements are always
|
218
|
+
welcome. GitHub pull requests are even better! :-)
|
219
|
+
|
220
|
+
## Mailing List
|
221
|
+
|
222
|
+
If you're interested in everything regarding RuboCop's development,
|
223
|
+
consider joining its
|
224
|
+
[Google Group](https://groups.google.com/forum/?fromgroups#!forum/rubocop).
|
225
|
+
|
226
|
+
## Changelog
|
75
227
|
|
76
|
-
RuboCop
|
77
|
-
Rubinius is not planned at this point.
|
228
|
+
RuboCop's changelog is available [here](CHANGELOG.md).
|
78
229
|
|
79
230
|
## Copyright
|
80
231
|
|
data/Rakefile
CHANGED
@@ -2,29 +2,15 @@
|
|
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
|
8
9
|
$stderr.puts e.message
|
9
|
-
$stderr.puts
|
10
|
+
$stderr.puts 'Run `bundle install` to install missing gems'
|
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|
|
@@ -37,7 +23,7 @@ task :coverage do
|
|
37
23
|
Rake::Task['spec'].execute
|
38
24
|
end
|
39
25
|
|
40
|
-
task :
|
26
|
+
task default: :spec
|
41
27
|
|
42
28
|
require 'yard'
|
43
29
|
YARD::Rake::YardocTask.new
|
data/bin/rubocop
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
|
-
|
4
|
+
if RUBY_VERSION >= '1.9.2'
|
5
|
+
$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
4
6
|
|
5
|
-
require 'rubocop'
|
6
|
-
require 'benchmark'
|
7
|
+
require 'rubocop'
|
8
|
+
require 'benchmark'
|
7
9
|
|
8
|
-
cli = Rubocop::CLI.new
|
9
|
-
result = 0
|
10
|
+
cli = Rubocop::CLI.new
|
11
|
+
result = 0
|
10
12
|
|
11
|
-
time = Benchmark.realtime do
|
12
|
-
|
13
|
-
end
|
13
|
+
time = Benchmark.realtime do
|
14
|
+
result = cli.run
|
15
|
+
end
|
14
16
|
|
15
|
-
puts "Finished in #{time} seconds" if
|
16
|
-
exit result
|
17
|
+
puts "Finished in #{time} seconds" if cli.options[:debug]
|
18
|
+
exit result
|
19
|
+
else
|
20
|
+
puts 'RuboCop supports only Ruby 1.9.2+'
|
21
|
+
exit(-1)
|
22
|
+
end
|