puppet-check 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d2defe55b01e90b73fc2cb3dfc12b9004fbe02b73fc751b736529e454c0c92b
4
- data.tar.gz: 96bce3d495f0a5778d5475659ba3fbf6360290ef565666478933cd867babc34d
3
+ metadata.gz: aa44aac16d4ff64057807c913172a7a064352f4fcfee70868b0d0c06dc0dffd6
4
+ data.tar.gz: 4a1fbf02e9638af8605b26377ac335594ac8d640308f38fdbc9dbae1ada78a99
5
5
  SHA512:
6
- metadata.gz: 52037386f7f9168822a8cc14da2455d3a6a2f38cc3686ef7edbed65bee382a07159328c9ca3e1472c97d533e0966b431b921d78380bec684489e7528ec443694
7
- data.tar.gz: 859c21981164a0e002c6e8faeec55b285aa65d7cd953b838415873d482f7a32acf4ede39049329eb9435f435a7a96b741749a7501e1a0cfd045c43444f5cbc94
6
+ metadata.gz: 58186b18c0aa0fe1600c158be2d20be6ccaf75389e18baae51041a47b8c314dd550f0817a329aca29e2ed1a6c96249f3220815b8f26387a2795306ce41715d9e
7
+ data.tar.gz: 616cdc41630d9b06e93cbc27015980baa3777063837ce91e1a88955a0fdbfb41cbcc79473133d4bbe1439961345cb8f745acda8f40b15c1d0bfb58b863a80be0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 2.0.1
2
+ - Check for existence of executables for dependency module retrieval.
3
+ - Beta support for Puppet 7, Rubocop 1, and Reek 6.
4
+
1
5
  ### 2.0.0
2
6
  - Bump minimum version of Puppet to 4.0.0 and remove < 4 support code.
3
7
  - Official support for Puppet 6.
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Puppet Check
2
2
  [![Build Status](https://travis-ci.org/mschuchard/puppet-check.svg?branch=master)](https://travis-ci.org/mschuchard/puppet-check)
3
+ [![CircleCI](https://circleci.com/gh/mschuchard/puppet-check.svg?style=svg)](https://circleci.com/gh/mschuchard/puppet-check)
3
4
 
4
5
  - [Description](#description)
5
6
  - [Usage](#usage)
@@ -118,8 +118,8 @@ class DataParser
118
118
  next warnings.push("'#{req_dep['name']}' is missing an upper bound.") unless req_dep['version_requirement'].include?('<')
119
119
 
120
120
  # check for semantic versioning
121
- if key == 'dependencies'
122
- warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.") unless req_dep['version_requirement'] =~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/
121
+ if key == 'dependencies' && req_dep['version_requirement'] !~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/
122
+ warnings.push("'#{req_dep['name']}' has non-semantic versioning in its 'version_requirement' key.")
123
123
  end
124
124
  end
125
125
  end
@@ -177,16 +177,16 @@ class DataParser
177
177
  end
178
178
  end
179
179
  # check that parameters is a hash
180
- if parsed.key?('parameters')
181
- warnings.push('parameters value is not a Hash') unless parsed['parameters'].is_a?(Hash)
180
+ if parsed.key?('parameters') && !parsed['parameters'].is_a?(Hash)
181
+ warnings.push('parameters value is not a Hash')
182
182
  end
183
183
  # check that puppet_task_version is an integer
184
- if parsed.key?('puppet_task_version')
185
- warnings.push('puppet_task_version value is not an Integer') unless parsed['puppet_task_version'].is_a?(Integer)
184
+ if parsed.key?('puppet_task_version') && !parsed['puppet_task_version'].is_a?(Integer)
185
+ warnings.push('puppet_task_version value is not an Integer')
186
186
  end
187
187
  # check that supports_noop is a boolean
188
- if parsed.key?('supports_noop')
189
- warnings.push('supports_noop value is not a Boolean') unless parsed['supports_noop'].is_a?(TrueClass) || parsed['supports_noop'].is_a?(FalseClass)
188
+ if parsed.key?('supports_noop') && !(parsed['supports_noop'].is_a?(TrueClass) || parsed['supports_noop'].is_a?(FalseClass))
189
+ warnings.push('supports_noop value is not a Boolean')
190
190
  end
191
191
  # assume this is hieradata and ensure it is non-empty
192
192
  elsif parsed
@@ -206,6 +206,7 @@ class DataParser
206
206
 
207
207
  # disregard nil/undef value data check if default values (common)
208
208
  unless file =~ /^common/
209
+ # unless /^common/.match?(file) TODO: use when ruby >= 2.4
209
210
  data.each do |key, value|
210
211
  # check for nil values in the data (nil keys are fine)
211
212
  if (value.is_a?(Hash) && value.values.any?(&:nil?)) || value.nil?
@@ -31,10 +31,11 @@ class OutputResults
31
31
  hash['ignored'] = PuppetCheck.settings[:ignored_files] unless PuppetCheck.settings[:ignored_files].empty?
32
32
 
33
33
  # convert hash to markup language
34
- if settings[:output_format] == 'yaml'
34
+ case settings[:output_format]
35
+ when 'yaml'
35
36
  require 'yaml'
36
37
  puts Psych.dump(hash, indentation: 2)
37
- elsif settings[:output_format] == 'json'
38
+ when 'json'
38
39
  require 'json'
39
40
  puts JSON.pretty_generate(hash)
40
41
  else
@@ -17,30 +17,34 @@ class PuppetParser
17
17
 
18
18
  # check puppet syntax
19
19
  begin
20
+ # initialize message
21
+ message = ''
20
22
  # in puppet >= 6.5 the return of this method is a hash with the error
21
23
  new_error = Puppet::Face[:parser, :current].validate(file)
22
24
  # puppet 6.5 output format is now a hash from the face api
23
- if Puppet::PUPPETVERSION.to_f >= 6.5 && new_error != {}
24
- next PuppetCheck.settings[:error_files].push("#{file}:\n#{new_error.values.map(&:to_s).join("\n").gsub(/ \(file: #{File.absolute_path(file)}(, |\))/, '').gsub(/Could not parse.*: /, '')}")
25
+ if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0') && new_error != {}
26
+ message = new_error.values.map(&:to_s).join("\n").gsub(/ \(file: #{File.absolute_path(file)}(, |\))/, '').gsub(/Could not parse.*: /, '')
25
27
  end
26
28
  # this is the actual error that we need to rescue Puppet::Face from
27
29
  rescue SystemExit
28
30
  # puppet 5.4-6.4 has a new validator output format and eof errors have fake dir env info
29
- if Puppet::PUPPETVERSION.to_f >= 5.4 && Puppet::PUPPETVERSION.to_f < 6.5
30
- next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub(/file: #{File.absolute_path(file)}(, |\))/, '').gsub(/Could not parse.*: /, '')}")
31
+ if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.4') && Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.5')
32
+ message = errors.map(&:to_s).join("\n").gsub(/file: #{File.absolute_path(file)}(, |\))/, '').gsub(/Could not parse.*: /, '')
31
33
  # puppet 5.0-5.2 can only do one error per line and outputs fake dir env info
32
- elsif Puppet::PUPPETVERSION.to_f >= 5.0 && Puppet::PUPPETVERSION.to_f < 5.3
33
- next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '').gsub(/Could not parse.*: /, '')}")
34
+ elsif Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.0') && Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('5.3')
35
+ message = errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '').gsub(/Could not parse.*: /, '')
34
36
  end
35
37
  # puppet < 5 and 5.3 parser output style
36
- next PuppetCheck.settings[:error_files].push("#{file}:\n#{errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')}")
38
+ message = errors.map(&:to_s).join("\n").gsub("#{File.absolute_path(file)}:", '')
37
39
  end
40
+ # output message
41
+ next PuppetCheck.settings[:error_files].push("#{file}:\n#{message}") unless message.empty?
38
42
 
39
43
  # initialize warnings with output from the parser if it exists, since the output is warnings if Puppet::Face did not trigger a SystemExit
40
44
  warnings = "#{file}:"
41
45
  unless errors.empty?
42
46
  # puppet 5.4-5.x has a new validator output format
43
- warnings << if Puppet::PUPPETVERSION.to_f >= 5.4
47
+ warnings << if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('5.4')
44
48
  "\n#{errors.map(&:to_s).join("\n").gsub("file: #{File.absolute_path(file)}, ", '')}"
45
49
  # puppet <= 5.3 validator output format
46
50
  else
@@ -3,7 +3,7 @@ class RSpecPuppetSupport
3
3
  # code diagram:
4
4
  # 'puppetcheck:spec' task invokes 'run'
5
5
  # 'run' invokes 'file_setup' always and 'dependency_setup' if metadata.json exists
6
- # 'dependency_setup' invokes 'git/forge/hg' if dependencies exist and git/forge/hg is download option
6
+ # 'dependency_setup' invokes 'git/forge/svn/hg' if dependencies exist and git/forge/svn/hg is download option
7
7
  # 'git/forge/svn/hg' downloads module fixture appropriately
8
8
 
9
9
  # prepare the spec fixtures directory for rspec-puppet testing
@@ -15,10 +15,10 @@ class RSpecPuppetSupport
15
15
  # setup fixtures for rspec-puppet testing
16
16
  specdirs.each do |specdir|
17
17
  # skip to next specdir if it does not seem like a puppet module
18
- next unless File.directory?(specdir + '/../manifests')
18
+ next unless File.directory?("#{specdir}/../manifests")
19
19
 
20
20
  # change to module directory
21
- Dir.chdir(specdir + '/..')
21
+ Dir.chdir("#{specdir}/..")
22
22
 
23
23
  # grab the module name from the directory name of the module to pass to file_setup
24
24
  file_setup(File.basename(Dir.pwd))
@@ -90,7 +90,11 @@ class RSpecPuppetSupport
90
90
  # establish path to clone module to
91
91
  path = "spec/fixtures/modules/#{File.basename(git_url, '.git')}"
92
92
  # is the module present and already cloned with git? do a pull; otherwise, do a clone
93
- File.directory?("#{path}/.git") ? spawn("git -C #{path} pull") : spawn("git clone #{args} #{git_url} #{path}")
93
+ begin
94
+ File.directory?("#{path}/.git") ? spawn("git -C #{path} pull") : spawn("git clone #{args} #{git_url} #{path}")
95
+ rescue Errno::ENOENT
96
+ warn 'git is not installed and cannot be used to retrieve dependency modules'
97
+ end
94
98
  end
95
99
 
96
100
  # download external module dependency with forge
@@ -107,7 +111,11 @@ class RSpecPuppetSupport
107
111
  # establish path to checkout module to
108
112
  path = "spec/fixtures/modules/#{File.basename(svn_url)}"
109
113
  # is the module present and already checked out with svn? do an update; otherwise, do a checkout
110
- File.directory?("#{path}/.svn") ? spawn("svn update #{path}") : spawn("svn co #{args} #{svn_url} #{path}")
114
+ begin
115
+ File.directory?("#{path}/.svn") ? spawn("svn update #{path}") : spawn("svn co #{args} #{svn_url} #{path}")
116
+ rescue Errno::ENOENT
117
+ warn 'subversion is not installed and cannot be used to retrieve dependency modules'
118
+ end
111
119
  end
112
120
 
113
121
  # download external module dependency with hg
@@ -116,6 +124,10 @@ class RSpecPuppetSupport
116
124
  # establish path to clone module to
117
125
  path = "spec/fixtures/modules/#{File.basename(hg_url)}"
118
126
  # is the module present and already cloned with hg? do a pull and update; otherwise do a clone
119
- File.directory?("#{path}/.hg") ? spawn("hg --cwd #{path} pull; hg --cwd #{path} update") : spawn("hg clone #{args} #{hg_url} #{path}")
127
+ begin
128
+ File.directory?("#{path}/.hg") ? spawn("hg --cwd #{path} pull; hg --cwd #{path} update") : spawn("hg clone #{args} #{hg_url} #{path}")
129
+ rescue Errno::ENOENT
130
+ warn 'mercurial is not installed and cannot be used to retrieve dependency modules'
131
+ end
120
132
  end
121
133
  end
@@ -29,7 +29,7 @@ describe DataParser do
29
29
  end
30
30
  end
31
31
 
32
- if RUBY_VERSION.to_f >= 2.3
32
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3')
33
33
  context '.eyaml' do
34
34
  before(:each) do
35
35
  PuppetCheck.settings[:ignored_files] = []
@@ -11,10 +11,10 @@ describe PuppetParser do
11
11
  context '.manifest' do
12
12
  it 'puts a bad syntax Puppet manifest in the error files array' do
13
13
  PuppetParser.manifest([fixtures_dir + 'manifests/syntax.pp'], false, [])
14
- if Puppet::PUPPETVERSION.to_f >= 6.5
14
+ if Gem::Version.new(Puppet::PUPPETVERSION) >= Gem::Version.new('6.5.0')
15
15
  expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nLanguage validation logged 2 errors})
16
16
  # dealing with annoying warning in puppet 5 and 6
17
- elsif RUBY_VERSION.to_f < 2.3
17
+ elsif Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.3')
18
18
  expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nSupport for ruby version.*\n.*\nThis Variable has no effect.*\nIllegal variable name})
19
19
  else
20
20
  expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/syntax.pp:\nThis Variable has no effect.*\nIllegal variable name})
@@ -22,11 +22,14 @@ describe PuppetParser do
22
22
  expect(PuppetCheck.settings[:warning_files]).to eql([])
23
23
  expect(PuppetCheck.settings[:clean_files]).to eql([])
24
24
  end
25
- it 'puts a bad syntax at eof Puppet manifest in the error files array' do
26
- PuppetParser.manifest([fixtures_dir + 'manifests/eof_syntax.pp'], false, [])
27
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/eof_syntax.pp:\nSyntax error at end of input})
28
- expect(PuppetCheck.settings[:warning_files]).to eql([])
29
- expect(PuppetCheck.settings[:clean_files]).to eql([])
25
+ # puppet 5 api has output issues for this fixture
26
+ unless Gem::Version.new(Puppet::PUPPETVERSION) < Gem::Version.new('6.0.0')
27
+ it 'puts a bad syntax at eof Puppet manifest in the error files array' do
28
+ PuppetParser.manifest([fixtures_dir + 'manifests/eof_syntax.pp'], false, [])
29
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}manifests/eof_syntax.pp:\nSyntax error at end of input})
30
+ expect(PuppetCheck.settings[:warning_files]).to eql([])
31
+ expect(PuppetCheck.settings[:clean_files]).to eql([])
32
+ end
30
33
  end
31
34
  it 'puts a bad parser and lint style Puppet manifest in the warning files array' do
32
35
  PuppetParser.manifest([fixtures_dir + 'manifests/style_parser.pp'], true, [])
@@ -37,7 +40,7 @@ describe PuppetParser do
37
40
  it 'puts a bad lint style Puppet manifest in the warning files array' do
38
41
  PuppetParser.manifest([fixtures_dir + 'manifests/style_lint.pp'], true, [])
39
42
  expect(PuppetCheck.settings[:error_files]).to eql([])
40
- expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_lint.pp:\n.*double quoted string containing.*\n.*indentation of})
43
+ expect(PuppetCheck.settings[:warning_files][0]).to match(%r{^#{fixtures_dir}manifests/style_lint.pp:\n.*(?:indentation of|double quoted string containing).*\n.*(?:indentation of|double quoted string containing)})
41
44
  expect(PuppetCheck.settings[:clean_files]).to eql([])
42
45
  end
43
46
  it 'puts a bad style Puppet manifest in the clean files array when puppetlint_args ignores its warnings' do
@@ -5,7 +5,7 @@ require_relative '../../lib/puppet-check/regression_check'
5
5
  describe RegressionCheck do
6
6
  context '.config' do
7
7
  # json gem got messed up for the EOL Ruby versions
8
- if RUBY_VERSION.to_f >= 2.2
8
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2')
9
9
  it 'raise an appropriate error if the file is malformed' do
10
10
  expect { RegressionCheck.config(fixtures_dir + 'metadata.json') }.to raise_error(OctocatalogDiff::Errors::ConfigurationFileContentError, 'Configuration must define OctocatalogDiff::Config!')
11
11
  end
@@ -14,7 +14,11 @@ describe RSpecPuppetSupport do
14
14
  before(:each) { Dir.chdir(fixtures_dir) }
15
15
 
16
16
  it 'creates missing directories, missing site.pp, missing symlinks, and a missing spec_helper' do
17
- expect { rspec_puppet_setup }.to output("puppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
17
+ if File.directory?('/home/travis')
18
+ expect { rspec_puppet_setup }.to output("puppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
19
+ else
20
+ expect { rspec_puppet_setup }.to output("subversion is not installed and cannot be used to retrieve dependency modules\npuppetlabs/gruntmaster has an unspecified, or specified but unsupported, download method.\n").to_stderr
21
+ end
18
22
 
19
23
  # .file_setup
20
24
  expect(File.directory?('spec/fixtures/manifests')).to be true
@@ -38,7 +38,11 @@ describe RubyParser do
38
38
  context '.template' do
39
39
  it 'puts a bad syntax ruby template file in the error files array' do
40
40
  RubyParser.template([fixtures_dir + 'templates/syntax.erb'])
41
- expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.erb:\n.*syntax error, unexpected tIDENTIFIER})
41
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
42
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.erb:\n.*1: syntax error, unexpected.*\n.*ruby})
43
+ else
44
+ expect(PuppetCheck.settings[:error_files][0]).to match(%r{^#{fixtures_dir}templates/syntax.erb:\n.*syntax error, unexpected tIDENTIFIER})
45
+ end
42
46
  expect(PuppetCheck.settings[:warning_files]).to eql([])
43
47
  expect(PuppetCheck.settings[:clean_files]).to eql([])
44
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Schuchard
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2021-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: puppet-lint
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '4.0'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '6'
56
+ version: '7'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,21 +63,27 @@ dependencies:
63
63
  version: '4.0'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '6'
66
+ version: '7'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: rubocop
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0.58'
74
+ - - "<"
75
+ - !ruby/object:Gem::Version
76
+ version: '2'
74
77
  type: :runtime
75
78
  prerelease: false
76
79
  version_requirements: !ruby/object:Gem::Requirement
77
80
  requirements:
78
- - - "~>"
81
+ - - ">="
79
82
  - !ruby/object:Gem::Version
80
83
  version: '0.58'
84
+ - - "<"
85
+ - !ruby/object:Gem::Version
86
+ version: '2'
81
87
  - !ruby/object:Gem::Dependency
82
88
  name: rubocop-performance
83
89
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +143,7 @@ dependencies:
137
143
  description: Puppet Check is a gem that provides a comprehensive, streamlined, and
138
144
  efficient analysis of the syntax, style, and validity of your entire Puppet code
139
145
  and data.
140
- email:
146
+ email:
141
147
  executables:
142
148
  - puppet-check
143
149
  extensions: []
@@ -215,7 +221,7 @@ homepage: https://www.github.com/mschuchard/puppet-check
215
221
  licenses:
216
222
  - MIT
217
223
  metadata: {}
218
- post_install_message:
224
+ post_install_message:
219
225
  rdoc_options: []
220
226
  require_paths:
221
227
  - lib
@@ -230,9 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
236
  - !ruby/object:Gem::Version
231
237
  version: '0'
232
238
  requirements: []
233
- rubyforge_project:
234
- rubygems_version: 2.7.6
235
- signing_key:
239
+ rubygems_version: 3.1.2
240
+ signing_key:
236
241
  specification_version: 4
237
242
  summary: A streamlined comprehensive set of checks for your entire Puppet code and
238
243
  data