puppet-lint 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
data/lib/puppet-lint.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
+
# We're doing this instead of a gem dependency so folks using Puppet
|
2
|
+
# from their distro packages don't have to install the gem.
|
3
|
+
begin
|
4
|
+
require 'puppet'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'Unable to require puppet. Please gem install puppet and try again.'
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
1
10
|
require 'puppet-lint/plugin'
|
2
11
|
require 'puppet-lint/plugins'
|
3
|
-
require 'puppet'
|
4
12
|
|
5
13
|
class PuppetLint::NoCodeError < StandardError; end
|
6
14
|
|
7
15
|
class PuppetLint
|
8
|
-
VERSION = '0.1.
|
16
|
+
VERSION = '0.1.6'
|
9
17
|
|
10
18
|
attr_reader :code, :file
|
11
19
|
|
@@ -65,11 +65,19 @@ class PuppetLint::Plugins::CheckClasses < PuppetLint::CheckPlugin
|
|
65
65
|
|
66
66
|
class_indexes.each do |class_idx|
|
67
67
|
class_tokens = tokens[class_idx[:start]..class_idx[:end]]
|
68
|
-
class_tokens[1..-1].
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
class_tokens[1..-1].each_index do |token_idx|
|
69
|
+
token = class_tokens[1..-1][token_idx]
|
70
|
+
next_token = class_tokens[1..-1][token_idx + 1]
|
71
|
+
|
72
|
+
if token.first == :CLASS
|
73
|
+
if next_token.first != :LBRACE
|
74
|
+
warn "class defined inside a class on line #{token.last[:line]}"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if token.first == :DEFINE
|
79
|
+
warn "define defined inside a class on line #{token.last[:line]}"
|
80
|
+
end
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
data/puppet-lint.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'puppet-lint'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.6'
|
4
4
|
s.homepage = 'https://github.com/rodjek/puppet-lint/'
|
5
5
|
s.summary = 'Ensure your Puppet manifests conform with the Puppetlabs style guide'
|
6
6
|
s.description = 'Checks your Puppet manifests against the Puppetlabs
|
@@ -171,4 +171,30 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
171
171
|
its(:warnings) { should be_empty }
|
172
172
|
its(:errors) { should be_empty }
|
173
173
|
end
|
174
|
+
|
175
|
+
describe 'instantiating a parametised class inside a class' do
|
176
|
+
let(:code) { "
|
177
|
+
class bar {
|
178
|
+
class { 'foo':
|
179
|
+
bar => 'foobar'
|
180
|
+
}
|
181
|
+
}"
|
182
|
+
}
|
183
|
+
|
184
|
+
its(:warnings) { should be_empty }
|
185
|
+
its(:errors) { should be_empty }
|
186
|
+
end
|
187
|
+
|
188
|
+
describe 'instantiating a parametised class inside a define' do
|
189
|
+
let(:code) { "
|
190
|
+
define bar() {
|
191
|
+
class { 'foo':
|
192
|
+
bar => 'foobar'
|
193
|
+
}
|
194
|
+
}"
|
195
|
+
}
|
196
|
+
|
197
|
+
its(:warnings) { should be_empty }
|
198
|
+
its(:errors) { should be_empty }
|
199
|
+
end
|
174
200
|
end
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
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: 2011-10-
|
18
|
+
date: 2011-10-06 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|