puppet-ghostbuster 0.9.0 → 1.1.0
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.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/release.yml +33 -0
- data/.github/workflows/test.yml +57 -0
- data/.gitignore +5 -4
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +170 -0
- data/CHANGELOG.md +206 -96
- data/Gemfile +13 -1
- data/README.md +15 -5
- data/Rakefile +31 -9
- data/lib/puppet-ghostbuster/puppetdb.rb +24 -9
- data/lib/puppet-ghostbuster/version.rb +1 -1
- data/lib/puppet-lint/plugins/check_ghostbuster_classes.rb +4 -4
- data/lib/puppet-lint/plugins/check_ghostbuster_defines.rb +4 -5
- data/lib/puppet-lint/plugins/check_ghostbuster_facts.rb +14 -15
- data/lib/puppet-lint/plugins/check_ghostbuster_files.rb +9 -9
- data/lib/puppet-lint/plugins/check_ghostbuster_functions.rb +8 -8
- data/lib/puppet-lint/plugins/check_ghostbuster_hiera_files.rb +30 -31
- data/lib/puppet-lint/plugins/check_ghostbuster_templates.rb +13 -10
- data/lib/puppet-lint/plugins/check_ghostbuster_types.rb +4 -4
- data/puppet-ghostbuster.gemspec +21 -19
- data/spec/fixtures/hiera.yaml +11 -12
- data/spec/fixtures/modules/foo/lib/facter/bar.rb +2 -0
- data/spec/fixtures/modules/foo/lib/facter/baz.rb +2 -0
- data/spec/fixtures/modules/foo/lib/facter/foo.rb +2 -0
- data/spec/fixtures/modules/foo/lib/facter/multi.rb +2 -0
- data/spec/fixtures/modules/foo/lib/facter/quux.rb +2 -0
- data/spec/fixtures/modules/foo/lib/puppet/parser/functions/bar.rb +8 -2
- data/spec/fixtures/modules/foo/lib/puppet/parser/functions/baz.rb +8 -2
- data/spec/fixtures/modules/foo/lib/puppet/parser/functions/foo.rb +8 -2
- data/spec/fixtures/modules/foo/lib/puppet/parser/functions/quux.rb +8 -2
- data/spec/fixtures/modules/foo/lib/puppet/type/bar.rb +2 -0
- data/spec/fixtures/modules/foo/lib/puppet/type/foo.rb +2 -0
- data/spec/puppet-lint/plugins/ghostbuster_classes_spec.rb +10 -9
- data/spec/puppet-lint/plugins/ghostbuster_defines_spec.rb +11 -11
- data/spec/puppet-lint/plugins/ghostbuster_facts_spec.rb +21 -20
- data/spec/puppet-lint/plugins/ghostbuster_files_spec.rb +25 -25
- data/spec/puppet-lint/plugins/ghostbuster_functions_spec.rb +16 -15
- data/spec/puppet-lint/plugins/ghostbuster_hiera_files_spec.rb +30 -30
- data/spec/puppet-lint/plugins/ghostbuster_templates_spec.rb +17 -16
- data/spec/puppet-lint/plugins/ghostbuster_types_spec.rb +10 -9
- data/spec/spec_helper.rb +33 -34
- metadata +76 -36
- data/.travis.yml +0 -20
@@ -6,7 +6,7 @@ class PuppetLint::Checks
|
|
6
6
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
7
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
8
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
9
|
+
rescue StandardError
|
10
10
|
PuppetLint::Data.tokens = []
|
11
11
|
end
|
12
12
|
end
|
@@ -18,37 +18,36 @@ PuppetLint.new_check(:ghostbuster_facts) do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
21
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
22
|
end
|
23
23
|
|
24
24
|
def check
|
25
25
|
m = path.match(%r{.*/([^/]+)/lib/facter/(.+)$})
|
26
26
|
return if m.nil?
|
27
27
|
|
28
|
-
File.readlines(path).grep(
|
29
|
-
fact_name = line.match(
|
28
|
+
File.readlines(path).grep(/Facter.add\(["']([^"']+)["']\)/).each do |line|
|
29
|
+
fact_name = line.match(/Facter.add\(["']([^"']+)["']\)/).captures[0]
|
30
30
|
|
31
31
|
found = false
|
32
32
|
|
33
33
|
manifests.each do |manifest|
|
34
|
-
found = true if File.readlines(manifest).grep(
|
35
|
-
found = true if File.readlines(manifest).grep(
|
34
|
+
found = true if File.readlines(manifest).grep(/\$\{?::#{fact_name}\}?/).size > 0
|
35
|
+
found = true if File.readlines(manifest).grep(/@#{fact_name}/).size > 0
|
36
36
|
break if found
|
37
37
|
end
|
38
38
|
|
39
39
|
templates.each do |template|
|
40
|
-
found = true if File.readlines(template).grep(
|
40
|
+
found = true if File.readlines(template).grep(/@#{fact_name}/).size > 0
|
41
41
|
break if found
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
notify :warning, {
|
46
|
-
:message => "Fact #{fact_name} seems unused",
|
47
|
-
:line => 1,
|
48
|
-
:column => 1,
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
44
|
+
next if found
|
52
45
|
|
46
|
+
notify :warning, {
|
47
|
+
message: "Fact #{fact_name} seems unused",
|
48
|
+
line: 1,
|
49
|
+
column: 1,
|
50
|
+
}
|
51
|
+
end
|
53
52
|
end
|
54
53
|
end
|
@@ -8,7 +8,7 @@ class PuppetLint::Checks
|
|
8
8
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
9
9
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
10
10
|
PuppetLint::Data.parse_control_comments
|
11
|
-
rescue
|
11
|
+
rescue StandardError
|
12
12
|
PuppetLint::Data.tokens = []
|
13
13
|
end
|
14
14
|
end
|
@@ -30,29 +30,29 @@ PuppetLint.new_check(:ghostbuster_files) do
|
|
30
30
|
return if puppetdb.client.request('', query).data.size > 0
|
31
31
|
|
32
32
|
dir_name = File.dirname(file_name)
|
33
|
-
while dir_name != '.'
|
33
|
+
while dir_name != '.'
|
34
34
|
query = "resources[title] {
|
35
35
|
(parameters.source = 'puppet:///modules/#{module_name}/#{dir_name}'
|
36
36
|
or parameters.source = 'puppet:///modules/#{module_name}/#{dir_name}/')
|
37
37
|
and parameters.recurse = true
|
38
38
|
and nodes { deactivated is null } }"
|
39
39
|
return if puppetdb.client.request('', query).data.size > 0
|
40
|
+
|
40
41
|
dir_name = File.dirname(dir_name)
|
41
42
|
end
|
42
43
|
|
43
44
|
manifests.each do |manifest|
|
44
45
|
return if File.readlines(manifest).grep(%r{["']#{module_name}/#{file_name}["']}).size > 0
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
46
|
+
|
47
|
+
if (match = manifest.match(%r{.*/([^/]+)/manifests/.+$})) && (match.captures[0] == module_name) && (File.readlines(manifest).grep(%r{["']\$\{module_name\}/#{file_name}["']}).size > 0)
|
48
|
+
return
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
notify :warning, {
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
53
|
+
message: "File #{module_name}/#{file_name} seems unused",
|
54
|
+
line: 1,
|
55
|
+
column: 1,
|
56
56
|
}
|
57
57
|
end
|
58
58
|
end
|
@@ -6,7 +6,7 @@ class PuppetLint::Checks
|
|
6
6
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
7
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
8
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
9
|
+
rescue StandardError
|
10
10
|
PuppetLint::Data.tokens = []
|
11
11
|
end
|
12
12
|
end
|
@@ -18,7 +18,7 @@ PuppetLint.new_check(:ghostbuster_functions) do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
21
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
22
|
end
|
23
23
|
|
24
24
|
def check
|
@@ -28,18 +28,18 @@ PuppetLint.new_check(:ghostbuster_functions) do
|
|
28
28
|
function_name = m.captures[0]
|
29
29
|
|
30
30
|
manifests.each do |manifest|
|
31
|
-
return if File.readlines(manifest).grep(
|
31
|
+
return if File.readlines(manifest).grep(/#{function_name}\(/).size > 0
|
32
32
|
end
|
33
33
|
|
34
34
|
templates.each do |template|
|
35
|
-
return if File.readlines(template).grep(
|
36
|
-
return if File.readlines(template).grep(
|
35
|
+
return if File.readlines(template).grep(/scope.function_#{function_name}\(/).size > 0
|
36
|
+
return if File.readlines(template).grep(/Puppet::Parser::Functions.function\(:#{function_name}/).size > 0
|
37
37
|
end
|
38
38
|
|
39
39
|
notify :warning, {
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
40
|
+
message: "Function #{function_name} seems unused",
|
41
|
+
line: 1,
|
42
|
+
column: 1,
|
43
43
|
}
|
44
44
|
end
|
45
45
|
end
|
@@ -6,22 +6,23 @@ class PuppetLint::Checks
|
|
6
6
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
7
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
8
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
9
|
+
rescue StandardError
|
10
10
|
PuppetLint::Data.tokens = []
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
15
|
PuppetLint.new_check(:ghostbuster_hiera_files) do
|
16
|
-
|
17
16
|
def regexprs
|
18
17
|
hiera_yaml_file = ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml'
|
19
18
|
hiera = YAML.load_file(hiera_yaml_file)
|
20
19
|
regs = {}
|
21
|
-
hiera[
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
hiera['hierarchy'].each do |hierarchy|
|
21
|
+
([*hierarchy['path']] + [*hierarchy['paths']]).each do |level|
|
22
|
+
regex = level.gsub(/%\{(::)?(trusted|server_facts|facts)\.[^\}]+\}/, '(.+)').gsub(/%\{[^\}]+\}/, '.+')
|
23
|
+
facts = level.match(regex).captures.map { |f| f[/%{(::)?(trusted|server_facts|facts)\.(.+)}/, 3] }
|
24
|
+
regs[regex] = facts
|
25
|
+
end
|
25
26
|
end
|
26
27
|
regs
|
27
28
|
end
|
@@ -30,48 +31,46 @@ PuppetLint.new_check(:ghostbuster_hiera_files) do
|
|
30
31
|
return if path.match(%r{./hieradata/.*\.yaml}).nil?
|
31
32
|
|
32
33
|
puppetdb = PuppetGhostbuster::PuppetDB.new
|
33
|
-
_path = path.gsub(
|
34
|
+
_path = path.gsub('./hieradata/', '')
|
34
35
|
|
35
36
|
regexprs.each do |k, v|
|
36
|
-
m = _path.match(Regexp.new
|
37
|
+
m = _path.match(Regexp.new(k))
|
37
38
|
next if m.nil?
|
38
39
|
return if m.captures.size == 0
|
39
40
|
|
40
41
|
if m.captures.size > 1
|
41
42
|
i = 0
|
42
|
-
query = [:
|
43
|
+
query = [:and]
|
43
44
|
m.captures.map do |value|
|
44
|
-
if v[i] == 'certname'
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
query << if v[i] == 'certname'
|
46
|
+
[:'=', v[i], value]
|
47
|
+
else
|
48
|
+
[:'=', ['fact', v[i]], value]
|
49
|
+
end
|
49
50
|
i += 1
|
50
51
|
end
|
52
|
+
elsif v[0] == 'certname'
|
53
|
+
query = [:'=', 'certname', m.captures[0]]
|
51
54
|
else
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
m.captures[0]
|
61
|
-
end
|
62
|
-
query = [:'=', ['fact', v[0]], value]
|
63
|
-
end
|
55
|
+
value = if m.captures[0] == 'true'
|
56
|
+
true
|
57
|
+
elsif m.captures[0] == 'false'
|
58
|
+
false
|
59
|
+
else
|
60
|
+
m.captures[0]
|
61
|
+
end
|
62
|
+
query = [:'=', ['fact', v[0]], value]
|
64
63
|
end
|
65
64
|
|
66
|
-
query = [:
|
65
|
+
query = [:and, query, [:'=', 'deactivated', nil]]
|
67
66
|
|
68
|
-
return if puppetdb.client.request('nodes', query
|
67
|
+
return if puppetdb.client.request('nodes', query).data.size > 0
|
69
68
|
end
|
70
69
|
|
71
70
|
notify :warning, {
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
71
|
+
message: "Hiera File #{_path} seems unused",
|
72
|
+
line: 1,
|
73
|
+
column: 1,
|
75
74
|
}
|
76
75
|
end
|
77
76
|
end
|
@@ -6,7 +6,7 @@ class PuppetLint::Checks
|
|
6
6
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
7
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
8
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
9
|
+
rescue StandardError
|
10
10
|
PuppetLint::Data.tokens = []
|
11
11
|
end
|
12
12
|
end
|
@@ -18,7 +18,7 @@ PuppetLint.new_check(:ghostbuster_templates) do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
21
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
22
|
end
|
23
23
|
|
24
24
|
def check
|
@@ -29,21 +29,24 @@ PuppetLint.new_check(:ghostbuster_templates) do
|
|
29
29
|
|
30
30
|
manifests.each do |manifest|
|
31
31
|
return if File.readlines(manifest).grep(%r{["']#{module_name}/#{template_name}["']}).size > 0
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
|
33
|
+
next unless match = manifest.match(%r{.*/([^/]+)/manifests/.+$})
|
34
|
+
|
35
|
+
if match.captures[0] == module_name && (File.readlines(manifest).grep(%r{["']\$\{module_name\}/#{template_name}["']}).size > 0)
|
36
|
+
return
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
templates.each do |template|
|
40
|
-
|
41
|
+
if File.readlines(template).grep(%r{scope.function_template\(\['#{module_name}/#{template_name}'\]\)}).size > 0
|
42
|
+
return
|
43
|
+
end
|
41
44
|
end
|
42
45
|
|
43
46
|
notify :warning, {
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
+
message: "Template #{module_name}/#{template_name} seems unused",
|
48
|
+
line: 1,
|
49
|
+
column: 1,
|
47
50
|
}
|
48
51
|
end
|
49
52
|
end
|
@@ -8,7 +8,7 @@ class PuppetLint::Checks
|
|
8
8
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
9
9
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
10
10
|
PuppetLint::Data.parse_control_comments
|
11
|
-
rescue
|
11
|
+
rescue StandardError
|
12
12
|
PuppetLint::Data.tokens = []
|
13
13
|
end
|
14
14
|
end
|
@@ -29,9 +29,9 @@ PuppetLint.new_check(:ghostbuster_types) do
|
|
29
29
|
return if puppetdb.resources.include? type_name.capitalize
|
30
30
|
|
31
31
|
notify :warning, {
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
32
|
+
message: "Type #{type_name.capitalize} seems unused",
|
33
|
+
line: 1,
|
34
|
+
column: 1,
|
35
35
|
}
|
36
36
|
end
|
37
37
|
end
|
data/puppet-ghostbuster.gemspec
CHANGED
@@ -1,29 +1,31 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
4
|
+
require 'puppet-ghostbuster/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
7
|
+
s.name = 'puppet-ghostbuster'
|
7
8
|
s.version = PuppetGhostbuster::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.homepage =
|
10
|
-
s.summary =
|
11
|
-
s.description =
|
9
|
+
s.authors = ['Camptocamp', 'Vox Pupuli']
|
10
|
+
s.homepage = 'http://github.com/voxpupuli/puppet-ghostbuster'
|
11
|
+
s.summary = 'Dead code detector for Puppet'
|
12
|
+
s.description = 'Try and find dead code in Puppet receipts'
|
12
13
|
s.licenses = 'Apache-2.0'
|
13
14
|
|
15
|
+
s.required_ruby_version = '>= 2.7'
|
16
|
+
|
14
17
|
s.files = `git ls-files`.split("\n")
|
15
|
-
s.
|
16
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
17
19
|
|
18
|
-
s.add_development_dependency 'coveralls'
|
19
|
-
s.add_development_dependency '
|
20
|
+
s.add_development_dependency 'coveralls', '>= 0.8', '< 0.9'
|
21
|
+
s.add_development_dependency 'jgrep', '>= 1.0.0', '< 2.0.0'
|
22
|
+
s.add_development_dependency 'rake', '>= 13.0.0', '< 14.0.0'
|
20
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
21
|
-
s.add_development_dependency 'rspec-its', '~> 1.0'
|
22
24
|
s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
|
23
|
-
s.add_development_dependency '
|
24
|
-
s.add_development_dependency '
|
25
|
-
s.add_runtime_dependency 'json'
|
26
|
-
s.add_runtime_dependency 'puppet'
|
27
|
-
s.add_dependency 'puppet-lint', '>= 1.0', '<
|
28
|
-
s.add_runtime_dependency 'puppetdb-ruby', '>= 1.1.1'
|
25
|
+
s.add_development_dependency 'rspec-its', '~> 1.0'
|
26
|
+
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.2.0'
|
27
|
+
s.add_runtime_dependency 'json', '>= 2.0', '< 3.0'
|
28
|
+
s.add_runtime_dependency 'puppet', '>= 6.0', '< 9.0'
|
29
|
+
s.add_dependency 'puppet-lint', '>= 1.0', '< 5.0'
|
30
|
+
s.add_runtime_dependency 'puppetdb-ruby', '~> 1.1', '>= 1.1.1'
|
29
31
|
end
|
data/spec/fixtures/hiera.yaml
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
---
|
2
|
-
:
|
3
|
-
:
|
4
|
-
:
|
5
|
-
:
|
6
|
-
|
7
|
-
- "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:deep_merge_options: {}
|
2
|
+
version: 5
|
3
|
+
hierarchy:
|
4
|
+
- name: "Per-node data (yaml version)"
|
5
|
+
path: "nodes/%{trusted.certname}.yaml"
|
6
|
+
|
7
|
+
- name: "Other YAML hierarchy levels"
|
8
|
+
paths:
|
9
|
+
- "environment/%{server_facts.environment}.yaml"
|
10
|
+
- "virtual/%{facts.is_virtual}.yaml"
|
11
|
+
- "domain/%{domain}.yaml"
|
12
|
+
- "common.yaml"
|
@@ -1,26 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe 'ghostbuster_classes' do
|
4
|
-
let(:path) {
|
6
|
+
let(:path) { './modules/foo/manifests/init.pp' }
|
5
7
|
|
6
8
|
context 'with fix disabled' do
|
7
|
-
|
8
9
|
context 'when class is used' do
|
9
|
-
let(:code) {
|
10
|
+
let(:code) { 'class foo {}' }
|
10
11
|
|
11
|
-
it '
|
12
|
-
expect(problems).to
|
12
|
+
it 'does not detect any problem' do
|
13
|
+
expect(problems.size).to eq(0)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
context 'when class is not used' do
|
17
|
-
let(:code) {
|
18
|
+
let(:code) { 'class bar {}' }
|
18
19
|
|
19
|
-
it '
|
20
|
-
expect(problems).to
|
20
|
+
it 'detects one problem' do
|
21
|
+
expect(problems.size).to eq(1)
|
21
22
|
end
|
22
23
|
|
23
|
-
it '
|
24
|
+
it 'creates a warning' do
|
24
25
|
expect(problems).to contain_warning('Class Bar seems unused')
|
25
26
|
end
|
26
27
|
end
|
@@ -1,28 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe 'ghostbuster_defines' do
|
4
|
-
|
5
6
|
context 'with fix disabled' do
|
6
|
-
|
7
7
|
context 'when define is not used' do
|
8
|
-
let(:code) {
|
9
|
-
let(:path) {
|
8
|
+
let(:code) { 'define foo::foo {}' }
|
9
|
+
let(:path) { './modules/foo/manifests/foo.pp' }
|
10
10
|
|
11
|
-
it '
|
12
|
-
expect(problems).to
|
11
|
+
it 'detects one problem' do
|
12
|
+
expect(problems.size).to eq(1)
|
13
13
|
end
|
14
14
|
|
15
|
-
it '
|
15
|
+
it 'creates a warning' do
|
16
16
|
expect(problems).to contain_warning('Define Foo::Foo seems unused')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'when define is used' do
|
21
|
-
let(:code) {
|
22
|
-
let(:path) {
|
21
|
+
let(:code) { 'define bar::foo {}' }
|
22
|
+
let(:path) { './modules/bar/manifests/foo.pp' }
|
23
23
|
|
24
|
-
it '
|
25
|
-
expect(problems).to
|
24
|
+
it 'does not detect any problem' do
|
25
|
+
expect(problems.size).to eq(0)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|