puppet-lint 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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]
@@ -1,3 +1,3 @@
1
1
  class PuppetLint
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.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 00:00:00 +10:00
18
+ date: 2014-08-20 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency