puppet-check 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +11 -0
  3. data/.travis.yml +21 -0
  4. data/CHANGELOG.md +14 -0
  5. data/Dockerfile +22 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE.md +20 -0
  8. data/README.md +148 -0
  9. data/Rakefile +24 -0
  10. data/Vagrantfile +77 -0
  11. data/bin/puppet-check +5 -0
  12. data/config.reek +3 -0
  13. data/images/puppetcheck_new.png +0 -0
  14. data/images/puppetcheck_old.odp +0 -0
  15. data/images/puppetcheck_old.png +0 -0
  16. data/lib/puppet-check.rb +86 -0
  17. data/lib/puppet-check/cli.rb +33 -0
  18. data/lib/puppet-check/data_parser.rb +95 -0
  19. data/lib/puppet-check/puppet_parser.rb +77 -0
  20. data/lib/puppet-check/ruby_parser.rb +93 -0
  21. data/lib/puppet-check/tasks.rb +15 -0
  22. data/lib/puppet-check/utils.rb +22 -0
  23. data/puppet-check.gemspec +25 -0
  24. data/spec/fixtures/foobarbaz +1 -0
  25. data/spec/fixtures/hieradata/good.json +7 -0
  26. data/spec/fixtures/hieradata/good.yaml +7 -0
  27. data/spec/fixtures/hieradata/style.yaml +15 -0
  28. data/spec/fixtures/hieradata/syntax.json +8 -0
  29. data/spec/fixtures/hieradata/syntax.yaml +8 -0
  30. data/spec/fixtures/lib/good.rb +1 -0
  31. data/spec/fixtures/lib/rubocop_style.rb +3 -0
  32. data/spec/fixtures/lib/style.rb +12 -0
  33. data/spec/fixtures/lib/syntax.rb +1 -0
  34. data/spec/fixtures/librarian_good/Puppetfile +5 -0
  35. data/spec/fixtures/librarian_style/Puppetfile +5 -0
  36. data/spec/fixtures/librarian_syntax/Puppetfile +7 -0
  37. data/spec/fixtures/manifests/good.pp +1 -0
  38. data/spec/fixtures/manifests/style_lint.pp +4 -0
  39. data/spec/fixtures/manifests/style_parser.pp +2 -0
  40. data/spec/fixtures/manifests/syntax.pp +1 -0
  41. data/spec/fixtures/metadata_good/metadata.json +35 -0
  42. data/spec/fixtures/metadata_style/metadata.json +35 -0
  43. data/spec/fixtures/metadata_syntax/metadata.json +15 -0
  44. data/spec/fixtures/templates/good.epp +3 -0
  45. data/spec/fixtures/templates/good.erb +1 -0
  46. data/spec/fixtures/templates/no_method_error.erb +3 -0
  47. data/spec/fixtures/templates/style.erb +3 -0
  48. data/spec/fixtures/templates/syntax.epp +3 -0
  49. data/spec/fixtures/templates/syntax.erb +1 -0
  50. data/spec/integration/integration_spec.rb +41 -0
  51. data/spec/puppet-check/cli_spec.rb +48 -0
  52. data/spec/puppet-check/data_parser_spec.rb +64 -0
  53. data/spec/puppet-check/puppet_parser_spec.rb +67 -0
  54. data/spec/puppet-check/ruby_parser_spec.rb +111 -0
  55. data/spec/puppet-check/utils_spec.rb +20 -0
  56. data/spec/puppet-check_spec.rb +82 -0
  57. data/spec/spec_helper.rb +13 -0
  58. metadata +233 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ffc2e861ac23804ea044caf8772a9a73e217d84
4
+ data.tar.gz: e97edbae606ba57e138b47668a94419b3e0cef48
5
+ SHA512:
6
+ metadata.gz: e08a269bd34024edc353a0f9d5fd60cb1370a3cec7b66f451b83979f8c9b6f5f67d9595423fc7cf43e2e85beb8aa0cd96930499531a25a5e4775d7fd4ce427b9
7
+ data.tar.gz: 27c1c67568bfdcdd805ae14814fbb1c62ce8bde32e17f6d59e7612eeaae40027a35cc51059bfda7d8270ed48806387bfb41289b45dfbb623ac5e676ec5fb2dc6
@@ -0,0 +1,11 @@
1
+ ---
2
+ AllCops:
3
+ Include:
4
+ - 'lib/**/*.rb'
5
+ - 'bin/*.rb'
6
+ - 'spec/**/*.rb'
7
+ Exclude:
8
+ - 'spec/fixtures/**/*.rb'
9
+
10
+ Metrics/LineLength:
11
+ Enabled: false
@@ -0,0 +1,21 @@
1
+ sudo: false
2
+ notifications:
3
+ email: false
4
+
5
+ language: ruby
6
+ cache: bundler
7
+
8
+ matrix:
9
+ include:
10
+ - rvm: 1.9.3
11
+ env: TEST=spec
12
+ - rvm: 2.0.0
13
+ env: TEST=spec
14
+ - rvm: 2.1.9
15
+ env: TEST=default
16
+ - rvm: 2.2.5
17
+ env: TEST=spec
18
+
19
+ before_install: gem update bundler
20
+ install: bundle install --retry=3
21
+ script: bundle exec rake $TEST
@@ -0,0 +1,14 @@
1
+ ### 1.3.0 (Roadmap)
2
+ - minimum puppet version bump to 3.5 and future parser enabled by force for version < 4 (search code on 'future')
3
+ - minimum ruby version bump to 2.0.0 (switch vagrant to centos7, remove 1.9.3 from travis.yml, add 2.3.x to travis.yml, update readme, remove psych::syntaxerror from dataparser.yaml, and remove | already initialized constant from rubyparser.template style spec)
4
+
5
+ ### 1.2.0 (Roadmap)
6
+ - json and yaml output formats support
7
+ - beaker as optional task
8
+
9
+ ### 1.1.0 (Roadmap)
10
+ - rspec and rspec puppet as optional tasks
11
+ - add additional hiera checks, including nested hash parsing
12
+
13
+ ### 1.0.0
14
+ - Initial release.
@@ -0,0 +1,22 @@
1
+ # PuppetCheck: automated rake testing in reproducible environment
2
+
3
+ # Build container to automatically provision environment and execute tests.
4
+ # sudo docker build -t puppetcheck .
5
+
6
+ # Start and enter container for troubleshooting if necessary.
7
+ # sudo docker run -it -d puppetcheck
8
+ # sudo docker exec -it `sudo docker ps -qa | awk '{print $1}' | head -n 1` bash
9
+
10
+ # Remove running containers before rebuild.
11
+ # sudo docker ps -qa | xargs sudo docker kill
12
+
13
+ # Cleanup all instances when you are finished.
14
+ # sudo docker ps -qa | xargs sudo docker rm
15
+ # sudo docker images | grep puppetcheck | awk '{print $3}' | xargs sudo docker rmi
16
+
17
+ FROM ubuntu:15.10
18
+ RUN apt-get update && apt-get install ruby -y
19
+ RUN gem install --no-rdoc --no-ri puppet rspec rake rubocop reek puppet-lint spdx-licenses
20
+ COPY / /
21
+ # Exit 0 to ensure container is built with tag for troubleshooting.
22
+ RUN rake; exit 0
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'reek' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Matt Schuchard
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,148 @@
1
+ # Puppet Check
2
+ [![Build Status](https://travis-ci.org/mschuchard/puppet-check.svg?branch=master)](https://travis-ci.org/mschuchard/puppet-check)
3
+
4
+ ## Description
5
+ Puppet Check is a gem for comprehensive, efficient, streamlined, and easy verification and validation of your Puppet code and data.
6
+
7
+ ### Former Method for Code and Data Checks
8
+ ![Old](https://raw.githubusercontent.com/mschuchard/puppet-check/master/images/puppetcheck_old.png)
9
+
10
+ ### Puppet Check Method for Code and Data Checks
11
+ ![New](https://raw.githubusercontent.com/mschuchard/puppet-check/master/images/puppetcheck_new.png)
12
+
13
+ ### Example Output
14
+ ```
15
+ The following files have errors:
16
+ -- manifests/syntax.pp:
17
+ This Variable has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form) at 1:1
18
+ Illegal variable name, The given name '' does not conform to the naming rule /^((::)?[a-z]\w*)*((::)?[a-z_]\w*)$/ at 1:1
19
+ Found 2 errors. Giving up
20
+
21
+ -- templates/syntax.epp:
22
+ This Name has no effect. A value was produced and then forgotten (one or more preceding expressions may have the wrong form) at 2:4
23
+
24
+ -- lib/syntax.rb:
25
+ (eval):1: syntax error, unexpected =>, expecting end-of-input
26
+ BEGIN {throw :good}; i => am : a '' ruby.file { with } &bad syntax
27
+ ^
28
+
29
+ -- templates/syntax.erb:
30
+ (erb):1: syntax error, unexpected tIDENTIFIER, expecting ')'
31
+ ... am "; _erbout.concat(( @a ruby ).to_s); _erbout.concat " te...
32
+ ... ^
33
+
34
+ -- hieradata/syntax.yaml:
35
+ block sequence entries are not allowed in this context at line 2 column 4
36
+
37
+ -- hieradata/syntax.json:
38
+ 757: unexpected token at '{
39
+
40
+ -- metadata_syntax/metadata.json:
41
+ Required field 'version' not found in metadata.json.
42
+ Duplicate dependencies on puppetlabs/nothing.
43
+ Deprecated field 'checksum' found.
44
+ Summary exceeds 144 characters.
45
+
46
+ -- librarian_syntax/Puppetfile:
47
+ (eval):3: syntax error, unexpected ':', expecting end-of-input
48
+ librarian: 'puppet'
49
+ ^
50
+
51
+ The following files have warnings:
52
+ -- manifests/style_lint.pp:
53
+ double quoted string containing no variables at line 2, column 8
54
+ indentation of => is not properly aligned at line 2, column 5
55
+
56
+ -- manifests/style_parser.pp:
57
+ Unrecognized escape sequence '\[' at 2:77
58
+ Unrecognized escape sequence '\]' at 2:77
59
+ double quoted string containing no variables at line 2, column 45
60
+
61
+ -- lib/style.rb:
62
+ 1:1: W: Useless assignment to variable - `hash`.
63
+ 1:10: C: Use the new Ruby 1.9 hash syntax.
64
+ 2:1: C: Do not introduce global variables.
65
+ 3:6: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
66
+ [7]:Attribute: Issue#foobarbaz is a writable attribute [https://github.com/troessner/reek/blob/master/docs/Attribute.md]
67
+ [6]:IrresponsibleModule: Issue has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md]
68
+
69
+ -- templates/style.erb:
70
+ 3: already initialized constant TEMPLATE
71
+ 2: previous definition of TEMPLATE was here
72
+
73
+ -- hieradata/style.yaml:
74
+ Values missing in key 'value'.
75
+
76
+ -- metadata_style/metadata.json:
77
+ License identifier 'Imaginary' is not in the SPDX list: http://spdx.org/licenses/
78
+
79
+ -- librarian_style/Puppetfile:
80
+ 2:3: C: Align the parameters of a method call if they span more than one line.
81
+ 5:13: C: Use the new Ruby 1.9 hash syntax.
82
+
83
+ The following files have no errors or warnings:
84
+ -- manifests/good.pp
85
+ -- templates/good.epp
86
+ -- lib/good.rb
87
+ -- templates/good.erb
88
+ -- hieradata/good.yaml
89
+ -- hieradata/good.json
90
+ -- metadata_good/metadata.json
91
+ -- librarian_good/Puppetfile
92
+
93
+ The following files have unrecognized formats and therefore were not processed:
94
+ -- foobarbaz
95
+ ```
96
+
97
+ ### Why not Puppetlabs Spec Helper?
98
+ - Puppetlabs Spec Helper is a larger and varied gem with a different overall emphasis for its features. Puppet Check is a lean and efficient gem solely for comprehensive Puppet code and data validation.
99
+ - Puppetlabs Spec Helper performs fewer types of checks.
100
+ - Puppetlabs Spec Helper has extra layers of gems in between it and the gems executing the checks.
101
+ - Puppetlabs Spec Helper does not allow interfacing through it to the gems executing the checks.
102
+ - Puppetlabs Spec Helper has no CLI.
103
+
104
+ ## Usage
105
+ Puppet Check requires `ruby >= 1.9.3`, `puppet >= 3.2`, and `puppet-lint >= 1.1.0`. All other dependencies should be fine with various versions. Puppet Check can be used either with a CLI or Rake tasks.
106
+
107
+ ### CLI
108
+ ```
109
+ usage: puppet-check [options] paths
110
+ -f, --future Enable future parser
111
+ -s, --style Enable style checks
112
+ --puppet-lint arg_one,arg_two
113
+ Arguments for PuppetLint ignored checks
114
+ --rubocop arg_one,arg_two Arguments for Rubocop disabled cops
115
+ ```
116
+
117
+ The command line interface enables the ability to select the Puppet future parser, additional style checks besides the syntax checks, and to specify PuppetLint and Rubocop checks to ignore. It should be noted that your `.puppet-lint.rc`, `.rubocop.yml`, and `*.reek` files should still be automatically respected by the individual style checkers if you prefer those to a simplified CLI.
118
+
119
+ ```
120
+ Example:
121
+ puppet-check -s --puppet-lint no-hard_tabs-check,no-80chars-check --rubocop Metrics/LineLength,Style/Encoding path/to/code_and_data
122
+ ```
123
+
124
+ ### Rake
125
+ Interfacing with Puppet-Check via `rake` requires a `require puppet-check/tasks` in your Rakefile. This generates the following `rake` command:
126
+
127
+ ```
128
+ rake puppetcheck:file # Execute Puppet-Check file checks
129
+ ```
130
+
131
+ You can add style checks to and select the future parser for the `rake` by adding the following after the require:
132
+
133
+ ```ruby
134
+ PuppetCheck.style_check = true
135
+ PuppetCheck.future_parser = true
136
+ ```
137
+
138
+ The style checks from within `rake` are directly interfaced to `puppet-lint`, `rubocop`, and `reek`. This means that all arguments and options should be specified from within your `.puppet-lint.rc`, `.rubocop.yml`, and `*.reek`. The capability to pass arguments and options to them from within the `Rakefile` task block will be considered for future versions.
139
+
140
+ ### Optional Checks
141
+ `reek` will automatically be installed as a dependency and checks enabled during style checks if your Ruby version is `>= 2.1`. `rspec`, `rspec-puppet`, and `beaker` are forthcoming purely optional dependency checks.
142
+
143
+ ## Contributing
144
+ Code should pass all spec tests. New features should involve new spec tests. Adherence to Rubocop and Reek is expected where not overly onerous or where the check is of dubious cost/benefit.
145
+
146
+ A `Dockerfile` is provided for easy `rake` testing. A `Vagrantfile` is provided for easy gem building, installation, and post-installation testing.
147
+
148
+ Please consult the `CHANGELOG` for the current development roadmap.
@@ -0,0 +1,24 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'rubocop/rake_task'
3
+ require 'reek/rake/task' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
4
+
5
+ task default: [:rubocop, :reek, :unit, :integration]
6
+
7
+ RuboCop::RakeTask.new(:rubocop) do |task|
8
+ task.formatters = ['simple']
9
+ task.fail_on_error = false
10
+ end
11
+
12
+ if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
13
+ Reek::Rake::Task.new do |task|
14
+ task.fail_on_error = false
15
+ end
16
+ end
17
+
18
+ RSpec::Core::RakeTask.new(:unit) do |task|
19
+ task.pattern = 'spec/{puppet-check_spec.rb, puppet-check/*_spec.rb}'
20
+ end
21
+
22
+ RSpec::Core::RakeTask.new(:integration) do |task|
23
+ task.pattern = 'spec/integration/*_spec.rb'
24
+ end
@@ -0,0 +1,77 @@
1
+ # PuppetCheck: testing gem build, install, and execution
2
+
3
+ # -*- mode: ruby -*-
4
+ # vi: set ft=ruby :
5
+
6
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
7
+ # configures the configuration version (we support older styles for
8
+ # backwards compatibility). Please don't change it unless you know what
9
+ # you're doing.
10
+ Vagrant.configure(2) do |config|
11
+ # The most common configuration options are documented and commented below.
12
+ # For a complete reference, please see the online documentation at
13
+ # https://docs.vagrantup.com.
14
+
15
+ # Every Vagrant development environment requires a box. You can search for
16
+ # boxes at https://atlas.hashicorp.com/search.
17
+ config.vm.box = 'ubuntu/trusty64'
18
+
19
+ # Disable automatic box update checking. If you disable this, then
20
+ # boxes will only be checked for updates when the user runs
21
+ # `vagrant box outdated`. This is not recommended.
22
+ # config.vm.box_check_update = false
23
+
24
+ # Create a forwarded port mapping which allows access to a specific port
25
+ # within the machine from a port on the host machine. In the example below,
26
+ # accessing "localhost:8080" will access port 80 on the guest machine.
27
+ # config.vm.network "forwarded_port", guest: 80, host: 8080
28
+
29
+ # Create a private network, which allows host-only access to the machine
30
+ # using a specific IP.
31
+ # config.vm.network "private_network", ip: "192.168.33.10"
32
+
33
+ # Create a public network, which generally matched to bridged network.
34
+ # Bridged networks make the machine appear as another physical device on
35
+ # your network.
36
+ # config.vm.network "public_network"
37
+
38
+ # Share an additional folder to the guest VM. The first argument is
39
+ # the path on the host to the actual folder. The second argument is
40
+ # the path on the guest to mount the folder. And the optional third
41
+ # argument is a set of non-required options.
42
+ # config.vm.synced_folder "../data", "/vagrant_data"
43
+
44
+ # Provider-specific configuration so you can fine-tune various
45
+ # backing providers for Vagrant. These expose provider-specific options.
46
+ # Example for VirtualBox:
47
+ #
48
+ # config.vm.provider "virtualbox" do |vb|
49
+ # # Display the VirtualBox GUI when booting the machine
50
+ # vb.gui = true
51
+ #
52
+ # # Customize the amount of memory on the VM:
53
+ # vb.memory = "1024"
54
+ # end
55
+ #
56
+ # View the documentation for the provider you are using for more
57
+ # information on available options.
58
+
59
+ # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
60
+ # such as FTP and Heroku are also available. See the documentation at
61
+ # https://docs.vagrantup.com/v2/push/atlas.html for more information.
62
+ # config.push.define "atlas" do |push|
63
+ # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
64
+ # end
65
+
66
+ # Enable provisioning with a shell script. Additional provisioners such as
67
+ # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
68
+ # documentation for more information about their specific syntax and use.
69
+ config.vm.provision 'shell', inline: <<-SHELL
70
+ cd /vagrant
71
+ sudo apt-get install git -y
72
+ sudo gem build puppet-check.gemspec
73
+ sudo gem install --no-rdoc --no-ri puppet-check*.gem
74
+ sudo /usr/local/bin/puppet-check -s spec/fixtures
75
+ sudo rm -f puppet-check*.gem
76
+ SHELL
77
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/puppet-check/cli'
4
+
5
+ exit PuppetCheck::CLI.run(ARGV)
@@ -0,0 +1,3 @@
1
+ ---
2
+ exclude_paths:
3
+ - spec/fixtures
@@ -0,0 +1,86 @@
1
+ require_relative 'puppet-check/puppet_parser'
2
+ require_relative 'puppet-check/ruby_parser'
3
+ require_relative 'puppet-check/data_parser'
4
+
5
+ # interfaces from CLI/tasks and to individual parsers
6
+ class PuppetCheck
7
+ # initialize future parser and style check bools
8
+ @future_parser = false
9
+ @style_check = false
10
+
11
+ # initialize diagnostic output arrays
12
+ @error_files = []
13
+ @warning_files = []
14
+ @clean_files = []
15
+ @ignored_files = []
16
+
17
+ # initialize style arg arrays
18
+ @puppetlint_args = []
19
+ @rubocop_args = []
20
+
21
+ # let the parser methods read user options and append to the file arrays; let CLI and tasks write to user options
22
+ class << self
23
+ attr_accessor :future_parser, :style_check, :error_files, :warning_files, :clean_files, :ignored_files, :puppetlint_args, :rubocop_args
24
+ end
25
+
26
+ # main runner for PuppetCheck
27
+ def run(paths)
28
+ # grab all of the files to be processed
29
+ files = parse_paths(paths)
30
+
31
+ # parse the files
32
+ execute_parsers(files)
33
+
34
+ # output the diagnostic results
35
+ self.class.output_results
36
+
37
+ # exit code
38
+ self.class.error_files.empty? ? 0 : 1
39
+ end
40
+
41
+ # parse the paths and return the array of files
42
+ def parse_paths(paths)
43
+ files = []
44
+
45
+ # traverse the unique paths, return all files, and replace // with /
46
+ paths.uniq.each do |path|
47
+ if File.directory?(path)
48
+ files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file? subpath })
49
+ elsif File.file?(path)
50
+ files.push(path)
51
+ end
52
+ end
53
+
54
+ # check that at least one file was found, remove double slashes, and return unique files
55
+ raise "No files found in supplied paths #{paths.join(', ')}." if files.empty?
56
+ files.map! { |file| file.gsub('//', '/') }
57
+ files.uniq
58
+ end
59
+
60
+ # categorize and pass the files out to the parsers to determine their status
61
+ def execute_parsers(files)
62
+ PuppetParser.manifest(files.select { |file| File.extname(file) == '.pp' })
63
+ files.reject! { |file| File.extname(file) == '.pp' }
64
+ PuppetParser.template(files.select { |file| File.extname(file) == '.epp' })
65
+ files.reject! { |file| File.extname(file) == '.epp' }
66
+ RubyParser.ruby(files.select { |file| File.extname(file) == '.rb' })
67
+ files.reject! { |file| File.extname(file) == '.rb' }
68
+ RubyParser.template(files.select { |file| File.extname(file) == '.erb' })
69
+ files.reject! { |file| File.extname(file) == '.erb' }
70
+ DataParser.yaml(files.select { |file| file =~ /.*\.ya?ml$/ })
71
+ files.reject! { |file| file =~ /.*\.ya?ml$/ }
72
+ DataParser.json(files.select { |file| File.extname(file) == '.json' })
73
+ files.reject! { |file| File.extname(file) == '.json' }
74
+ RubyParser.librarian(files.select { |file| file =~ /.*(Puppet|Module|Rake|Gem)file$/ })
75
+ files.reject! { |file| file =~ /.*(?:Puppet|Module|Rake|Gem)file$/ }
76
+ files.each { |file| self.class.ignored_files.push("-- #{file}") }
77
+ end
78
+
79
+ # output the results for the files that were requested to be checked
80
+ def self.output_results
81
+ puts "\033[31mThe following files have errors:\033[0m", error_files.join("\n\n") unless error_files.empty?
82
+ puts "\n\033[33mThe following files have warnings:\033[0m", warning_files.join("\n\n") unless warning_files.empty?
83
+ puts "\n\033[32mThe following files have no errors or warnings:\033[0m", clean_files unless clean_files.empty?
84
+ puts "\n\033[34mThe following files have unrecognized formats and therefore were not processed:\033[0m", ignored_files unless ignored_files.empty?
85
+ end
86
+ end