rubocop 0.11.1 → 0.12.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.

Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +32 -1
  3. data/README.md +28 -3
  4. data/config/default.yml +14 -12
  5. data/config/disabled.yml +1 -1
  6. data/config/enabled.yml +190 -118
  7. data/lib/rubocop.rb +9 -1
  8. data/lib/rubocop/cli.rb +49 -13
  9. data/lib/rubocop/config.rb +5 -5
  10. data/lib/rubocop/cop/cop.rb +34 -1
  11. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +47 -0
  12. data/lib/rubocop/cop/lint/rescue_exception.rb +1 -4
  13. data/lib/rubocop/cop/lint/useless_assignment.rb +39 -11
  14. data/lib/rubocop/cop/lint/useless_comparison.rb +2 -4
  15. data/lib/rubocop/cop/rails/has_and_belongs_to_many.rb +20 -0
  16. data/lib/rubocop/cop/rails/read_attribute.rb +28 -0
  17. data/lib/rubocop/cop/style/access_control.rb +12 -1
  18. data/lib/rubocop/cop/style/attr.rb +7 -0
  19. data/lib/rubocop/cop/style/collection_methods.rb +13 -1
  20. data/lib/rubocop/cop/style/constant_name.rb +1 -1
  21. data/lib/rubocop/cop/style/def_parentheses.rb +18 -0
  22. data/lib/rubocop/cop/style/documentation.rb +1 -1
  23. data/lib/rubocop/cop/style/empty_literal.rb +14 -0
  24. data/lib/rubocop/cop/style/even_odd.rb +56 -0
  25. data/lib/rubocop/cop/style/favor_modifier.rb +2 -2
  26. data/lib/rubocop/cop/style/hash_methods.rb +40 -0
  27. data/lib/rubocop/cop/style/indentation_width.rb +148 -0
  28. data/lib/rubocop/cop/style/method_and_variable_snake_case.rb +40 -25
  29. data/lib/rubocop/cop/style/method_call_parentheses.rb +8 -0
  30. data/lib/rubocop/cop/style/multiline_if_then.rb +1 -1
  31. data/lib/rubocop/cop/style/nil_comparison.rb +38 -0
  32. data/lib/rubocop/cop/style/signal_exception.rb +11 -0
  33. data/lib/rubocop/cop/style/space_after_method_name.rb +34 -0
  34. data/lib/rubocop/cop/util.rb +17 -0
  35. data/lib/rubocop/formatter/emacs_style_formatter.rb +2 -2
  36. data/lib/rubocop/formatter/file_list_formatter.rb +3 -2
  37. data/lib/rubocop/formatter/formatter_set.rb +3 -11
  38. data/lib/rubocop/formatter/offence_count_formatter.rb +50 -0
  39. data/lib/rubocop/formatter/progress_formatter.rb +0 -2
  40. data/lib/rubocop/formatter/simple_text_formatter.rb +1 -6
  41. data/lib/rubocop/version.rb +1 -1
  42. data/spec/project_spec.rb +7 -0
  43. data/spec/rubocop/cli_spec.rb +119 -57
  44. data/spec/rubocop/config_spec.rb +23 -17
  45. data/spec/rubocop/cop/commissioner_spec.rb +8 -8
  46. data/spec/rubocop/cop/cop_spec.rb +80 -0
  47. data/spec/rubocop/cop/lint/parentheses_as_grouped_expression_spec.rb +63 -0
  48. data/spec/rubocop/cop/lint/useless_assignment_spec.rb +59 -0
  49. data/spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb +19 -0
  50. data/spec/rubocop/cop/rails/read_attribute_spec.rb +19 -0
  51. data/spec/rubocop/cop/rails/validation_spec.rb +5 -5
  52. data/spec/rubocop/cop/style/access_control_spec.rb +28 -0
  53. data/spec/rubocop/cop/style/attr_spec.rb +6 -1
  54. data/spec/rubocop/cop/style/collection_methods_spec.rb +5 -0
  55. data/spec/rubocop/cop/style/constant_name_spec.rb +9 -0
  56. data/spec/rubocop/cop/style/def_with_parentheses_spec.rb +14 -9
  57. data/spec/rubocop/cop/style/def_without_parentheses_spec.rb +12 -7
  58. data/spec/rubocop/cop/style/empty_literal_spec.rb +42 -27
  59. data/spec/rubocop/cop/style/even_odd_spec.rb +47 -0
  60. data/spec/rubocop/cop/style/favor_modifier_spec.rb +15 -14
  61. data/spec/rubocop/cop/style/hash_methods_spec.rb +51 -0
  62. data/spec/rubocop/cop/style/indentation_width_spec.rb +390 -0
  63. data/spec/rubocop/cop/style/method_and_variable_snake_case_spec.rb +58 -50
  64. data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +6 -1
  65. data/spec/rubocop/cop/style/nil_comparison_spec.rb +31 -0
  66. data/spec/rubocop/cop/style/signal_exception_spec.rb +28 -0
  67. data/spec/rubocop/cop/style/space_after_method_name_spec.rb +61 -0
  68. data/spec/rubocop/formatter/emacs_style_formatter_spec.rb +9 -2
  69. data/spec/rubocop/formatter/file_list_formatter_spec.rb +3 -3
  70. data/spec/rubocop/formatter/offence_count_formatter_spec.rb +52 -0
  71. data/spec/rubocop/formatter/progress_formatter_spec.rb +70 -84
  72. data/spec/rubocop/source_parser_spec.rb +1 -1
  73. metadata +29 -5
  74. data/lib/rubocop/cop/style/line_continuation.rb +0 -27
  75. data/spec/rubocop/cop/style/line_continuation_spec.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2faac5537f8a90a10686b48873e68045e6b47df8
4
- data.tar.gz: d2bcd8de09aa159aa8bcf1f342194a81cd8d1f06
3
+ metadata.gz: 3ab0d432e91c72639b48734e66c1e4ce045ea0d8
4
+ data.tar.gz: cd33ef19aa06a05bb32a2f882ec8ea128a0d8e8a
5
5
  SHA512:
6
- metadata.gz: b65464231491f7a7fe59bded76486c3a36aa58bae76dd7625fc68cbd1564a96474e16371acc8c6623b13d587bcaab2a80f0f70f2bfefed736c7941d260249e58
7
- data.tar.gz: c9e362bb95915fc8e7a23cb5322059620b79f57a5c73b17a5a56de600d141139b16f77e72d461d22f9dead5fd5077c8076014ff01ed344894f6d9a1d13631c60
6
+ metadata.gz: 56e469c18ad41f08a3b33c0e13d8632cdf6d92c1281bd7012077beb759bceefe8429da0f1f670accf44dfc08841ec366807cf0d3d50ce1827b1a5689a6333a77
7
+ data.tar.gz: 773e23dbd3e938afe4ee156c6c0c7afd3b8589c1a8e896b24b119086865200d3c4dcc87cdc9453b0f0a6eb5076f3aaa5e6b89a5da3794de67bea258b138dc6c9
data/CHANGELOG.md CHANGED
@@ -2,11 +2,41 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.12.0 (23/08/2013)
6
+
5
7
  ### New features
6
8
 
9
+ * [#439](https://github.com/bbatsov/rubocop/issues/439) Added formatter 'OffenceCount' which outputs a summary list of cops and their offence count
10
+ * [#395](https://github.com/bbatsov/rubocop/issues/395) Added `--show-cops` option to show available cops.
11
+ * New cop `NilComparison` keeps track of comparisons like `== nil`
12
+ * New cop `EvenOdd` keeps track of occasions where `Fixnum#even?` or `Fixnum#odd?` should have been used (like `x % 2 == 0`)
13
+ * New cop `IndentationWidth` checks for files using indentation that is not two spaces.
14
+ * New cop `SpaceAfterMethodName` keeps track of method definitions with a space between the method name and the opening parenthesis.
15
+ * New cop `ParenthesesAsGroupedExpression` keeps track of method calls with a space before the opening parenthesis.
16
+ * New cop `HashMethods` keeps track of uses of deprecated `Hash` methods.
17
+ * New Rails cop `HasAndBelongsToMany` checks for uses of `has_and_belongs_to_many`.
18
+ * New Rails cop `ReadAttribute` tracks uses of `read_attribute`.
19
+ * `Attr` cop does auto-correction
20
+ * `CollectionMethods` cop does auto-correction
21
+ * `SignalException` cop does auto-correction
22
+ * `EmptyLiteral` cop does auto-correction
23
+ * `MethodCallParentheses` cop does auto-correction
24
+ * `DefWithParentheses` cop does auto-correction
25
+ * `DefWithoutParentheses` cop does auto-correction
26
+
27
+ ### Changes
28
+
29
+ * Dropped `-s`/`--silent` option. Now `progress`/`simple`/`clang` formatters always report summary and `emacs`/`files` formatters no longer report.
30
+ * Dropped the `LineContinuation` cop
31
+
7
32
  ### Bugs fixed
8
33
 
9
- ### 0.11.1 (12/08/2013)
34
+ * [#432](https://github.com/bbatsov/rubocop/issues/432) - Fix false positive for constant assignments when rhs is a method call with block in `ConstantName`
35
+ * [#434](https://github.com/bbatsov/rubocop/issues/434) - Support classes and modules defined with `Class.new`/`Module.new` in `AccessControl`
36
+ * Fix which ranges are highlighted in reports from IfUnlessModifier, WhileUntilModifier, and MethodAndVariableSnakeCase cop.
37
+ * [#438](https://github.com/bbatsov/rubocop/issues/438) - Accept setting attribute on method argument in `UselessAssignment`
38
+
39
+ ## 0.11.1 (12/08/2013)
10
40
 
11
41
  ### Changes
12
42
 
@@ -151,6 +181,7 @@
151
181
  * New cop `EndBlock` tracks uses of `END` blocks.
152
182
  * New cop `DotPosition` tracks the dot position in multi-line method calls.
153
183
  * New cop `Attr` tracks uses of `Module#attr`.
184
+ * Add support for auto-correction of some offences with `-a`/`--auto-correct`.
154
185
 
155
186
  ### Changes
156
187
 
data/README.md CHANGED
@@ -48,12 +48,12 @@ Running RuboCop on it (assuming it's in a file named `test.rb`) would produce th
48
48
  ```
49
49
  Offences:
50
50
 
51
- test.rb:1:1: C: Use snake_case for methods and variables.
51
+ test.rb:1:5: C: Use snake_case for methods and variables.
52
52
  def badName
53
- ^^^
53
+ ^^^^^^^
54
54
  test.rb:2:3: C: Favor modifier if/unless usage when you have a single-line body. Another good alternative is the usage of control flow &&/||.
55
55
  if something
56
- ^^^^^
56
+ ^^
57
57
  test.rb:4:5: W: end at 4, 4 is not aligned with if at 2, 2
58
58
  end
59
59
  ^^^
@@ -82,6 +82,7 @@ Command flag | Description
82
82
  `-s/--silent` | Suppress the final summary
83
83
  `--only` | Run only the specified cop
84
84
  `--auto-gen-config` | Generate a configuration file acting as a TODO list
85
+ `--show-cops` | Shows available cops and their configuration
85
86
 
86
87
  ## Configuration
87
88
 
@@ -314,6 +315,30 @@ The JSON structure is like the following example:
314
315
  }
315
316
  ```
316
317
 
318
+ ### OffenceCount Formatter
319
+
320
+ Sometimes when first applying RuboCop to a codebase, it's nice to be able to
321
+ see where most of your style cleanup is going to be spent.
322
+
323
+ With this in mind, you can use the offence count formatter to outline the offended
324
+ cops and the number of offences found for each by running:
325
+
326
+ ```
327
+ rubocop --format offences
328
+
329
+ (87) Documentation
330
+ (12) DotPosition
331
+ (8) AvoidGlobalVars
332
+ (7) EmptyLines
333
+ (6) AssignmentInCondition
334
+ (4) Blocks
335
+ (4) CommentAnnotation
336
+ (3) BlockAlignment
337
+ (1) IndentationWidth
338
+ (1) AvoidPerlBackrefs
339
+ (1) ColonMethodCall
340
+ ```
341
+
317
342
  ### Custom Formatters
318
343
 
319
344
  You can customize RuboCop's output format with custom formatter.
data/config/default.yml CHANGED
@@ -13,54 +13,56 @@ AllCops:
13
13
  - '**/Rakefile'
14
14
  Excludes: []
15
15
 
16
- # Limit lines to 79 characters.
17
16
  LineLength:
17
+ Description: 'Limit lines to 79 characters.'
18
18
  Max: 79
19
19
 
20
- # Avoid methods longer than 10 lines of code
21
20
  MethodLength:
21
+ Description: 'Avoid methods longer than 10 lines of code.'
22
22
  CountComments: false # count full line comments?
23
23
  Max: 10
24
24
 
25
- # Avoid parameter lists longer than five parameters.
26
25
  ParameterLists:
26
+ Description: 'Avoid parameter lists longer than five parameters.'
27
27
  Max: 5
28
28
  CountKeywordArgs: true
29
29
 
30
- # Don't use semicolons to terminate expressions.
31
30
  Semicolon:
31
+ Description: "Don't use semicolons to terminate expressions."
32
32
  # For example; def area(height, width); height * width end
33
33
  AllowAfterParameterListInOneLineMethods: false
34
34
  # For example; def area(height, width) height * width; end
35
35
  AllowBeforeEndInOneLineMethods: true
36
36
 
37
- # Avoid single-line methods.
38
37
  SingleLineMethods:
38
+ Description: 'Avoid single-line methods.'
39
39
  AllowIfMethodIsEmpty: true
40
40
 
41
- # Use spaces inside hash literal braces - or don't.
42
41
  SpaceInsideHashLiteralBraces:
42
+ Description: "Use spaces inside hash literal braces - or don't."
43
43
  EnforcedStyleIsWithSpaces: true
44
44
 
45
- # Symbol literals should use snake_case.
46
45
  SymbolName:
46
+ Description: 'Symbol literals should use snake_case.'
47
47
  AllowCamelCase: true
48
48
 
49
- # Avoid more than `Max` levels of nesting.
50
49
  BlockNesting:
50
+ Description: 'Avoid more than `Max` levels of nesting.'
51
51
  Max: 3
52
52
 
53
- # Use %r for regular expressions matching more than `MaxSlashes` '/'
54
- # characters.
55
- # Use %r only for regular expressions matching more than `MaxSlashes` '/'
56
- # character.
57
53
  RegexpLiteral:
54
+ Description: >
55
+ Use %r for regular expressions matching more than
56
+ `MaxSlashes` '/' characters.
57
+ Use %r only for regular expressions matching more than
58
+ `MaxSlashes` '/' character.
58
59
  MaxSlashes: 1
59
60
 
60
61
  # Align with the style guide.
61
62
  CollectionMethods:
62
63
  PreferredMethods:
63
64
  collect: 'map'
65
+ collect!: 'map!'
64
66
  inject: 'reduce'
65
67
  detect: 'find'
66
68
  find_all: 'select'
data/config/disabled.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  # These are all the cops that are disabled in the default configuration.
2
2
 
3
- # Use %i or %I for arrays of symbols.
4
3
  SymbolArray:
4
+ Description: 'Use %i or %I for arrays of symbols.'
5
5
  Enabled: false
data/config/enabled.yml CHANGED
@@ -1,444 +1,516 @@
1
1
  # These are all the cops that are enabled in the default configuration.
2
2
 
3
- # Use UTF-8 as the source file encoding.
4
3
  Encoding:
4
+ Description: 'Use UTF-8 as the source file encoding.'
5
5
  Enabled: true
6
6
 
7
- # Limit lines to 79 characters.
8
7
  LineLength:
8
+ Description: 'Limit lines to 79 characters.'
9
9
  Enabled: true
10
10
 
11
- # Avoid methods longer than 10 lines of code
12
11
  MethodLength:
12
+ Description: 'Avoid methods longer than 10 lines of code.'
13
13
  Enabled: true
14
14
 
15
- # No hard tabs.
16
15
  Tab:
16
+ Description: 'No hard tabs.'
17
17
  Enabled: true
18
18
 
19
- # Avoid trailing whitespace.
20
19
  TrailingWhitespace:
20
+ Description: 'Avoid trailing whitespace.'
21
21
  Enabled: true
22
22
 
23
- # Indent when as deep as case.
24
23
  CaseIndentation:
24
+ Description: 'Indent when as deep as case.'
25
25
  Enabled: true
26
26
 
27
- # Use empty lines between defs.
28
27
  EmptyLineBetweenDefs:
28
+ Description: 'Use empty lines between defs.'
29
29
  Enabled: true
30
30
 
31
- # Don't use several empty lines in a row.
32
31
  EmptyLines:
32
+ Description: "Don't use several empty lines in a row."
33
33
  Enabled: true
34
34
 
35
- # Use spaces around operators.
36
35
  SpaceAroundOperators:
36
+ Description: 'Use spaces around operators.'
37
37
  Enabled: true
38
38
 
39
- # Use spaces around { and before }.
40
39
  SpaceAroundBraces:
40
+ Description: 'Use spaces around { and before }.'
41
41
  Enabled: true
42
42
 
43
- # No spaces after ( or before ).
44
43
  SpaceInsideParens:
44
+ Description: 'No spaces after ( or before ).'
45
45
  Enabled: true
46
46
 
47
- # No spaces after [ or before ].
48
47
  SpaceInsideBrackets:
48
+ Description: 'No spaces after [ or before ].'
49
49
  Enabled: true
50
50
 
51
- # Use spaces after commas.
52
51
  SpaceAfterComma:
52
+ Description: 'Use spaces after commas.'
53
53
  Enabled: true
54
54
 
55
- # Use spaces after semicolons.
56
55
  SpaceAfterSemicolon:
56
+ Description: 'Use spaces after semicolons.'
57
57
  Enabled: true
58
58
 
59
- # Use spaces after colons.
60
59
  SpaceAfterColon:
60
+ Description: 'Use spaces after colons.'
61
61
  Enabled: true
62
62
 
63
- # Use spaces after if/elsif/unless/while/until/case/when.
64
63
  SpaceAfterControlKeyword:
64
+ Description: 'Use spaces after if/elsif/unless/while/until/case/when.'
65
65
  Enabled: true
66
66
 
67
- # Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
68
- # { :a => 1, :b => 2 }.
69
67
  HashSyntax:
68
+ Description: >
69
+ Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax
70
+ { :a => 1, :b => 2 }.
70
71
  Enabled: true
71
72
 
72
- # Use Unix-style line endings.
73
73
  EndOfLine:
74
+ Description: 'Use Unix-style line endings.'
74
75
  Enabled: true
75
76
 
76
- # Add underscores to large numeric literals to improve their readability.
77
77
  NumericLiterals:
78
+ Description: >
79
+ Add underscores to large numeric literals to improve their
80
+ readability.
78
81
  Enabled: true
79
82
 
80
- # Align the parameters of a method call if they span more than one line.
81
83
  AlignParameters:
84
+ Description: >
85
+ Align the parameters of a method call if they span more
86
+ than one line.
82
87
  Enabled: true
83
88
 
84
- # Use def with parentheses when there are arguments.
85
89
  DefWithParentheses:
90
+ Description: 'Use def with parentheses when there are arguments.'
86
91
  Enabled: true
87
92
 
88
- # Omit the parentheses when the method doesn't accept any arguments.
89
93
  DefWithoutParentheses:
94
+ Description: >
95
+ Omit the parentheses when the method doesn't accept
96
+ any arguments.
90
97
  Enabled: true
91
98
 
92
- # Never use if x; .... Use the ternary operator instead.
93
99
  IfWithSemicolon:
100
+ Description: 'Never use if x; .... Use the ternary operator instead.'
94
101
  Enabled: true
95
102
 
96
- # Never use then for multi-line if/unless.
97
103
  MultilineIfThen:
104
+ Description: 'Never use then for multi-line if/unless.'
98
105
  Enabled: true
99
106
 
100
- # Favor the ternary operator(?:) over if/then/else/end constructs.
101
107
  OneLineConditional:
108
+ Description: >
109
+ Favor the ternary operator(?:) over
110
+ if/then/else/end constructs.
102
111
  Enabled: true
103
112
 
104
- # Avoid using {...} for multi-line blocks (multiline chaining is always ugly).
105
- # Prefer {...} over do...end for single-line blocks.
106
113
  Blocks:
114
+ Description: >
115
+ Avoid using {...} for multi-line blocks (multiline chaining is
116
+ always ugly).
117
+ Prefer {...} over do...end for single-line blocks.
107
118
  Enabled: true
108
119
 
109
- # Avoid parameter lists longer than three or four parameters.
120
+
110
121
  ParameterLists:
122
+ Description: Avoid parameter lists longer than three or four parameters.
111
123
  Enabled: true
112
124
 
113
- # Prefer ' strings when you don't need string interpolation or special symbols.
114
125
  StringLiterals:
126
+ Description: >
127
+ Prefer ' strings when you don't need string interpolation or
128
+ special symbols.
115
129
  Enabled: true
116
130
 
117
- # Avoid multi-line ?: (the ternary operator); use if/unless instead.
131
+
118
132
  MultilineTernaryOperator:
133
+ Description: >
134
+ Avoid multi-line ?: (the ternary operator);
135
+ use if/unless instead.
119
136
  Enabled: true
120
137
 
121
- # Use one expression per branch in a ternary operator.
122
138
  NestedTernaryOperator:
139
+ Description: 'Use one expression per branch in a ternary operator.'
123
140
  Enabled: true
124
141
 
125
- # Never use unless with else. Rewrite these with the positive case first.
126
142
  UnlessElse:
143
+ Description: >
144
+ Never use unless with else. Rewrite these with the positive
145
+ case first.
127
146
  Enabled: true
128
147
 
129
- # Use &&/|| instead of and/or.
130
148
  AndOr:
149
+ Description: 'Use &&/|| instead of and/or.'
131
150
  Enabled: true
132
151
 
133
- # Use when x then ... for one-line cases.
134
152
  WhenThen:
153
+ Description: 'Use when x then ... for one-line cases.'
135
154
  Enabled: true
136
155
 
137
- # Favor modifier if/unless usage when you have a single-line body.
138
156
  IfUnlessModifier:
157
+ Description: >
158
+ Favor modifier if/unless usage when you have a
159
+ single-line body.
139
160
  Enabled: true
140
161
 
141
- # Favor modifier while/until usage when you have a single-line body.
142
162
  WhileUntilModifier:
163
+ Description: >
164
+ Favor modifier while/until usage when you have a
165
+ single-line body.
143
166
  Enabled: true
144
167
 
145
- # Favor unless over if for negative conditions (or control flow or).
168
+
146
169
  FavorUnlessOverNegatedIf:
170
+ Description: >
171
+ Favor unless over if for negative conditions
172
+ (or control flow or).
147
173
  Enabled: true
148
174
 
149
- # Favor until over while for negative conditions.
150
175
  FavorUntilOverNegatedWhile:
176
+ Description: 'Favor until over while for negative conditions.'
151
177
  Enabled: true
152
178
 
153
- # Use spaces around the = operator when assigning default values in def params.
154
179
  SpaceAroundEqualsInParameterDefault:
180
+ Description: >
181
+ Use spaces around the = operator when assigning default
182
+ values in def params.
155
183
  Enabled: true
156
184
 
157
- # Use the new lambda literal syntax for single-line blocks.
158
185
  Lambda:
186
+ Description: 'Use the new lambda literal syntax for single-line blocks.'
159
187
  Enabled: true
160
188
 
161
- # Use proc instead of Proc.new.
162
189
  Proc:
190
+ Description: 'Use proc instead of Proc.new.'
163
191
  Enabled: true
164
192
 
165
- # Don't use parentheses around the condition of an if/unless/while.
166
193
  ParenthesesAroundCondition:
194
+ Description: >
195
+ Don't use parentheses around the condition of an
196
+ if/unless/while.
167
197
  Enabled: true
168
198
 
169
- # Use snake_case for symbols, methods and variables.
170
199
  MethodAndVariableSnakeCase:
200
+ Description: 'Use snake_case for symbols, methods and variables.'
171
201
  Enabled: true
172
202
 
173
- # Use CamelCase for classes and modules.
174
203
  ClassAndModuleCamelCase:
204
+ Description: 'Use CamelCase for classes and modules.'
175
205
  Enabled: true
176
206
 
177
- # Preferred collection methods.
178
207
  CollectionMethods:
208
+ Description: 'Preferred collection methods.'
179
209
  Enabled: true
180
210
 
181
- # Prefer each over for.
182
211
  AvoidFor:
212
+ Description: 'Prefer each over for.'
183
213
  Enabled: true
184
214
 
185
- # Avoid Perl-style global variables.
186
215
  AvoidPerlisms:
216
+ Description: 'Avoid Perl-style global variables.'
187
217
  Enabled: true
188
218
 
189
- # Avoid Perl-style regex back references.
190
219
  AvoidPerlBackrefs:
220
+ Description: 'Avoid Perl-style regex back references.'
191
221
  Enabled: true
192
222
 
193
- # Avoid the use of class variables.
194
223
  AvoidClassVars:
224
+ Description: 'Avoid the use of class variables.'
195
225
  Enabled: true
196
226
 
197
- # Don't interpolate global, instance and class variables directly in strings.
198
227
  VariableInterpolation:
228
+ Description: >
229
+ Don't interpolate global, instance and class variables
230
+ directly in strings.
199
231
  Enabled: true
200
232
 
201
- # Don't use semicolons to terminate expressions.
202
233
  Semicolon:
234
+ Desription: "Don't use semicolons to terminate expressions."
203
235
  Enabled: true
204
236
 
205
- # Use sprintf instead of String#%.
206
237
  FavorSprintf:
238
+ Description: 'Use sprintf instead of String#%.'
207
239
  Enabled: true
208
240
 
209
- # Use Array#join instead of Array#*.
210
241
  FavorJoin:
242
+ Description: 'Use Array#join instead of Array#*.'
211
243
  Enabled: true
212
244
 
213
- # Use alias_method instead of alias.
214
245
  Alias:
246
+ Description: 'Use alias_method instead of alias.'
215
247
  Enabled: true
216
248
 
217
- # Use ! instead of not.
218
249
  Not:
250
+ Description: 'Use ! instead of not.'
219
251
  Enabled: true
220
252
 
221
- # Avoid using rescue in its modifier form.
222
253
  RescueModifier:
254
+ Description: 'Avoid using rescue in its modifier form.'
223
255
  Enabled: true
224
256
 
225
- # Never use return in an ensure block.
226
257
  EnsureReturn:
258
+ Description: 'Never use return in an ensure block.'
227
259
  Enabled: true
228
260
 
229
- # Don't suppress exception.
230
261
  HandleExceptions:
262
+ Description: "Don't suppress exception."
231
263
  Enabled: true
232
264
 
233
- # Use only ascii symbols in identifiers.
234
265
  AsciiIdentifiers:
266
+ Description: 'Use only ascii symbols in identifiers.'
235
267
  Enabled: true
236
268
 
237
- # Use only ascii symbols in comments.
238
269
  AsciiComments:
270
+ Description: 'Use only ascii symbols in comments.'
239
271
  Enabled: true
240
272
 
241
- # Do not use block comments.
242
273
  BlockComments:
274
+ Description: 'Do not use block comments.'
243
275
  Enabled: true
244
276
 
245
- # Avoid rescuing the Exception class.
246
277
  RescueException:
278
+ Description: 'Avoid rescuing the Exception class.'
247
279
  Enabled: true
248
280
 
249
- # Prefer literals to Array.new/Hash.new/String.new.
250
281
  EmptyLiteral:
282
+ Description: 'Prefer literals to Array.new/Hash.new/String.new.'
251
283
  Enabled: true
252
284
 
253
- # When defining binary operators, name the argument other.
254
285
  OpMethod:
286
+ Description: 'When defining binary operators, name the argument other.'
255
287
  Enabled: true
256
288
 
257
- # Name reduce arguments |a, e| (accumulator, element)
258
289
  ReduceArguments:
290
+ Description: 'Name reduce arguments |a, e| (accumulator, element)'
259
291
  Enabled: true
260
292
 
261
- # Use %r for regular expressions matching more than `MaxSlashes` '/'
262
- # characters.
263
- # Use %r only for regular expressions matching more than `MaxSlashes` '/'
264
- # character.
265
293
  RegexpLiteral:
294
+ Description: >
295
+ Use %r for regular expressions matching more than
296
+ `MaxSlashes` '/' characters.
297
+ Use %r only for regular expressions matching more than
298
+ `MaxSlashes` '/' character.
266
299
  Enabled: true
267
300
 
268
- # Use self when defining module/class methods.
269
301
  ClassMethods:
302
+ Description: 'Use self when defining module/class methods.'
270
303
  Enabled: true
271
304
 
272
- # Avoid single-line methods.
273
305
  SingleLineMethods:
306
+ Description: 'Avoid single-line methods.'
274
307
  Enabled: true
275
308
 
276
- # Use %w or %W for arrays of words.
277
309
  WordArray:
310
+ Description: 'Use %w or %W for arrays of words.'
278
311
  Enabled: true
279
312
 
280
- # Use spaces inside hash literal braces - or don't.
281
313
  SpaceInsideHashLiteralBraces:
314
+ Description: "Use spaces inside hash literal braces - or don't."
282
315
  Enabled: true
283
316
 
284
- # Avoid the use of line continuation (/).
285
- LineContinuation:
286
- Enabled: true
287
-
288
- # Prefer attr_* methods to trivial readers/writers.
289
317
  TrivialAccessors:
318
+ Description: 'Prefer attr_* methods to trivial readers/writers.'
290
319
  Enabled: true
291
320
 
292
- # Comments should start with a space.
293
321
  LeadingCommentSpace:
322
+ Description: 'Comments should start with a space.'
294
323
  Enabled: true
295
324
 
296
- # Do not use :: for method call.
297
325
  ColonMethodCall:
326
+ Description: 'Do not use :: for method call.'
298
327
  Enabled: true
299
328
 
300
- # Do not introduce global variables.
301
329
  AvoidGlobalVars:
330
+ Description: 'Do not introduce global variables.'
302
331
  Enabled: true
303
332
 
304
- # The use of eval represents a serious security risk.
305
333
  Eval:
334
+ Description: 'The use of eval represents a serious security risk.'
306
335
  Enabled: true
307
336
 
308
- # Symbol literals should use snake_case.
309
337
  SymbolName:
338
+ Description: 'Symbol literals should use snake_case.'
310
339
  Enabled: true
311
340
 
312
- # Constants should use SCREAMING_SNAKE_CASE.
313
341
  ConstantName:
342
+ Description: 'Constants should use SCREAMING_SNAKE_CASE.'
314
343
  Enabled: true
315
344
 
316
- # Indent private/protected as deep as defs and keep blank lines around them.
317
345
  AccessControl:
346
+ Description: >
347
+ Indent private/protected as deep as defs and keep blank
348
+ lines around them.
318
349
  Enabled: true
319
350
 
320
- # Use Kernel#loop with break rather than begin/end/until or begin/end/while for
321
- # post-loop tests.
322
351
  Loop:
352
+ Description: >
353
+ Use Kernel#loop with break rather than begin/end/until or
354
+ begin/end/while for post-loop tests.
323
355
  Enabled: true
324
356
 
325
- # Avoid excessive block nesting
326
357
  BlockNesting:
358
+ Description: 'Avoid excessive block nesting'
327
359
  Enabled: true
328
360
 
329
- # Avoid explicit use of the case equality operator(===).
330
361
  CaseEquality:
362
+ Description: 'Avoid explicit use of the case equality operator(===).'
331
363
  Enabled: true
332
364
 
333
- # Document classes and non-namespace modules.
334
365
  Documentation:
366
+ Description: 'Document classes and non-namespace modules.'
335
367
  Enabled: true
336
368
 
337
- # Do not use parentheses for method calls with no arguments.
338
369
  MethodCallParentheses:
370
+ Description: 'Do not use parentheses for method calls with no arguments.'
339
371
  Enabled: true
340
372
 
341
- # Checks for redundant do after while or until.
342
373
  WhileUntilDo:
374
+ Description: 'Checks for redundant do after while or until.'
343
375
  Enabled: true
344
376
 
345
- # Checks for uses of character literals.
346
377
  CharacterLiteral:
378
+ Description: 'Checks for uses of character literals.'
347
379
  Enabled: true
348
380
 
349
- # Avoid the use of BEGIN blocks.
350
381
  BeginBlock:
382
+ Description: 'Avoid the use of BEGIN blocks.'
351
383
  Enabled: true
352
384
 
353
- # Avoid the use of END blocks.
354
385
  EndBlock:
386
+ Description: 'Avoid the use of END blocks.'
355
387
  Enabled: true
356
388
 
357
- # Don't use return where it's not required.
358
389
  RedundantReturn:
390
+ Description: "Don't use return where it's not required."
359
391
  Enabled: true
360
392
 
361
- # Don't use begin blocks when they are not needed.
362
393
  RedundantBegin:
394
+ Description: "Don't use begin blocks when they are not needed."
363
395
  Enabled: true
364
396
 
365
- # Don't use self where it's not needed.
366
397
  RedundantSelf:
398
+ Description: "Don't use self where it's not needed."
367
399
  Enabled: true
368
400
 
369
- # Checks the position of the dot in multi-line method calls.
370
401
  DotPosition:
402
+ Description: 'Checks the position of the dot in multi-line method calls.'
371
403
  Enabled: true
372
404
 
373
- # Checks for uses of Module#attr.
374
405
  Attr:
406
+ Description: 'Checks for uses of Module#attr.'
375
407
  Enabled: true
376
408
 
377
- # Checks for proper usage of fail and raise.
378
409
  SignalException:
410
+ Description: 'Checks for proper usage of fail and raise.'
379
411
  Enabled: true
380
412
 
381
- # Checks for usage of `extend self` in modules.
382
413
  ModuleFunction:
414
+ Description: 'Checks for usage of `extend self` in modules.'
415
+ Enabled: true
416
+
417
+ NilComparison:
418
+ Description: 'Prefer x.nil? to x == nil.'
419
+ Enabled: true
420
+
421
+ IndentationWidth:
422
+ Description: 'Use 2 spaces for indentation.'
423
+ Enabled: true
424
+
425
+ EvenOdd:
426
+ Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
427
+ Enabled: true
428
+
429
+ SpaceAfterMethodName:
430
+ Description: >
431
+ Never put a space between a method name and the opening
432
+ parenthesis.
433
+ Enabled: true
434
+
435
+ HashMethods:
436
+ Description: Checks for use of deprecated Hash methods.
383
437
  Enabled: true
384
438
 
385
439
  #################### Lint ################################
440
+ ### Warnings
386
441
 
387
- # Don't use assignment in conditions.
388
442
  AssignmentInCondition:
443
+ Description: "Don't use assignment in conditions."
389
444
  Enabled: true
390
445
 
391
- # Align ends correctly.
392
446
  EndAlignment:
447
+ Description: 'Align ends correctly.'
393
448
  Enabled: true
394
449
 
395
- # Align block ends correctly.
396
450
  BlockAlignment:
451
+ Description: 'Align block ends correctly.'
397
452
  Enabled: true
398
453
 
399
- # Possible use of operator/literal/variable in void context.
400
454
  Void:
455
+ Description: 'Possible use of operator/literal/variable in void context.'
401
456
  Enabled: true
402
457
 
403
- # Unreachable code.
404
458
  UnreachableCode:
459
+ Description: 'Unreachable code.'
405
460
  Enabled: true
406
461
 
407
- # Unused local variable.
408
462
  UnusedLocalVariable:
463
+ Description: 'Unused local variable.'
409
464
  Enabled: true
410
465
 
411
- # Do not use the same name as outer local variable
412
- # for block arguments or block local variables.
413
466
  ShadowingOuterLocalVariable:
467
+ Description: >
468
+ Do not use the same name as outer local variable
469
+ for block arguments or block local variables.
414
470
  Enabled: true
415
471
 
416
- # END blocks should not be placed inside method definitions.
417
472
  EndInMethod:
473
+ Description: 'END blocks should not be placed inside method definitions.'
418
474
  Enabled: true
419
475
 
420
- # Checks of literals used in conditions.
421
476
  LiteralInCondition:
477
+ Description: 'Checks of literals used in conditions.'
422
478
  Enabled: true
423
479
 
424
- # Checks for empty ensure block.
425
480
  EmptyEnsure:
481
+ Description: 'Checks for empty ensure block.'
426
482
  Enabled: true
427
483
 
428
- # Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
429
484
  CommentAnnotation:
485
+ Description: >
486
+ Checks formatting of special comments
487
+ (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
430
488
  Enabled: true
431
489
 
432
- # Checks for useless assignment to a local variable.
433
490
  UselessAssignment:
491
+ Description: 'Checks for useless assignment to a local variable.'
434
492
  Enabled: true
435
493
 
436
- # Checks for comparison of something with itself.
437
494
  UselessComparison:
495
+ Description: 'Checks for comparison of something with itself.'
496
+ Enabled: true
497
+
498
+ ParenthesesAsGroupedExpression:
499
+ Description: >
500
+ Checks for method calls with a space before the opening
501
+ parenthesis.
438
502
  Enabled: true
439
503
 
440
504
  ##################### Rails ##################################
441
505
 
442
- # Use sexy validations.
506
+ HasAndBelongsToMany:
507
+ Description: Prefer has_many :through to has_and_belongs_to_many.
508
+ Enabled: true
509
+
510
+ ReadAttribute:
511
+ Description: Prefer self[:attribute] over read_attribute(:attribute).
512
+ Enabled: true
513
+
443
514
  Validation:
515
+ Description: 'Use sexy validations.'
444
516
  Enabled: true