rubocop 0.3.1 → 0.3.2

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.

@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module Rubocop
6
+ module Cop
7
+ describe NewLambdaLiteral do
8
+ let (:lambda_literal) { NewLambdaLiteral.new }
9
+
10
+ it 'registers an offence for an old lambda call' do
11
+ inspect_source(lambda_literal, 'file.rb', ['f = lambda { |x| x }'])
12
+ lambda_literal.offences.map(&:message).should ==
13
+ ['The new lambda literal syntax is preferred in Ruby 1.9.']
14
+ end
15
+
16
+ it 'accepts the new lambda literal' do
17
+ inspect_source(lambda_literal, 'file.rb', ['lambda = ->(x) { x }',
18
+ 'lambda.(1)'])
19
+ lambda_literal.offences.map(&:message).should == []
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module Rubocop
6
+ module Cop
7
+ describe ParenthesesAroundCondition do
8
+ let (:pac) { ParenthesesAroundCondition.new }
9
+
10
+ it 'registers an offence for parentheses around condition' do
11
+ inspect_source(pac, 'file.rb', ['if (x > 10)',
12
+ 'elsif (x < 3)',
13
+ 'end',
14
+ 'unless (x > 10)',
15
+ 'end',
16
+ 'while (x > 10)',
17
+ 'end',
18
+ 'until (x > 10)',
19
+ 'end',
20
+ 'x += 1 if (x < 10)',
21
+ 'x += 1 unless (x < 10)',
22
+ 'x += 1 while (x < 10)',
23
+ 'x += 1 until (x < 10)',
24
+ ])
25
+ pac.offences.map(&:message).should ==
26
+ ["Don't use parentheses around the condition of an if/unless/" +
27
+ 'while/until, unless the condition contains an assignment.'] * 9
28
+ end
29
+
30
+ it 'accepts condition without parentheses' do
31
+ inspect_source(pac, 'file.rb', ['if x > 10',
32
+ 'end',
33
+ 'unless x > 10',
34
+ 'end',
35
+ 'while x > 10',
36
+ 'end',
37
+ 'until x > 10',
38
+ 'end',
39
+ 'x += 1 if x < 10',
40
+ 'x += 1 unless x < 10',
41
+ 'x += 1 while x < 10',
42
+ 'x += 1 until x < 10',
43
+ ])
44
+ pac.offences.map(&:message).should == []
45
+ end
46
+
47
+ # Parentheses are sometimes used to help the editor make nice
48
+ # indentation of conditions spanning several lines.
49
+ it 'accepts parentheses around multiline conditions' do
50
+ inspect_source(pac, 'file.rb', ['if (@lex_state != EXPR_BEG &&',
51
+ ' @lex_state != EXPR_FNAME &&',
52
+ ' trans[1])',
53
+ 'end'])
54
+ pac.offences.map(&:message).should == []
55
+ end
56
+
57
+ it 'accepts parentheses around assignment' do
58
+ inspect_source(pac, 'file.rb', ['if (x = self.next_value)',
59
+ 'end'])
60
+ pac.offences.map(&:message).should == []
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ module Rubocop
6
+ module Cop
7
+ describe SpaceAroundEqualsInParameterDefault do
8
+ let (:space) { SpaceAroundEqualsInParameterDefault.new }
9
+
10
+ it 'registers an offence for default value assignment without space' do
11
+ inspect_source(space, 'file.rb', ['def f(x, y=0, z=1)', 'end'])
12
+ space.offences.map(&:message).should ==
13
+ ['Surrounding space missing in default value assignment.'] * 2
14
+ end
15
+
16
+ it 'accepts default value assignment with space' do
17
+ inspect_source(space, 'file.rb', ['def f(x, y = 0, z = 1)', 'end'])
18
+ space.offences.map(&:message).should == []
19
+ end
20
+ end
21
+ end
22
+ end
@@ -13,6 +13,31 @@ module Rubocop
13
13
  ["Surrounding space missing for operator '='."] * 3
14
14
  end
15
15
 
16
+ it 'registers an offence in presence of modifier if statement' do
17
+ check_modifier('if')
18
+ end
19
+
20
+ it 'registers an offence in presence of modifier unless statement' do
21
+ check_modifier('unless')
22
+ end
23
+
24
+ it 'registers an offence in presence of modifier while statement' do
25
+ check_modifier('unless')
26
+ end
27
+
28
+ it 'registers an offence in presence of modifier until statement' do
29
+ check_modifier('unless')
30
+ end
31
+
32
+ def check_modifier(keyword)
33
+ src = ["a=1 #{keyword} condition",
34
+ 'c=2']
35
+ inspect_source(space, 'file.rb', src)
36
+ space.offences.map(&:line_number).should == [1, 2]
37
+ space.offences.map(&:message).should ==
38
+ ["Surrounding space missing for operator '='."] * 2
39
+ end
40
+
16
41
  it 'registers an offence for binary operators that could be unary' do
17
42
  inspect_source(space, 'file.rb', ['a-3', 'x&0xff', 'z+0'])
18
43
  space.offences.map(&:message).should ==
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,88 +9,104 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-28 00:00:00.000000000 Z
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: term-ansicolor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  requirement: !ruby/object:Gem::Requirement
17
33
  none: false
18
34
  requirements:
19
- - - ~>
35
+ - - ! '>='
20
36
  - !ruby/object:Gem::Version
21
- version: 10.0.0
37
+ version: '0'
22
38
  type: :development
23
39
  prerelease: false
24
40
  version_requirements: !ruby/object:Gem::Requirement
25
41
  none: false
26
42
  requirements:
27
- - - ~>
43
+ - - ! '>='
28
44
  - !ruby/object:Gem::Version
29
- version: 10.0.0
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: rspec
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
35
- - - ~>
51
+ - - ! '>='
36
52
  - !ruby/object:Gem::Version
37
- version: 2.12.0
53
+ version: '0'
38
54
  type: :development
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
- - - ~>
59
+ - - ! '>='
44
60
  - !ruby/object:Gem::Version
45
- version: 2.12.0
61
+ version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: yard
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
51
- - - ~>
67
+ - - ! '>='
52
68
  - !ruby/object:Gem::Version
53
- version: 0.8.0
69
+ version: '0'
54
70
  type: :development
55
71
  prerelease: false
56
72
  version_requirements: !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
- - - ~>
75
+ - - ! '>='
60
76
  - !ruby/object:Gem::Version
61
- version: 0.8.0
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: bundler
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ~>
83
+ - - ! '>='
68
84
  - !ruby/object:Gem::Version
69
- version: 1.2.0
85
+ version: '0'
70
86
  type: :development
71
87
  prerelease: false
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - ~>
91
+ - - ! '>='
76
92
  - !ruby/object:Gem::Version
77
- version: 1.2.0
93
+ version: '0'
78
94
  - !ruby/object:Gem::Dependency
79
95
  name: jeweler
80
96
  requirement: !ruby/object:Gem::Requirement
81
97
  none: false
82
98
  requirements:
83
- - - ~>
99
+ - - ! '>='
84
100
  - !ruby/object:Gem::Version
85
- version: 1.8.3
101
+ version: '0'
86
102
  type: :development
87
103
  prerelease: false
88
104
  version_requirements: !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
- - - ~>
107
+ - - ! '>='
92
108
  - !ruby/object:Gem::Version
93
- version: 1.8.3
109
+ version: '0'
94
110
  - !ruby/object:Gem::Dependency
95
111
  name: simplecov
96
112
  requirement: !ruby/object:Gem::Requirement
@@ -118,10 +134,8 @@ extra_rdoc_files:
118
134
  - README.md
119
135
  files:
120
136
  - .document
121
- - .rbenv-version
122
137
  - .rspec
123
138
  - .rubocop.yml
124
- - .rvmrc
125
139
  - .travis.yml
126
140
  - CONTRIBUTING.md
127
141
  - Gemfile
@@ -139,20 +153,25 @@ files:
139
153
  - lib/rubocop/cop/align_parameters.rb
140
154
  - lib/rubocop/cop/ampersands_pipes_vs_and_or.rb
141
155
  - lib/rubocop/cop/blocks.rb
156
+ - lib/rubocop/cop/class_and_module_camel_case.rb
142
157
  - lib/rubocop/cop/cop.rb
143
158
  - lib/rubocop/cop/def_parentheses.rb
144
159
  - lib/rubocop/cop/empty_lines.rb
145
160
  - lib/rubocop/cop/encoding.rb
146
161
  - lib/rubocop/cop/end_of_line.rb
147
162
  - lib/rubocop/cop/favor_modifier.rb
163
+ - lib/rubocop/cop/favor_unless_over_negated_if.rb
148
164
  - lib/rubocop/cop/grammar.rb
149
165
  - lib/rubocop/cop/hash_syntax.rb
150
166
  - lib/rubocop/cop/if_then_else.rb
151
167
  - lib/rubocop/cop/indentation.rb
152
168
  - lib/rubocop/cop/line_length.rb
169
+ - lib/rubocop/cop/method_and_variable_snake_case.rb
170
+ - lib/rubocop/cop/new_lambda_literal.rb
153
171
  - lib/rubocop/cop/numeric_literals.rb
154
172
  - lib/rubocop/cop/offence.rb
155
173
  - lib/rubocop/cop/parameter_lists.rb
174
+ - lib/rubocop/cop/parentheses_around_condition.rb
156
175
  - lib/rubocop/cop/space_after_comma_etc.rb
157
176
  - lib/rubocop/cop/string_literals.rb
158
177
  - lib/rubocop/cop/surrounding_space.rb
@@ -169,6 +188,7 @@ files:
169
188
  - spec/rubocop/cli_spec.rb
170
189
  - spec/rubocop/cops/align_parameters_spec.rb
171
190
  - spec/rubocop/cops/ampersands_pipes_vs_and_or_spec.rb
191
+ - spec/rubocop/cops/class_and_module_camel_case_spec.rb
172
192
  - spec/rubocop/cops/cop_spec.rb
173
193
  - spec/rubocop/cops/def_with_parentheses_spec.rb
174
194
  - spec/rubocop/cops/def_without_parentheses_spec.rb
@@ -176,22 +196,28 @@ files:
176
196
  - spec/rubocop/cops/encoding_spec.rb
177
197
  - spec/rubocop/cops/end_of_line_spec.rb
178
198
  - spec/rubocop/cops/favor_modifier_spec.rb
199
+ - spec/rubocop/cops/favor_unless_over_negated_if_spec.rb
200
+ - spec/rubocop/cops/favor_until_over_negated_while_spec.rb
179
201
  - spec/rubocop/cops/grammar_spec.rb
180
202
  - spec/rubocop/cops/hash_syntax_spec.rb
181
203
  - spec/rubocop/cops/if_with_semicolon_spec.rb
182
204
  - spec/rubocop/cops/indentation_spec.rb
183
205
  - spec/rubocop/cops/line_length_spec.rb
206
+ - spec/rubocop/cops/method_and_variable_snake_case_spec.rb
184
207
  - spec/rubocop/cops/multiline_blocks_spec.rb
185
208
  - spec/rubocop/cops/multiline_if_then_spec.rb
209
+ - spec/rubocop/cops/new_lambda_literal_spec.rb
186
210
  - spec/rubocop/cops/numeric_literals_spec.rb
187
211
  - spec/rubocop/cops/offence_spec.rb
188
212
  - spec/rubocop/cops/one_line_conditional_spec.rb
189
213
  - spec/rubocop/cops/parameter_lists_spec.rb
214
+ - spec/rubocop/cops/parentheses_around_condition_spec.rb
190
215
  - spec/rubocop/cops/single_line_blocks_spec.rb
191
216
  - spec/rubocop/cops/space_after_colon_spec.rb
192
217
  - spec/rubocop/cops/space_after_comma_spec.rb
193
218
  - spec/rubocop/cops/space_after_semicolon_spec.rb
194
219
  - spec/rubocop/cops/space_around_braces_spec.rb
220
+ - spec/rubocop/cops/space_around_equals_in_default_parameter_spec.rb
195
221
  - spec/rubocop/cops/space_around_operators_spec.rb
196
222
  - spec/rubocop/cops/space_inside_brackets_spec.rb
197
223
  - spec/rubocop/cops/space_inside_parens_spec.rb
@@ -219,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
245
  version: '0'
220
246
  segments:
221
247
  - 0
222
- hash: -1525847250123006446
248
+ hash: -1829929382271578205
223
249
  required_rubygems_version: !ruby/object:Gem::Requirement
224
250
  none: false
225
251
  requirements:
data/.rbenv-version DELETED
@@ -1 +0,0 @@
1
- 1.9.3-p327
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use --create 1.9.3@rubocop