puppet-lint 0.1.11 → 0.1.12
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.rb +2 -2
- data/lib/puppet-lint/plugin.rb +11 -6
- data/lib/puppet-lint/plugins/check_classes.rb +2 -2
- data/puppet-lint.gemspec +1 -1
- data/spec/puppet-lint/check_classes_spec.rb +19 -5
- data/spec/puppet-lint/check_conditionals_spec.rb +1 -1
- data/spec/puppet-lint/check_resources_spec.rb +1 -1
- data/spec/puppet-lint/check_strings_spec.rb +1 -1
- data/spec/puppet-lint/check_variables_spec.rb +1 -1
- data/spec/puppet-lint/check_whitespace_spec.rb +1 -1
- metadata +4 -4
data/lib/puppet-lint.rb
CHANGED
@@ -74,7 +74,7 @@ end
|
|
74
74
|
class PuppetLint::NoCodeError < StandardError; end
|
75
75
|
|
76
76
|
class PuppetLint
|
77
|
-
VERSION = '0.1.
|
77
|
+
VERSION = '0.1.12'
|
78
78
|
|
79
79
|
attr_reader :code, :file
|
80
80
|
|
@@ -155,7 +155,7 @@ class PuppetLint
|
|
155
155
|
end
|
156
156
|
|
157
157
|
PuppetLint::CheckPlugin.repository.each do |plugin|
|
158
|
-
report plugin.new.run(@fileinfo
|
158
|
+
report plugin.new.run(@fileinfo, @data)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
data/lib/puppet-lint/plugin.rb
CHANGED
@@ -53,14 +53,13 @@ class PuppetLint::CheckPlugin
|
|
53
53
|
message_hash
|
54
54
|
end
|
55
55
|
|
56
|
-
def run(
|
56
|
+
def run(fileinfo, data)
|
57
57
|
lexer = Puppet::Parser::Lexer.new
|
58
58
|
lexer.string = data
|
59
59
|
@tokens = lexer.fullscan
|
60
|
-
@
|
60
|
+
@fileinfo = fileinfo
|
61
61
|
@data = data
|
62
62
|
|
63
|
-
test(path, data) if self.respond_to? :test
|
64
63
|
self.public_methods.select { |method|
|
65
64
|
method.to_s.start_with? 'lint_check_'
|
66
65
|
}.each { |method|
|
@@ -103,8 +102,10 @@ class PuppetLint::CheckPlugin
|
|
103
102
|
elsif @tokens[idx].first == :RBRACE
|
104
103
|
lbrace_count -= 1
|
105
104
|
if lbrace_count == 0
|
106
|
-
|
107
|
-
|
105
|
+
if @tokens[token_idx].first == :CLASS and @tokens[token_idx + 1].first != :LBRACE
|
106
|
+
@class_indexes << {:start => token_idx, :end => idx}
|
107
|
+
end
|
108
|
+
@defined_type_indexes << {:start => token_idx, :end => idx} if @tokens[token_idx].first == :DEFINE
|
108
109
|
break
|
109
110
|
end
|
110
111
|
end
|
@@ -118,7 +119,11 @@ class PuppetLint::CheckPlugin
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def path
|
121
|
-
@path
|
122
|
+
@fileinfo[:path]
|
123
|
+
end
|
124
|
+
|
125
|
+
def fullpath
|
126
|
+
@fileinfo[:fullpath]
|
122
127
|
end
|
123
128
|
|
124
129
|
def data
|
@@ -6,7 +6,7 @@ class PuppetLint::Plugins::CheckClasses < PuppetLint::CheckPlugin
|
|
6
6
|
end
|
7
7
|
|
8
8
|
check 'autoloader_layout' do
|
9
|
-
unless
|
9
|
+
unless fullpath == ""
|
10
10
|
(class_indexes + defined_type_indexes).each do |class_idx|
|
11
11
|
title_token = tokens[class_idx[:start]+1]
|
12
12
|
split_title = title_token.last[:value].split('::')
|
@@ -16,7 +16,7 @@ class PuppetLint::Plugins::CheckClasses < PuppetLint::CheckPlugin
|
|
16
16
|
expected_path = "#{title_token.last[:value]}/manifests/init.pp"
|
17
17
|
end
|
18
18
|
|
19
|
-
unless
|
19
|
+
unless fullpath.end_with? expected_path
|
20
20
|
notify :error, :message => "#{title_token.last[:value]} not in autoload module layout", :linenumber => title_token.last[:line]
|
21
21
|
end
|
22
22
|
end
|
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.12'
|
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
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckClasses do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -228,31 +228,45 @@ describe PuppetLint::Plugins::CheckClasses do
|
|
228
228
|
|
229
229
|
describe 'foo::bar in foo/manifests/bar.pp' do
|
230
230
|
let(:code) { "class foo::bar { }" }
|
231
|
-
let(:
|
231
|
+
let(:fullpath) { '/etc/puppet/modules/foo/manifests/bar.pp' }
|
232
232
|
|
233
233
|
its(:problems) { should be_empty }
|
234
234
|
end
|
235
235
|
|
236
236
|
describe 'foo::bar::baz in foo/manifests/bar/baz.pp' do
|
237
237
|
let(:code) { 'define foo::bar::baz() { }' }
|
238
|
-
let(:
|
238
|
+
let(:fullpath) { '/etc/puppet/modules/foo/manifests/bar/baz.pp' }
|
239
239
|
|
240
240
|
its(:problems) { should be_empty }
|
241
241
|
end
|
242
242
|
|
243
243
|
describe 'foo in foo/manifests/init.pp' do
|
244
244
|
let(:code) { 'class foo { }' }
|
245
|
-
let(:
|
245
|
+
let(:fullpath) { '/etc/puppet/modules/foo/manifests/init.pp' }
|
246
246
|
|
247
247
|
its(:problems) { should be_empty }
|
248
248
|
end
|
249
249
|
|
250
250
|
describe 'foo::bar in foo/manifests/init.pp' do
|
251
251
|
let(:code) { 'class foo::bar { }' }
|
252
|
-
let(:
|
252
|
+
let(:fullpath) { '/etc/puppet/modules/foo/manifests/init.pp' }
|
253
253
|
|
254
254
|
its(:problems) {
|
255
255
|
should only_have_problem :kind => :error, :message => "foo::bar not in autoload module layout", :linenumber => 1
|
256
256
|
}
|
257
257
|
end
|
258
|
+
|
259
|
+
describe 'foo included in bar/manifests/init.pp' do
|
260
|
+
let(:code) { "
|
261
|
+
class bar {
|
262
|
+
class {'foo':
|
263
|
+
someparam => 'somevalue',
|
264
|
+
}
|
265
|
+
}
|
266
|
+
"
|
267
|
+
}
|
268
|
+
let(:fullpath) { '/etc/puppet/modules/bar/manifests/init.pp' }
|
269
|
+
its(:problems) { should be_empty }
|
270
|
+
|
271
|
+
end
|
258
272
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckConditionals do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckResources do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckStrings do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckVariables do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe PuppetLint::Plugins::CheckWhitespace do
|
4
4
|
subject do
|
5
5
|
klass = described_class.new
|
6
|
-
klass.run(defined?(
|
6
|
+
klass.run(defined?(fullpath).nil? ? {:fullpath => ''} : {:fullpath => fullpath}, code)
|
7
7
|
klass
|
8
8
|
end
|
9
9
|
|
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: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 12
|
10
|
+
version: 0.1.12
|
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: 2012-01-
|
18
|
+
date: 2012-01-27 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|