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.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +17 -0
  3. data/.github/workflows/release.yml +33 -0
  4. data/.github/workflows/test.yml +57 -0
  5. data/.gitignore +5 -4
  6. data/.rubocop.yml +8 -0
  7. data/.rubocop_todo.yml +170 -0
  8. data/CHANGELOG.md +206 -96
  9. data/Gemfile +13 -1
  10. data/README.md +15 -5
  11. data/Rakefile +31 -9
  12. data/lib/puppet-ghostbuster/puppetdb.rb +24 -9
  13. data/lib/puppet-ghostbuster/version.rb +1 -1
  14. data/lib/puppet-lint/plugins/check_ghostbuster_classes.rb +4 -4
  15. data/lib/puppet-lint/plugins/check_ghostbuster_defines.rb +4 -5
  16. data/lib/puppet-lint/plugins/check_ghostbuster_facts.rb +14 -15
  17. data/lib/puppet-lint/plugins/check_ghostbuster_files.rb +9 -9
  18. data/lib/puppet-lint/plugins/check_ghostbuster_functions.rb +8 -8
  19. data/lib/puppet-lint/plugins/check_ghostbuster_hiera_files.rb +30 -31
  20. data/lib/puppet-lint/plugins/check_ghostbuster_templates.rb +13 -10
  21. data/lib/puppet-lint/plugins/check_ghostbuster_types.rb +4 -4
  22. data/puppet-ghostbuster.gemspec +21 -19
  23. data/spec/fixtures/hiera.yaml +11 -12
  24. data/spec/fixtures/modules/foo/lib/facter/bar.rb +2 -0
  25. data/spec/fixtures/modules/foo/lib/facter/baz.rb +2 -0
  26. data/spec/fixtures/modules/foo/lib/facter/foo.rb +2 -0
  27. data/spec/fixtures/modules/foo/lib/facter/multi.rb +2 -0
  28. data/spec/fixtures/modules/foo/lib/facter/quux.rb +2 -0
  29. data/spec/fixtures/modules/foo/lib/puppet/parser/functions/bar.rb +8 -2
  30. data/spec/fixtures/modules/foo/lib/puppet/parser/functions/baz.rb +8 -2
  31. data/spec/fixtures/modules/foo/lib/puppet/parser/functions/foo.rb +8 -2
  32. data/spec/fixtures/modules/foo/lib/puppet/parser/functions/quux.rb +8 -2
  33. data/spec/fixtures/modules/foo/lib/puppet/type/bar.rb +2 -0
  34. data/spec/fixtures/modules/foo/lib/puppet/type/foo.rb +2 -0
  35. data/spec/puppet-lint/plugins/ghostbuster_classes_spec.rb +10 -9
  36. data/spec/puppet-lint/plugins/ghostbuster_defines_spec.rb +11 -11
  37. data/spec/puppet-lint/plugins/ghostbuster_facts_spec.rb +21 -20
  38. data/spec/puppet-lint/plugins/ghostbuster_files_spec.rb +25 -25
  39. data/spec/puppet-lint/plugins/ghostbuster_functions_spec.rb +16 -15
  40. data/spec/puppet-lint/plugins/ghostbuster_hiera_files_spec.rb +30 -30
  41. data/spec/puppet-lint/plugins/ghostbuster_templates_spec.rb +17 -16
  42. data/spec/puppet-lint/plugins/ghostbuster_types_spec.rb +10 -9
  43. data/spec/spec_helper.rb +33 -34
  44. metadata +76 -36
  45. 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(%r{Facter.add\(["']([^"']+)["']\)}).each do |line|
29
- fact_name = line.match(%r{Facter.add\(["']([^"']+)["']\)}).captures[0]
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(%r{\$\{?::#{fact_name}\}?}).size > 0
35
- found = true if File.readlines(manifest).grep(%r{@#{fact_name}}).size > 0
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(%r{@#{fact_name}}).size > 0
40
+ found = true if File.readlines(template).grep(/@#{fact_name}/).size > 0
41
41
  break if found
42
42
  end
43
43
 
44
- unless found
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 != '.' do
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
- if match = manifest.match(%r{.*/([^/]+)/manifests/.+$})
46
- if match.captures[0] == module_name
47
- return if File.readlines(manifest).grep(/["']\$\{module_name\}\/#{file_name}["']/).size > 0
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
- :message => "File #{module_name}/#{file_name} seems unused",
54
- :line => 1,
55
- :column => 1,
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(%r{#{function_name}\(}).size > 0
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(%r{scope.function_#{function_name}\(}).size > 0
36
- return if File.readlines(template).grep(%r{Puppet::Parser::Functions.function\(:#{function_name}}).size > 0
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
- :message => "Function #{function_name} seems unused",
41
- :line => 1,
42
- :column => 1,
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[:hierarchy].each do |hierarchy|
22
- regex = hierarchy.gsub(/%\{(::)?(trusted|server_facts|facts)\.[^\}]+\}/, "(.+)").gsub(/%\{[^\}]+\}/, ".+")
23
- facts = hierarchy.match(regex).captures.map { |f| f[/%{(::)?(trusted|server_facts|facts)\.(.+)}/, 3] }
24
- regs[regex] = facts
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("./hieradata/", "")
34
+ _path = path.gsub('./hieradata/', '')
34
35
 
35
36
  regexprs.each do |k, v|
36
- m = _path.match(Regexp.new "#{k}\.yaml")
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 = [:'and']
43
+ query = [:and]
43
44
  m.captures.map do |value|
44
- if v[i] == 'certname'
45
- query << [:'=', v[i], value]
46
- else
47
- query << [:'=', ['fact', v[i]], value]
48
- end
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 v[0] == 'certname'
53
- query = [:'=', 'certname', m.captures[0]]
54
- else
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]
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 = [:'and', query, [:'=', 'deactivated', nil]]
65
+ query = [:and, query, [:'=', 'deactivated', nil]]
67
66
 
68
- return if puppetdb.client.request('nodes', query ).data.size > 0
67
+ return if puppetdb.client.request('nodes', query).data.size > 0
69
68
  end
70
69
 
71
70
  notify :warning, {
72
- :message => "Hiera File #{_path} seems unused",
73
- :line => 1,
74
- :column => 1,
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
- if match = manifest.match(%r{.*/([^/]+)/manifests/.+$})
33
- if match.captures[0] == module_name
34
- return if File.readlines(manifest).grep(/["']\$\{module_name\}\/#{template_name}["']/).size > 0
35
- end
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
- return if File.readlines(template).grep(%r{scope.function_template\(\['#{module_name}/#{template_name}'\]\)}).size > 0
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
- :message => "Template #{module_name}/#{template_name} seems unused",
45
- :line => 1,
46
- :column => 1,
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
- :message => "Type #{type_name.capitalize} seems unused",
33
- :line => 1,
34
- :column => 1,
32
+ message: "Type #{type_name.capitalize} seems unused",
33
+ line: 1,
34
+ column: 1,
35
35
  }
36
36
  end
37
37
  end
@@ -1,29 +1,31 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
- require "puppet-ghostbuster/version"
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 = "puppet-ghostbuster"
7
+ s.name = 'puppet-ghostbuster'
7
8
  s.version = PuppetGhostbuster::VERSION
8
- s.authors = ["Camptocamp"]
9
- s.homepage = "http://github.com/camptocamp/puppet-ghostbuster"
10
- s.summary = "Dead code detector for Puppet"
11
- s.description = "Try and find dead code in Puppet receipts"
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.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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 'rake'
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 'github_changelog_generator'
24
- s.add_development_dependency 'jgrep'
25
- s.add_runtime_dependency 'json'
26
- s.add_runtime_dependency 'puppet'
27
- s.add_dependency 'puppet-lint', '>= 1.0', '< 3.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
@@ -1,13 +1,12 @@
1
1
  ---
2
- :backends: yaml
3
- :yaml:
4
- :datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
5
- :hierarchy:
6
- - "nodes/%{::trusted.certname}"
7
- - "environment/%{server_facts.environment}"
8
- - "virtual/%{facts.is_virtual}"
9
- - "domain/%{::domain}"
10
- - "common"
11
- :logger: console
12
- :merge_behavior: native
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,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Fact used in manifest
2
4
  Facter.add('bar') do
3
5
  setcode do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Fact used in template
2
4
  Facter.add('baz') do
3
5
  setcode do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Fact used in a string
2
4
  Facter.add('foo') do
3
5
  setcode do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Unused facts
2
4
  Facter.add('multi1') do
3
5
  setcode do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Fact used in inline_template
2
4
  Facter.add('quux') do
3
5
  setcode do
@@ -1,4 +1,10 @@
1
- module Puppet::Parser::Functions
2
- newfunction(:bar, :type => :rvalue) do |arguments|
1
+ # frozen_string_literal: true
2
+
3
+ module Puppet
4
+ module Parser
5
+ module Functions
6
+ newfunction(:bar, type: :rvalue) do |arguments|
7
+ end
8
+ end
3
9
  end
4
10
  end
@@ -1,4 +1,10 @@
1
- module Puppet::Parser::Functions
2
- newfunction(:baz, :type => :rvalue) do |arguments|
1
+ # frozen_string_literal: true
2
+
3
+ module Puppet
4
+ module Parser
5
+ module Functions
6
+ newfunction(:baz, type: :rvalue) do |arguments|
7
+ end
8
+ end
3
9
  end
4
10
  end
@@ -1,4 +1,10 @@
1
- module Puppet::Parser::Functions
2
- newfunction(:foo, :type => :rvalue) do |arguments|
1
+ # frozen_string_literal: true
2
+
3
+ module Puppet
4
+ module Parser
5
+ module Functions
6
+ newfunction(:foo, type: :rvalue) do |arguments|
7
+ end
8
+ end
3
9
  end
4
10
  end
@@ -1,4 +1,10 @@
1
- module Puppet::Parser::Functions
2
- newfunction(:quux, :type => :rvalue) do |arguments|
1
+ # frozen_string_literal: true
2
+
3
+ module Puppet
4
+ module Parser
5
+ module Functions
6
+ newfunction(:quux, type: :rvalue) do |arguments|
7
+ end
8
+ end
3
9
  end
4
10
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Puppet::Type.newtype(:bar) do
2
4
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Puppet::Type.newtype(:foo) do
2
4
  end
@@ -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) { "./modules/foo/manifests/init.pp" }
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) { "class foo {}" }
10
+ let(:code) { 'class foo {}' }
10
11
 
11
- it 'should not detect any problem' do
12
- expect(problems).to have(0).problems
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) { "class bar {}" }
18
+ let(:code) { 'class bar {}' }
18
19
 
19
- it 'should detect one problem' do
20
- expect(problems).to have(1).problems
20
+ it 'detects one problem' do
21
+ expect(problems.size).to eq(1)
21
22
  end
22
23
 
23
- it 'should create a warning' do
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) { "define foo::foo {}" }
9
- let(:path) { "./modules/foo/manifests/foo.pp" }
8
+ let(:code) { 'define foo::foo {}' }
9
+ let(:path) { './modules/foo/manifests/foo.pp' }
10
10
 
11
- it 'should detect one problem' do
12
- expect(problems).to have(1).problems
11
+ it 'detects one problem' do
12
+ expect(problems.size).to eq(1)
13
13
  end
14
14
 
15
- it 'should create a warning' do
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) { "define bar::foo {}" }
22
- let(:path) { "./modules/bar/manifests/foo.pp" }
21
+ let(:code) { 'define bar::foo {}' }
22
+ let(:path) { './modules/bar/manifests/foo.pp' }
23
23
 
24
- it 'should not detect any problem' do
25
- expect(problems).to have(0).problems
24
+ it 'does not detect any problem' do
25
+ expect(problems.size).to eq(0)
26
26
  end
27
27
  end
28
28
  end