puppet-lint 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/puppet-lint/plugins/check_classes.rb +1 -1
- data/lib/puppet-lint/plugins/check_whitespace.rb +1 -0
- data/lib/puppet-lint/version.rb +1 -1
- data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +31 -0
- data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +14 -0
- metadata +4 -4
@@ -256,7 +256,7 @@ PuppetLint.new_check(:variable_scope) do
|
|
256
256
|
end
|
257
257
|
|
258
258
|
unless token.value.include? '::'
|
259
|
-
unless variables_in_scope.include? token.value
|
259
|
+
unless variables_in_scope.include? token.value.gsub(/\[.+\]\Z/, '')
|
260
260
|
unless token.value =~ /\A\d+\Z/
|
261
261
|
notify :warning, {
|
262
262
|
:message => msg,
|
@@ -120,6 +120,7 @@ PuppetLint.new_check(:arrow_alignment) do
|
|
120
120
|
elsif token.type == :LBRACE
|
121
121
|
indent_depth_idx += 1
|
122
122
|
indent_depth << 0
|
123
|
+
level_tokens[indent_depth_idx] ||= []
|
123
124
|
elsif token.type == :RBRACE
|
124
125
|
level_tokens[indent_depth_idx].each do |arrow_tok|
|
125
126
|
unless arrow_tok.column == indent_depth[indent_depth_idx]
|
data/lib/puppet-lint/version.rb
CHANGED
@@ -31,6 +31,37 @@ describe 'variable_scope' do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
context 'class with no variables declared accessing local array index' do
|
35
|
+
let(:code) { "
|
36
|
+
class foo {
|
37
|
+
$bar = ['one', 'two', 'three']
|
38
|
+
$baz = $bar[1]
|
39
|
+
}"
|
40
|
+
}
|
41
|
+
|
42
|
+
it 'should not detect any problems' do
|
43
|
+
expect(problems).to have(0).problems
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'class with no variables declared accessing local hash key' do
|
48
|
+
let(:code) { "
|
49
|
+
class foo {
|
50
|
+
$bar = {
|
51
|
+
'one' => 1,
|
52
|
+
'two' => 2,
|
53
|
+
'three' => 3,
|
54
|
+
}
|
55
|
+
$baz = $bar['two']
|
56
|
+
}"
|
57
|
+
}
|
58
|
+
|
59
|
+
it 'should not detect any problems' do
|
60
|
+
expect(problems).to have(0).problems
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
34
65
|
context 'class with variables declared accessing local scope' do
|
35
66
|
let(:code) { "
|
36
67
|
class foo {
|
@@ -236,6 +236,20 @@ describe 'arrow_alignment' do
|
|
236
236
|
expect(problems).to contain_warning(msg).on_line(4).in_column(19)
|
237
237
|
end
|
238
238
|
end
|
239
|
+
|
240
|
+
context 'resource with multiple params where one is an empty hash' do
|
241
|
+
let(:code) { "
|
242
|
+
foo { 'foo':
|
243
|
+
a => true,
|
244
|
+
b => {
|
245
|
+
}
|
246
|
+
}
|
247
|
+
"}
|
248
|
+
|
249
|
+
it 'should not detect any problems' do
|
250
|
+
expect(problems).to have(0).problems
|
251
|
+
end
|
252
|
+
end
|
239
253
|
end
|
240
254
|
|
241
255
|
context 'with fix enabled' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Sharpe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2014-08-
|
18
|
+
date: 2014-08-20 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|