rubocop 0.14.1 → 0.15.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 (109) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -3
  3. data/CHANGELOG.md +245 -198
  4. data/README.md +7 -0
  5. data/Rakefile +5 -1
  6. data/config/default.yml +27 -4
  7. data/config/enabled.yml +18 -4
  8. data/lib/rubocop.rb +13 -1
  9. data/lib/rubocop/cli.rb +83 -23
  10. data/lib/rubocop/config.rb +1 -1
  11. data/lib/rubocop/cop/cop.rb +31 -6
  12. data/lib/rubocop/cop/lint/block_alignment.rb +11 -8
  13. data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +21 -14
  14. data/lib/rubocop/cop/lint/useless_setter_call.rb +1 -1
  15. data/lib/rubocop/cop/rails/output.rb +35 -0
  16. data/lib/rubocop/cop/style/{access_control.rb → access_modifier_indentation.rb} +18 -15
  17. data/lib/rubocop/cop/style/alias.rb +14 -2
  18. data/lib/rubocop/cop/style/align_hash.rb +174 -109
  19. data/lib/rubocop/cop/style/autocorrect_alignment.rb +38 -18
  20. data/lib/rubocop/cop/style/blocks.rb +4 -6
  21. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +3 -3
  22. data/lib/rubocop/cop/style/cyclomatic_complexity.rb +46 -0
  23. data/lib/rubocop/cop/style/empty_lines_around_access_modifier.rb +48 -0
  24. data/lib/rubocop/cop/style/empty_lines_around_body.rb +62 -0
  25. data/lib/rubocop/cop/style/end_of_line.rb +6 -2
  26. data/lib/rubocop/cop/style/favor_modifier.rb +11 -1
  27. data/lib/rubocop/cop/style/final_newline.rb +10 -4
  28. data/lib/rubocop/cop/style/hash_syntax.rb +32 -21
  29. data/lib/rubocop/cop/style/leading_comment_space.rb +9 -0
  30. data/lib/rubocop/cop/style/method_call_parentheses.rb +11 -1
  31. data/lib/rubocop/cop/style/numeric_literals.rb +11 -15
  32. data/lib/rubocop/cop/style/redundant_return.rb +7 -4
  33. data/lib/rubocop/cop/style/redundant_self.rb +3 -3
  34. data/lib/rubocop/cop/style/signal_exception.rb +4 -2
  35. data/lib/rubocop/cop/style/space_after_comma_etc.rb +7 -1
  36. data/lib/rubocop/cop/style/space_after_control_keyword.rb +6 -0
  37. data/lib/rubocop/cop/style/space_after_method_name.rb +7 -1
  38. data/lib/rubocop/cop/style/space_after_not.rb +6 -2
  39. data/lib/rubocop/cop/style/space_around_block_braces.rb +149 -0
  40. data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +33 -0
  41. data/lib/rubocop/cop/style/space_around_operators.rb +169 -0
  42. data/lib/rubocop/cop/style/space_before_modifier_keyword.rb +6 -0
  43. data/lib/rubocop/cop/style/space_inside.rb +35 -0
  44. data/lib/rubocop/cop/style/space_inside_brackets.rb +18 -0
  45. data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +99 -0
  46. data/lib/rubocop/cop/style/space_inside_parens.rb +18 -0
  47. data/lib/rubocop/cop/style/special_global_vars.rb +52 -25
  48. data/lib/rubocop/cop/style/string_literals.rb +1 -1
  49. data/lib/rubocop/cop/style/surrounding_space.rb +1 -344
  50. data/lib/rubocop/cop/style/trailing_blank_lines.rb +17 -5
  51. data/lib/rubocop/cop/style/trailing_whitespace.rb +9 -5
  52. data/lib/rubocop/cop/style/trivial_accessors.rb +1 -2
  53. data/lib/rubocop/cop/style/word_array.rb +16 -1
  54. data/lib/rubocop/cop/team.rb +5 -5
  55. data/lib/rubocop/cop/util.rb +1 -0
  56. data/lib/rubocop/formatter/offence_count_formatter.rb +0 -1
  57. data/lib/rubocop/options.rb +76 -111
  58. data/lib/rubocop/rake_task.rb +4 -2
  59. data/lib/rubocop/target_finder.rb +3 -3
  60. data/lib/rubocop/version.rb +1 -1
  61. data/spec/rubocop/cli_spec.rb +123 -13
  62. data/spec/rubocop/config_spec.rb +2 -2
  63. data/spec/rubocop/cop/lint/rescue_exception_spec.rb +10 -0
  64. data/spec/rubocop/cop/lint/useless_setter_call_spec.rb +13 -0
  65. data/spec/rubocop/cop/offence_spec.rb +2 -0
  66. data/spec/rubocop/cop/rails/output_spec.rb +40 -0
  67. data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +243 -0
  68. data/spec/rubocop/cop/style/alias_spec.rb +8 -0
  69. data/spec/rubocop/cop/style/align_array_spec.rb +12 -0
  70. data/spec/rubocop/cop/style/align_hash_spec.rb +15 -0
  71. data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +7 -4
  72. data/spec/rubocop/cop/style/cyclomatic_complexity_spec.rb +203 -0
  73. data/spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb +56 -0
  74. data/spec/rubocop/cop/style/empty_lines_around_body_spec.rb +87 -0
  75. data/spec/rubocop/cop/style/end_of_line_spec.rb +17 -8
  76. data/spec/rubocop/cop/style/favor_modifier_spec.rb +34 -0
  77. data/spec/rubocop/cop/style/final_newline_spec.rb +5 -0
  78. data/spec/rubocop/cop/style/hash_syntax_spec.rb +22 -2
  79. data/spec/rubocop/cop/style/leading_comment_space_spec.rb +5 -0
  80. data/spec/rubocop/cop/style/method_call_parentheses_spec.rb +39 -4
  81. data/spec/rubocop/cop/style/numeric_literals_spec.rb +5 -0
  82. data/spec/rubocop/cop/style/signal_exception_spec.rb +11 -0
  83. data/spec/rubocop/cop/style/space_after_colon_spec.rb +7 -0
  84. data/spec/rubocop/cop/style/space_after_comma_spec.rb +5 -0
  85. data/spec/rubocop/cop/style/space_after_control_keyword_spec.rb +29 -8
  86. data/spec/rubocop/cop/style/space_after_method_name_spec.rb +15 -0
  87. data/spec/rubocop/cop/style/space_after_semicolon_spec.rb +5 -0
  88. data/spec/rubocop/cop/style/space_around_block_braces_spec.rb +68 -0
  89. data/spec/rubocop/cop/style/space_around_equals_in_default_parameter_spec.rb +5 -0
  90. data/spec/rubocop/cop/style/space_around_operators_spec.rb +43 -0
  91. data/spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb +23 -0
  92. data/spec/rubocop/cop/style/space_inside_brackets_spec.rb +7 -0
  93. data/spec/rubocop/cop/style/space_inside_hash_literal_braces_spec.rb +65 -23
  94. data/spec/rubocop/cop/style/space_inside_parens_spec.rb +7 -0
  95. data/spec/rubocop/cop/style/special_global_vars_spec.rb +12 -2
  96. data/spec/rubocop/cop/style/string_literals_spec.rb +6 -0
  97. data/spec/rubocop/cop/style/symbol_array_spec.rb +5 -7
  98. data/spec/rubocop/cop/style/trailing_blank_lines_spec.rb +26 -1
  99. data/spec/rubocop/cop/style/trailing_whitespace_spec.rb +7 -0
  100. data/spec/rubocop/cop/style/trivial_accessors_spec.rb +8 -0
  101. data/spec/rubocop/cop/style/word_array_spec.rb +33 -2
  102. data/spec/rubocop/cop/team_spec.rb +4 -4
  103. data/spec/rubocop/formatter/json_formatter_spec.rb +1 -1
  104. data/spec/rubocop/options_spec.rb +5 -96
  105. data/spec/rubocop/processed_source_spec.rb +3 -3
  106. data/spec/spec_helper.rb +28 -23
  107. data/spec/support/mri_syntax_checker.rb +20 -16
  108. metadata +24 -5
  109. data/spec/rubocop/cop/style/access_control_spec.rb +0 -164
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-10 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -178,9 +178,10 @@ files:
178
178
  - lib/rubocop/cop/lint/void.rb
179
179
  - lib/rubocop/cop/offence.rb
180
180
  - lib/rubocop/cop/rails/has_and_belongs_to_many.rb
181
+ - lib/rubocop/cop/rails/output.rb
181
182
  - lib/rubocop/cop/rails/read_attribute.rb
182
183
  - lib/rubocop/cop/rails/validation.rb
183
- - lib/rubocop/cop/style/access_control.rb
184
+ - lib/rubocop/cop/style/access_modifier_indentation.rb
184
185
  - lib/rubocop/cop/style/alias.rb
185
186
  - lib/rubocop/cop/style/align_array.rb
186
187
  - lib/rubocop/cop/style/align_hash.rb
@@ -207,11 +208,14 @@ files:
207
208
  - lib/rubocop/cop/style/comment_annotation.rb
208
209
  - lib/rubocop/cop/style/configurable_naming.rb
209
210
  - lib/rubocop/cop/style/constant_name.rb
211
+ - lib/rubocop/cop/style/cyclomatic_complexity.rb
210
212
  - lib/rubocop/cop/style/def_parentheses.rb
211
213
  - lib/rubocop/cop/style/documentation.rb
212
214
  - lib/rubocop/cop/style/dot_position.rb
213
215
  - lib/rubocop/cop/style/empty_line_between_defs.rb
214
216
  - lib/rubocop/cop/style/empty_lines.rb
217
+ - lib/rubocop/cop/style/empty_lines_around_access_modifier.rb
218
+ - lib/rubocop/cop/style/empty_lines_around_body.rb
215
219
  - lib/rubocop/cop/style/empty_literal.rb
216
220
  - lib/rubocop/cop/style/encoding.rb
217
221
  - lib/rubocop/cop/style/end_block.rb
@@ -264,7 +268,14 @@ files:
264
268
  - lib/rubocop/cop/style/space_after_control_keyword.rb
265
269
  - lib/rubocop/cop/style/space_after_method_name.rb
266
270
  - lib/rubocop/cop/style/space_after_not.rb
271
+ - lib/rubocop/cop/style/space_around_block_braces.rb
272
+ - lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb
273
+ - lib/rubocop/cop/style/space_around_operators.rb
267
274
  - lib/rubocop/cop/style/space_before_modifier_keyword.rb
275
+ - lib/rubocop/cop/style/space_inside.rb
276
+ - lib/rubocop/cop/style/space_inside_brackets.rb
277
+ - lib/rubocop/cop/style/space_inside_hash_literal_braces.rb
278
+ - lib/rubocop/cop/style/space_inside_parens.rb
268
279
  - lib/rubocop/cop/style/special_global_vars.rb
269
280
  - lib/rubocop/cop/style/string_help.rb
270
281
  - lib/rubocop/cop/style/string_literals.rb
@@ -340,9 +351,10 @@ files:
340
351
  - spec/rubocop/cop/lint/void_spec.rb
341
352
  - spec/rubocop/cop/offence_spec.rb
342
353
  - spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
354
+ - spec/rubocop/cop/rails/output_spec.rb
343
355
  - spec/rubocop/cop/rails/read_attribute_spec.rb
344
356
  - spec/rubocop/cop/rails/validation_spec.rb
345
- - spec/rubocop/cop/style/access_control_spec.rb
357
+ - spec/rubocop/cop/style/access_modifier_indentation_spec.rb
346
358
  - spec/rubocop/cop/style/alias_spec.rb
347
359
  - spec/rubocop/cop/style/align_array_spec.rb
348
360
  - spec/rubocop/cop/style/align_hash_spec.rb
@@ -367,11 +379,14 @@ files:
367
379
  - spec/rubocop/cop/style/colon_method_call_spec.rb
368
380
  - spec/rubocop/cop/style/comment_annotation_spec.rb
369
381
  - spec/rubocop/cop/style/constant_name_spec.rb
382
+ - spec/rubocop/cop/style/cyclomatic_complexity_spec.rb
370
383
  - spec/rubocop/cop/style/def_with_parentheses_spec.rb
371
384
  - spec/rubocop/cop/style/def_without_parentheses_spec.rb
372
385
  - spec/rubocop/cop/style/documentation_spec.rb
373
386
  - spec/rubocop/cop/style/dot_position_spec.rb
374
387
  - spec/rubocop/cop/style/empty_line_between_defs_spec.rb
388
+ - spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb
389
+ - spec/rubocop/cop/style/empty_lines_around_body_spec.rb
375
390
  - spec/rubocop/cop/style/empty_lines_spec.rb
376
391
  - spec/rubocop/cop/style/empty_literal_spec.rb
377
392
  - spec/rubocop/cop/style/encoding_spec.rb
@@ -535,9 +550,10 @@ test_files:
535
550
  - spec/rubocop/cop/lint/void_spec.rb
536
551
  - spec/rubocop/cop/offence_spec.rb
537
552
  - spec/rubocop/cop/rails/has_and_belongs_to_many_spec.rb
553
+ - spec/rubocop/cop/rails/output_spec.rb
538
554
  - spec/rubocop/cop/rails/read_attribute_spec.rb
539
555
  - spec/rubocop/cop/rails/validation_spec.rb
540
- - spec/rubocop/cop/style/access_control_spec.rb
556
+ - spec/rubocop/cop/style/access_modifier_indentation_spec.rb
541
557
  - spec/rubocop/cop/style/alias_spec.rb
542
558
  - spec/rubocop/cop/style/align_array_spec.rb
543
559
  - spec/rubocop/cop/style/align_hash_spec.rb
@@ -562,11 +578,14 @@ test_files:
562
578
  - spec/rubocop/cop/style/colon_method_call_spec.rb
563
579
  - spec/rubocop/cop/style/comment_annotation_spec.rb
564
580
  - spec/rubocop/cop/style/constant_name_spec.rb
581
+ - spec/rubocop/cop/style/cyclomatic_complexity_spec.rb
565
582
  - spec/rubocop/cop/style/def_with_parentheses_spec.rb
566
583
  - spec/rubocop/cop/style/def_without_parentheses_spec.rb
567
584
  - spec/rubocop/cop/style/documentation_spec.rb
568
585
  - spec/rubocop/cop/style/dot_position_spec.rb
569
586
  - spec/rubocop/cop/style/empty_line_between_defs_spec.rb
587
+ - spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb
588
+ - spec/rubocop/cop/style/empty_lines_around_body_spec.rb
570
589
  - spec/rubocop/cop/style/empty_lines_spec.rb
571
590
  - spec/rubocop/cop/style/empty_literal_spec.rb
572
591
  - spec/rubocop/cop/style/encoding_spec.rb
@@ -1,164 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Rubocop::Cop::Style::AccessControl do
6
- subject(:cop) { described_class.new }
7
-
8
- it 'registers an offence for misaligned private' do
9
- inspect_source(cop,
10
- ['class Test',
11
- '',
12
- 'private',
13
- '',
14
- ' def test; end',
15
- 'end'])
16
- expect(cop.offences.size).to eq(1)
17
- expect(cop.messages)
18
- .to eq(['Indent private as deep as method definitions.'])
19
- end
20
-
21
- it 'registers an offence for misaligned private in module' do
22
- inspect_source(cop,
23
- ['module Test',
24
- '',
25
- 'private',
26
- '',
27
- ' def test; end',
28
- 'end'])
29
- expect(cop.offences.size).to eq(1)
30
- expect(cop.messages)
31
- .to eq(['Indent private as deep as method definitions.'])
32
- end
33
-
34
- it 'registers an offence for misaligned private in singleton class' do
35
- inspect_source(cop,
36
- ['class << self',
37
- '',
38
- 'private',
39
- '',
40
- ' def test; end',
41
- 'end'])
42
- expect(cop.offences.size).to eq(1)
43
- expect(cop.messages)
44
- .to eq(['Indent private as deep as method definitions.'])
45
- end
46
-
47
- it 'registers an offence for misaligned private in class ' +
48
- 'defined with Class.new' do
49
- inspect_source(cop,
50
- ['Test = Class.new do',
51
- '',
52
- 'private',
53
- '',
54
- ' def test; end',
55
- 'end'])
56
- expect(cop.offences.size).to eq(1)
57
- expect(cop.messages)
58
- .to eq(['Indent private as deep as method definitions.'])
59
- end
60
-
61
- it 'registers an offence for misaligned private in module ' +
62
- 'defined with Module.new' do
63
- inspect_source(cop,
64
- ['Test = Module.new do',
65
- '',
66
- 'private',
67
- '',
68
- ' def test; end',
69
- 'end'])
70
- expect(cop.offences.size).to eq(1)
71
- expect(cop.messages)
72
- .to eq(['Indent private as deep as method definitions.'])
73
- end
74
-
75
- it 'registers an offence for misaligned protected' do
76
- inspect_source(cop,
77
- ['class Test',
78
- '',
79
- 'protected',
80
- '',
81
- ' def test; end',
82
- 'end'])
83
- expect(cop.offences.size).to eq(1)
84
- expect(cop.messages)
85
- .to eq(['Indent protected as deep as method definitions.'])
86
- end
87
-
88
- it 'accepts properly indented private' do
89
- inspect_source(cop,
90
- ['class Test',
91
- '',
92
- ' private',
93
- '',
94
- ' def test; end',
95
- 'end'])
96
- expect(cop.offences).to be_empty
97
- end
98
-
99
- it 'accepts properly indented protected' do
100
- inspect_source(cop,
101
- ['class Test',
102
- '',
103
- ' protected',
104
- '',
105
- ' def test; end',
106
- 'end'])
107
- expect(cop.offences).to be_empty
108
- end
109
-
110
- it 'handles properly nested classes' do
111
- inspect_source(cop,
112
- ['class Test',
113
- '',
114
- ' class Nested',
115
- '',
116
- ' private',
117
- '',
118
- ' def a; end',
119
- ' end',
120
- '',
121
- ' protected',
122
- '',
123
- ' def test; end',
124
- 'end'])
125
- expect(cop.offences.size).to eq(1)
126
- expect(cop.messages)
127
- .to eq(['Indent private as deep as method definitions.'])
128
- end
129
-
130
- it 'requires blank line before private/protected' do
131
- inspect_source(cop,
132
- ['class Test',
133
- ' protected',
134
- '',
135
- ' def test; end',
136
- 'end'])
137
- expect(cop.offences.size).to eq(1)
138
- expect(cop.messages)
139
- .to eq(['Keep a blank line before and after protected.'])
140
- end
141
-
142
- it 'requires blank line after private/protected' do
143
- inspect_source(cop,
144
- ['class Test',
145
- '',
146
- ' protected',
147
- ' def test; end',
148
- 'end'])
149
- expect(cop.offences.size).to eq(1)
150
- expect(cop.messages)
151
- .to eq(['Keep a blank line before and after protected.'])
152
- end
153
-
154
- it 'recognizes blank lines with DOS style line endings' do
155
- inspect_source(cop,
156
- ["class Test\r",
157
- "\r",
158
- " protected\r",
159
- "\r",
160
- " def test; end\r",
161
- "end\r"])
162
- expect(cop.offences.size).to eq(0)
163
- end
164
- end