puppet-ghostbuster 0.9.0 → 1.2.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 +173 -0
- data/CHANGELOG.md +226 -95
- data/Gemfile +13 -1
- data/README.md +20 -5
- data/Rakefile +31 -9
- data/lib/puppet-ghostbuster/puppetdb.rb +35 -9
- data/lib/puppet-ghostbuster/util.rb +19 -0
- 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 +21 -19
- data/lib/puppet-lint/plugins/check_ghostbuster_files.rb +11 -10
- data/lib/puppet-lint/plugins/check_ghostbuster_functions.rb +9 -8
- data/lib/puppet-lint/plugins/check_ghostbuster_hiera_files.rb +45 -33
- data/lib/puppet-lint/plugins/check_ghostbuster_templates.rb +14 -11
- data/lib/puppet-lint/plugins/check_ghostbuster_types.rb +4 -4
- data/puppet-ghostbuster.gemspec +21 -19
- data/spec/fixtures/hiera.yaml +17 -12
- data/spec/fixtures/modules/foo/lib/facter/asym.rb +8 -0
- 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 +33 -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 +54 -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 +34 -34
- metadata +78 -36
- data/.travis.yml +0 -20
@@ -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
|
@@ -27,9 +27,9 @@ PuppetLint.new_check(:ghostbuster_classes) do
|
|
27
27
|
return if puppetdb.classes.include? title
|
28
28
|
|
29
29
|
notify :warning, {
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
30
|
+
message: "Class #{title} seems unused",
|
31
|
+
line: title_token.line,
|
32
|
+
column: title_token.column,
|
33
33
|
}
|
34
34
|
end
|
35
35
|
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
|
@@ -27,11 +27,10 @@ PuppetLint.new_check(:ghostbuster_defines) do
|
|
27
27
|
return if puppetdb.resources.include? type
|
28
28
|
|
29
29
|
notify :warning, {
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
30
|
+
message: "Define #{type} seems unused",
|
31
|
+
line: title_token.line,
|
32
|
+
column: title_token.column,
|
33
33
|
}
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -6,7 +8,7 @@ class PuppetLint::Checks
|
|
6
8
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
9
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
10
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
11
|
+
rescue StandardError
|
10
12
|
PuppetLint::Data.tokens = []
|
11
13
|
end
|
12
14
|
end
|
@@ -18,37 +20,37 @@ PuppetLint.new_check(:ghostbuster_facts) do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
23
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
24
|
end
|
23
25
|
|
24
26
|
def check
|
25
27
|
m = path.match(%r{.*/([^/]+)/lib/facter/(.+)$})
|
26
28
|
return if m.nil?
|
27
29
|
|
28
|
-
File.
|
29
|
-
|
30
|
+
File.foreach(path) do |line|
|
31
|
+
if line =~ /Facter.add\(["':](?<fact>[^"'\)]+)["']?\)/
|
32
|
+
fact_name = Regexp.last_match(:fact)
|
30
33
|
|
31
|
-
|
34
|
+
found = false
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
36
|
+
manifests.each do |manifest|
|
37
|
+
found = true unless PuppetGhostbuster::Util.search_file(manifest, /(\$\{?::#{fact_name}\}?|@#{fact_name})/).nil?
|
38
|
+
break if found
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
templates.each do |template|
|
42
|
+
found = true unless PuppetGhostbuster::Util.search_file(template, /@#{fact_name}/).nil?
|
43
|
+
break if found
|
44
|
+
end
|
45
|
+
|
46
|
+
next if found
|
43
47
|
|
44
|
-
unless found
|
45
48
|
notify :warning, {
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
+
message: "Fact #{fact_name} seems unused",
|
50
|
+
line: 1,
|
51
|
+
column: 1,
|
49
52
|
}
|
50
53
|
end
|
51
54
|
end
|
52
|
-
|
53
55
|
end
|
54
56
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'puppet-ghostbuster/puppetdb'
|
2
|
+
require 'puppet-ghostbuster/util'
|
2
3
|
|
3
4
|
class PuppetLint::Checks
|
4
5
|
def load_data(path, content)
|
@@ -8,7 +9,7 @@ class PuppetLint::Checks
|
|
8
9
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
9
10
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
10
11
|
PuppetLint::Data.parse_control_comments
|
11
|
-
rescue
|
12
|
+
rescue StandardError
|
12
13
|
PuppetLint::Data.tokens = []
|
13
14
|
end
|
14
15
|
end
|
@@ -30,29 +31,29 @@ PuppetLint.new_check(:ghostbuster_files) do
|
|
30
31
|
return if puppetdb.client.request('', query).data.size > 0
|
31
32
|
|
32
33
|
dir_name = File.dirname(file_name)
|
33
|
-
while dir_name != '.'
|
34
|
+
while dir_name != '.'
|
34
35
|
query = "resources[title] {
|
35
36
|
(parameters.source = 'puppet:///modules/#{module_name}/#{dir_name}'
|
36
37
|
or parameters.source = 'puppet:///modules/#{module_name}/#{dir_name}/')
|
37
38
|
and parameters.recurse = true
|
38
39
|
and nodes { deactivated is null } }"
|
39
40
|
return if puppetdb.client.request('', query).data.size > 0
|
41
|
+
|
40
42
|
dir_name = File.dirname(dir_name)
|
41
43
|
end
|
42
44
|
|
43
45
|
manifests.each do |manifest|
|
44
|
-
return if
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
46
|
+
return if PuppetGhostbuster::Util.search_file(manifest, %r{["']#{module_name}/#{file_name}["']})
|
47
|
+
|
48
|
+
if (match = manifest.match(%r{.*/([^/]+)/manifests/.+$})) && (match.captures[0] == module_name) && PuppetGhostbuster::Util.search_file(manifest, %r{["']\$\{module_name\}/#{file_name}["']})
|
49
|
+
return
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
notify :warning, {
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
54
|
+
message: "File #{module_name}/#{file_name} seems unused",
|
55
|
+
line: 1,
|
56
|
+
column: 1,
|
56
57
|
}
|
57
58
|
end
|
58
59
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -6,7 +8,7 @@ class PuppetLint::Checks
|
|
6
8
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
9
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
10
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
11
|
+
rescue StandardError
|
10
12
|
PuppetLint::Data.tokens = []
|
11
13
|
end
|
12
14
|
end
|
@@ -18,7 +20,7 @@ PuppetLint.new_check(:ghostbuster_functions) do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
23
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
24
|
end
|
23
25
|
|
24
26
|
def check
|
@@ -28,18 +30,17 @@ PuppetLint.new_check(:ghostbuster_functions) do
|
|
28
30
|
function_name = m.captures[0]
|
29
31
|
|
30
32
|
manifests.each do |manifest|
|
31
|
-
return if
|
33
|
+
return if PuppetGhostbuster::Util.search_file(manifest, "#{function_name}(")
|
32
34
|
end
|
33
35
|
|
34
36
|
templates.each do |template|
|
35
|
-
return if
|
36
|
-
return if File.readlines(template).grep(%r{Puppet::Parser::Functions.function\(:#{function_name}}).size > 0
|
37
|
+
return if PuppetGhostbuster::Util.search_file(template, /(Puppet::Parser::Functions\.function\(:|scope\.function_)#{function_name}/)
|
37
38
|
end
|
38
39
|
|
39
40
|
notify :warning, {
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
41
|
+
message: "Function #{function_name} seems unused",
|
42
|
+
line: 1,
|
43
|
+
column: 1,
|
43
44
|
}
|
44
45
|
end
|
45
46
|
end
|
@@ -6,72 +6,84 @@ 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
|
+
def hiera
|
17
|
+
@hiera ||= YAML.load_file(ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml')
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_datadir
|
21
|
+
hiera.dig('defaults', 'datadir') || 'hieradata'
|
22
|
+
end
|
23
|
+
|
24
|
+
def path_in_datadirs?(path)
|
25
|
+
@data_dirs ||= hiera['hierarchy'].map { |h| (h['datadir'] || default_datadir).chomp('/') }.uniq
|
26
|
+
path.match?(%(./#{Regexp.union(@data_dirs)}/))
|
27
|
+
end
|
16
28
|
|
17
29
|
def regexprs
|
18
|
-
hiera_yaml_file = ENV['HIERA_YAML_PATH'] || '/etc/puppetlabs/code/hiera.yaml'
|
19
|
-
hiera = YAML.load_file(hiera_yaml_file)
|
20
30
|
regs = {}
|
21
|
-
hiera[
|
22
|
-
|
23
|
-
|
24
|
-
|
31
|
+
hiera['hierarchy'].each do |hierarchy|
|
32
|
+
path_datadir = Regexp.escape((hierarchy['datadir'] || default_datadir).chomp('/'))
|
33
|
+
([*hierarchy['path']] + [*hierarchy['paths']]).each do |level|
|
34
|
+
level = File.join(path_datadir, level)
|
35
|
+
regex = Regexp.new(level.gsub(/%\{(::)?(trusted|server_facts|facts)\.[^\}]+\}/, '(.+)').gsub(/%\{[^\}]+\}/, '.+'))
|
36
|
+
facts = level.match(regex).captures.map { |f| f[/%{(::)?(trusted|server_facts|facts)\.(.+)}/, 3] }
|
37
|
+
regs[regex] = facts
|
38
|
+
end
|
25
39
|
end
|
26
40
|
regs
|
27
41
|
end
|
28
42
|
|
29
43
|
def check
|
30
|
-
return
|
44
|
+
return unless path_in_datadirs? path
|
31
45
|
|
32
46
|
puppetdb = PuppetGhostbuster::PuppetDB.new
|
33
|
-
_path = path.gsub("./hieradata/", "")
|
34
47
|
|
35
48
|
regexprs.each do |k, v|
|
36
|
-
m =
|
49
|
+
m = path.match(k)
|
37
50
|
next if m.nil?
|
51
|
+
|
38
52
|
return if m.captures.size == 0
|
39
53
|
|
40
54
|
if m.captures.size > 1
|
41
55
|
i = 0
|
42
|
-
query = [:
|
56
|
+
query = [:and]
|
43
57
|
m.captures.map do |value|
|
44
|
-
if v[i] == 'certname'
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
58
|
+
query << if v[i] == 'certname'
|
59
|
+
[:'=', v[i], value]
|
60
|
+
else
|
61
|
+
[:'=', ['fact', v[i]], value]
|
62
|
+
end
|
49
63
|
i += 1
|
50
64
|
end
|
65
|
+
elsif v[0] == 'certname'
|
66
|
+
query = [:'=', 'certname', m.captures[0]]
|
51
67
|
else
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
m.captures[0]
|
61
|
-
end
|
62
|
-
query = [:'=', ['fact', v[0]], value]
|
63
|
-
end
|
68
|
+
value = if m.captures[0] == 'true'
|
69
|
+
true
|
70
|
+
elsif m.captures[0] == 'false'
|
71
|
+
false
|
72
|
+
else
|
73
|
+
m.captures[0]
|
74
|
+
end
|
75
|
+
query = [:'=', ['fact', v[0]], value]
|
64
76
|
end
|
65
77
|
|
66
|
-
query = [:
|
78
|
+
query = [:and, query, [:'=', 'deactivated', nil]]
|
67
79
|
|
68
|
-
return if puppetdb.client.request('nodes', query
|
80
|
+
return if puppetdb.client.request('nodes', query).data.size > 0
|
69
81
|
end
|
70
82
|
|
71
83
|
notify :warning, {
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
84
|
+
message: "Hiera File #{path} seems unused",
|
85
|
+
line: 1,
|
86
|
+
column: 1,
|
75
87
|
}
|
76
88
|
end
|
77
89
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet-ghostbuster/util'
|
2
|
+
|
1
3
|
class PuppetLint::Checks
|
2
4
|
def load_data(path, content)
|
3
5
|
lexer = PuppetLint::Lexer.new
|
@@ -6,7 +8,7 @@ class PuppetLint::Checks
|
|
6
8
|
PuppetLint::Data.manifest_lines = content.split("\n", -1)
|
7
9
|
PuppetLint::Data.tokens = lexer.tokenise(content)
|
8
10
|
PuppetLint::Data.parse_control_comments
|
9
|
-
rescue
|
11
|
+
rescue StandardError
|
10
12
|
PuppetLint::Data.tokens = []
|
11
13
|
end
|
12
14
|
end
|
@@ -18,7 +20,7 @@ PuppetLint.new_check(:ghostbuster_templates) do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def templates
|
21
|
-
Dir.glob('./**/templates/**/*').select{ |f| File.file? f }
|
23
|
+
Dir.glob('./**/templates/**/*').select { |f| File.file? f }
|
22
24
|
end
|
23
25
|
|
24
26
|
def check
|
@@ -28,22 +30,23 @@ PuppetLint.new_check(:ghostbuster_templates) do
|
|
28
30
|
module_name, template_name = m.captures
|
29
31
|
|
30
32
|
manifests.each do |manifest|
|
31
|
-
return if
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
return if PuppetGhostbuster::Util.search_file(manifest, %r{["']#{module_name}/#{template_name}["']})
|
34
|
+
|
35
|
+
next unless match = manifest.match(%r{.*/([^/]+)/manifests/.+$})
|
36
|
+
|
37
|
+
if match.captures[0] == module_name && PuppetGhostbuster::Util.search_file(manifest, %r{["']\$\{module_name\}/#{template_name}["']})
|
38
|
+
return
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
42
|
templates.each do |template|
|
40
|
-
return if
|
43
|
+
return if PuppetGhostbuster::Util.search_file(template, "scope.function_template(['#{module_name}/#{template_name}'])")
|
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.4.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,18 @@
|
|
1
1
|
---
|
2
|
-
:
|
3
|
-
:
|
4
|
-
|
5
|
-
|
6
|
-
- "
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- "
|
11
|
-
:
|
12
|
-
|
13
|
-
:
|
2
|
+
version: 5
|
3
|
+
defaults:
|
4
|
+
datadir: data
|
5
|
+
hierarchy:
|
6
|
+
- name: "Some other location"
|
7
|
+
datadir: private/
|
8
|
+
path: "nodes/%{trusted.certname}.eyaml"
|
9
|
+
|
10
|
+
- name: "Per-node data (yaml version)"
|
11
|
+
path: "nodes/%{trusted.certname}.yaml"
|
12
|
+
|
13
|
+
- name: "Other YAML hierarchy levels"
|
14
|
+
paths:
|
15
|
+
- "environment/%{server_facts.environment}.yaml"
|
16
|
+
- "virtual/%{facts.is_virtual}.yaml"
|
17
|
+
- "domain/%{domain}.yaml"
|
18
|
+
- "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
|