puppet-lint 0.4.0.pre1 → 1.0.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.
- data/.travis.yml +3 -4
 - data/Gemfile +2 -5
 - data/README.md +2 -149
 - data/Rakefile +0 -5
 - data/lib/puppet-lint.rb +74 -20
 - data/lib/puppet-lint/bin.rb +20 -85
 - data/lib/puppet-lint/checkplugin.rb +158 -12
 - data/lib/puppet-lint/checks.rb +39 -222
 - data/lib/puppet-lint/configuration.rb +12 -31
 - data/lib/puppet-lint/data.rb +329 -0
 - data/lib/puppet-lint/lexer.rb +37 -30
 - data/lib/puppet-lint/lexer/token.rb +14 -16
 - data/lib/puppet-lint/monkeypatches/string_prepend.rb +6 -0
 - data/lib/puppet-lint/optparser.rb +105 -0
 - data/lib/puppet-lint/plugins.rb +28 -9
 - data/lib/puppet-lint/plugins/check_classes.rb +162 -238
 - data/lib/puppet-lint/plugins/check_comments.rb +40 -25
 - data/lib/puppet-lint/plugins/check_conditionals.rb +16 -20
 - data/lib/puppet-lint/plugins/check_documentation.rb +14 -20
 - data/lib/puppet-lint/plugins/check_nodes.rb +23 -0
 - data/lib/puppet-lint/plugins/check_resources.rb +127 -141
 - data/lib/puppet-lint/plugins/check_strings.rb +133 -107
 - data/lib/puppet-lint/plugins/check_variables.rb +11 -11
 - data/lib/puppet-lint/plugins/check_whitespace.rb +86 -92
 - data/lib/puppet-lint/tasks/puppet-lint.rb +17 -1
 - data/lib/puppet-lint/version.rb +1 -1
 - data/puppet-lint.gemspec +4 -2
 - data/spec/fixtures/test/manifests/ignore.pp +1 -0
 - data/spec/fixtures/test/manifests/ignore_reason.pp +1 -0
 - data/spec/puppet-lint/bin_spec.rb +104 -84
 - data/spec/puppet-lint/configuration_spec.rb +19 -19
 - data/spec/puppet-lint/ignore_overrides_spec.rb +97 -0
 - data/spec/puppet-lint/lexer/token_spec.rb +9 -9
 - data/spec/puppet-lint/lexer_spec.rb +352 -325
 - data/spec/puppet-lint/plugins/check_classes/autoloader_layout_spec.rb +77 -23
 - data/spec/puppet-lint/plugins/check_classes/class_inherits_from_params_class_spec.rb +14 -12
 - data/spec/puppet-lint/plugins/check_classes/inherits_across_namespaces_spec.rb +18 -14
 - data/spec/puppet-lint/plugins/check_classes/names_containing_dash_spec.rb +30 -30
 - data/spec/puppet-lint/plugins/check_classes/nested_classes_or_defines_spec.rb +31 -26
 - data/spec/puppet-lint/plugins/check_classes/parameter_order_spec.rb +34 -28
 - data/spec/puppet-lint/plugins/check_classes/right_to_left_relationship_spec.rb +14 -12
 - data/spec/puppet-lint/plugins/check_classes/variable_scope_spec.rb +74 -30
 - data/spec/puppet-lint/plugins/check_comments/slash_comments_spec.rb +27 -20
 - data/spec/puppet-lint/plugins/check_comments/star_comments_spec.rb +78 -13
 - data/spec/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +17 -12
 - data/spec/puppet-lint/plugins/check_conditionals/selector_inside_resource_spec.rb +13 -10
 - data/spec/puppet-lint/plugins/check_documentation/documentation_spec.rb +21 -16
 - data/spec/puppet-lint/plugins/check_nodes/unquoted_node_name_spec.rb +69 -0
 - data/spec/puppet-lint/plugins/check_resources/duplicate_params_spec.rb +42 -38
 - data/spec/puppet-lint/plugins/check_resources/ensure_first_param_spec.rb +22 -10
 - data/spec/puppet-lint/plugins/check_resources/ensure_not_symlink_target_spec.rb +81 -18
 - data/spec/puppet-lint/plugins/check_resources/file_mode_spec.rb +69 -112
 - data/spec/puppet-lint/plugins/check_resources/unquoted_file_mode_spec.rb +27 -20
 - data/spec/puppet-lint/plugins/check_resources/unquoted_resource_title_spec.rb +177 -171
 - data/spec/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +165 -88
 - data/spec/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +97 -22
 - data/spec/puppet-lint/plugins/check_strings/puppet_url_without_modules_spec.rb +25 -0
 - data/spec/puppet-lint/plugins/check_strings/quoted_booleans_spec.rb +97 -111
 - data/spec/puppet-lint/plugins/check_strings/single_quote_string_with_variables_spec.rb +10 -9
 - data/spec/puppet-lint/plugins/check_strings/variables_not_enclosed_spec.rb +53 -53
 - data/spec/puppet-lint/plugins/check_variables/variable_contains_dash_spec.rb +26 -14
 - data/spec/puppet-lint/plugins/check_whitespace/2sp_soft_tabs_spec.rb +10 -9
 - data/spec/puppet-lint/plugins/check_whitespace/80chars_spec.rb +31 -15
 - data/spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb +340 -322
 - data/spec/puppet-lint/plugins/check_whitespace/hard_tabs_spec.rb +30 -23
 - data/spec/puppet-lint/plugins/check_whitespace/trailing_whitespace_spec.rb +42 -41
 - data/spec/puppet-lint_spec.rb +3 -3
 - data/spec/spec_helper.rb +109 -116
 - metadata +109 -50
 - data/spec/puppet-lint/plugins/check_classes/class_parameter_defaults_spec.rb +0 -60
 
| 
         @@ -1,14 +1,29 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'puppet-lint'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'puppet-lint/optparser'
         
     | 
| 
       2 
3 
     | 
    
         
             
            require 'rake'
         
     | 
| 
       3 
4 
     | 
    
         
             
            require 'rake/tasklib'
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            class PuppetLint
         
     | 
| 
      
 7 
     | 
    
         
            +
              # Public: A Rake task that can be loaded and used with everything you need.
         
     | 
| 
      
 8 
     | 
    
         
            +
              #
         
     | 
| 
      
 9 
     | 
    
         
            +
              # Examples
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              #   require 'puppet-lint'
         
     | 
| 
      
 12 
     | 
    
         
            +
              #   PuppetLint::RakeTask.new
         
     | 
| 
       6 
13 
     | 
    
         
             
              class RakeTask < ::Rake::TaskLib
         
     | 
| 
      
 14 
     | 
    
         
            +
                # Public: Initialise a new PuppetLint::RakeTask.
         
     | 
| 
      
 15 
     | 
    
         
            +
                #
         
     | 
| 
      
 16 
     | 
    
         
            +
                # args - Not used.
         
     | 
| 
      
 17 
     | 
    
         
            +
                #
         
     | 
| 
      
 18 
     | 
    
         
            +
                # Example
         
     | 
| 
      
 19 
     | 
    
         
            +
                #
         
     | 
| 
      
 20 
     | 
    
         
            +
                #   PuppetLint::RakeTask.new
         
     | 
| 
       7 
21 
     | 
    
         
             
                def initialize(*args)
         
     | 
| 
       8 
22 
     | 
    
         
             
                  desc 'Run puppet-lint'
         
     | 
| 
       9 
23 
     | 
    
         | 
| 
       10 
24 
     | 
    
         
             
                  task :lint do
         
     | 
| 
       11 
25 
     | 
    
         
             
                    PuppetLint.configuration.with_filename = true
         
     | 
| 
      
 26 
     | 
    
         
            +
                    PuppetLint::OptParser.build
         
     | 
| 
       12 
27 
     | 
    
         | 
| 
       13 
28 
     | 
    
         
             
                    RakeFileUtils.send(:verbose, true) do
         
     | 
| 
       14 
29 
     | 
    
         
             
                      linter = PuppetLint.new
         
     | 
| 
         @@ -21,8 +36,9 @@ class PuppetLint 
     | 
|
| 
       21 
36 
     | 
    
         
             
                      matched_files.to_a.each do |puppet_file|
         
     | 
| 
       22 
37 
     | 
    
         
             
                        linter.file = puppet_file
         
     | 
| 
       23 
38 
     | 
    
         
             
                        linter.run
         
     | 
| 
      
 39 
     | 
    
         
            +
                        linter.print_problems
         
     | 
| 
       24 
40 
     | 
    
         
             
                      end
         
     | 
| 
       25 
     | 
    
         
            -
                       
     | 
| 
      
 41 
     | 
    
         
            +
                      abort if linter.errors? || (
         
     | 
| 
       26 
42 
     | 
    
         
             
                        linter.warnings? && PuppetLint.configuration.fail_on_warnings
         
     | 
| 
       27 
43 
     | 
    
         
             
                      )
         
     | 
| 
       28 
44 
     | 
    
         
             
                    end
         
     | 
    
        data/lib/puppet-lint/version.rb
    CHANGED
    
    
    
        data/puppet-lint.gemspec
    CHANGED
    
    | 
         @@ -14,8 +14,10 @@ Gem::Specification.new do |s| 
     | 
|
| 
       14 
14 
     | 
    
         
             
              s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              s.add_development_dependency ' 
     | 
| 
       18 
     | 
    
         
            -
              s.add_development_dependency ' 
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_development_dependency 'rake', '~> 10.0'
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_development_dependency 'rspec', '~> 3.0'
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_development_dependency 'rspec-its', '~> 1.0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_development_dependency 'rspec-collection_matchers', '~> 1.0'
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
              s.authors = ['Tim Sharpe']
         
     | 
| 
       21 
23 
     | 
    
         
             
              s.email = 'tim@sharpe.id.au'
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "test" # lint:ignore:double_quoted_strings
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "test" # lint:ignore:double_quoted_strings for a good reason
         
     | 
| 
         @@ -38,20 +38,20 @@ describe PuppetLint::Bin do 
     | 
|
| 
       38 
38 
     | 
    
         
             
              context 'when running normally' do
         
     | 
| 
       39 
39 
     | 
    
         
             
                let(:args) { 'spec/fixtures/test/manifests/init.pp' }
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
      
 41 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
       42 
42 
     | 
    
         
             
              end
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
              context 'when running without arguments' do
         
     | 
| 
       45 
45 
     | 
    
         
             
                let(:args) { [] }
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
      
 47 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
       48 
48 
     | 
    
         
             
              end
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
50 
     | 
    
         
             
              context 'when asked to display version' do
         
     | 
| 
       51 
51 
     | 
    
         
             
                let(:args) { '--version' }
         
     | 
| 
       52 
52 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       54 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 53 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 54 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq("puppet-lint #{PuppetLint::VERSION}") }
         
     | 
| 
       55 
55 
     | 
    
         
             
              end
         
     | 
| 
       56 
56 
     | 
    
         | 
| 
       57 
57 
     | 
    
         
             
              context 'when passed multiple files' do
         
     | 
| 
         @@ -60,18 +60,18 @@ describe PuppetLint::Bin do 
     | 
|
| 
       60 
60 
     | 
    
         
             
                  'spec/fixtures/test/manifests/fail.pp',
         
     | 
| 
       61 
61 
     | 
    
         
             
                ] }
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       64 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
       65 
     | 
    
         
            -
                   
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
       67 
     | 
    
         
            -
                ].join("\n") }
         
     | 
| 
      
 63 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 64 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq([
         
     | 
| 
      
 65 
     | 
    
         
            +
                  "#{args[0]} - WARNING: optional parameter listed before required parameter on line 2",
         
     | 
| 
      
 66 
     | 
    
         
            +
                  "#{args[1]} - ERROR: test::foo not in autoload module layout on line 2",
         
     | 
| 
      
 67 
     | 
    
         
            +
                ].join("\n")) }
         
     | 
| 
       68 
68 
     | 
    
         
             
              end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
              context 'when passed a malformed file' do
         
     | 
| 
       71 
71 
     | 
    
         
             
                let(:args) { 'spec/fixtures/test/manifests/malformed.pp' }
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       74 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 73 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 74 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq('ERROR: Syntax error (try running `puppet parser validate <file>`) on line 1') }
         
     | 
| 
       75 
75 
     | 
    
         
             
              end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
77 
     | 
    
         
             
              context 'when limited to errors only' do
         
     | 
| 
         @@ -81,33 +81,46 @@ describe PuppetLint::Bin do 
     | 
|
| 
       81 
81 
     | 
    
         
             
                  'spec/fixtures/test/manifests/fail.pp',
         
     | 
| 
       82 
82 
     | 
    
         
             
                ] }
         
     | 
| 
       83 
83 
     | 
    
         | 
| 
       84 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       85 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 84 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 85 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/^#{args.last} - ERROR/) }
         
     | 
| 
       86 
86 
     | 
    
         
             
              end
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
              context 'when limited to  
     | 
| 
      
 88 
     | 
    
         
            +
              context 'when limited to warnings only' do
         
     | 
| 
       89 
89 
     | 
    
         
             
                let(:args) { [
         
     | 
| 
       90 
90 
     | 
    
         
             
                  '--error-level', 'warning',
         
     | 
| 
       91 
91 
     | 
    
         
             
                  'spec/fixtures/test/manifests/warning.pp',
         
     | 
| 
       92 
92 
     | 
    
         
             
                  'spec/fixtures/test/manifests/fail.pp',
         
     | 
| 
       93 
93 
     | 
    
         
             
                ] }
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       96 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 95 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 96 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/WARNING/) }
         
     | 
| 
      
 97 
     | 
    
         
            +
                its(:stdout) { is_expected.to_not match(/ERROR/) }
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              context 'when specifying a specific check to run' do
         
     | 
| 
      
 101 
     | 
    
         
            +
                let(:args) { [
         
     | 
| 
      
 102 
     | 
    
         
            +
                  '--only-check', 'parameter_order',
         
     | 
| 
      
 103 
     | 
    
         
            +
                  'spec/fixtures/test/manifests/warning.pp',
         
     | 
| 
      
 104 
     | 
    
         
            +
                  'spec/fixtures/test/manifests/fail.pp',
         
     | 
| 
      
 105 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 108 
     | 
    
         
            +
                its(:stdout) { is_expected.to_not match(/ERROR/) }
         
     | 
| 
      
 109 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/WARNING/) }
         
     | 
| 
       97 
110 
     | 
    
         
             
              end
         
     | 
| 
       98 
111 
     | 
    
         | 
| 
       99 
112 
     | 
    
         
             
              context 'when asked to display filenames ' do
         
     | 
| 
       100 
113 
     | 
    
         
             
                let(:args) { ['--with-filename', 'spec/fixtures/test/manifests/fail.pp'] }
         
     | 
| 
       101 
114 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       103 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 115 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 116 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(%r{^spec/fixtures/test/manifests/fail\.pp -}) }
         
     | 
| 
       104 
117 
     | 
    
         
             
              end
         
     | 
| 
       105 
118 
     | 
    
         | 
| 
       106 
119 
     | 
    
         
             
              context 'when not asked to fail on warnings' do
         
     | 
| 
       107 
120 
     | 
    
         
             
                let(:args) { ['spec/fixtures/test/manifests/warning.pp'] }
         
     | 
| 
       108 
121 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       110 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 122 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 123 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/optional parameter/) }
         
     | 
| 
       111 
124 
     | 
    
         
             
              end
         
     | 
| 
       112 
125 
     | 
    
         | 
| 
       113 
126 
     | 
    
         
             
              context 'when asked to provide context to problems' do
         
     | 
| 
         @@ -116,13 +129,13 @@ describe PuppetLint::Bin do 
     | 
|
| 
       116 
129 
     | 
    
         
             
                  'spec/fixtures/test/manifests/warning.pp',
         
     | 
| 
       117 
130 
     | 
    
         
             
                ] }
         
     | 
| 
       118 
131 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       120 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 132 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 133 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq([
         
     | 
| 
       121 
134 
     | 
    
         
             
                  'WARNING: optional parameter listed before required parameter on line 2',
         
     | 
| 
       122 
135 
     | 
    
         
             
                  '',
         
     | 
| 
       123 
136 
     | 
    
         
             
                  "  define test::warning($foo='bar', $baz) { }",
         
     | 
| 
       124 
137 
     | 
    
         
             
                  '                                   ^',
         
     | 
| 
       125 
     | 
    
         
            -
                ].join("\n")
         
     | 
| 
      
 138 
     | 
    
         
            +
                ].join("\n"))
         
     | 
| 
       126 
139 
     | 
    
         
             
                }
         
     | 
| 
       127 
140 
     | 
    
         
             
              end
         
     | 
| 
       128 
141 
     | 
    
         | 
| 
         @@ -132,29 +145,29 @@ describe PuppetLint::Bin do 
     | 
|
| 
       132 
145 
     | 
    
         
             
                  'spec/fixtures/test/manifests/warning.pp',
         
     | 
| 
       133 
146 
     | 
    
         
             
                ] }
         
     | 
| 
       134 
147 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       136 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 148 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 149 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/optional parameter/) }
         
     | 
| 
       137 
150 
     | 
    
         
             
              end
         
     | 
| 
       138 
151 
     | 
    
         | 
| 
       139 
152 
     | 
    
         
             
              context 'when used with an invalid option' do
         
     | 
| 
       140 
153 
     | 
    
         
             
                let(:args) { '--foo-bar-baz' }
         
     | 
| 
       141 
154 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       143 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 155 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 156 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/invalid option/) }
         
     | 
| 
       144 
157 
     | 
    
         
             
              end
         
     | 
| 
       145 
158 
     | 
    
         | 
| 
       146 
159 
     | 
    
         
             
              context 'when passed a file that does not exist' do
         
     | 
| 
       147 
160 
     | 
    
         
             
                let(:args) { 'spec/fixtures/test/manifests/enoent.pp' }
         
     | 
| 
       148 
161 
     | 
    
         | 
| 
       149 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       150 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 162 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 163 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/specified file does not exist/) }
         
     | 
| 
       151 
164 
     | 
    
         
             
              end
         
     | 
| 
       152 
165 
     | 
    
         | 
| 
       153 
166 
     | 
    
         
             
              context 'when passed a directory' do
         
     | 
| 
       154 
167 
     | 
    
         
             
                let(:args) { 'spec/fixtures/' }
         
     | 
| 
       155 
168 
     | 
    
         | 
| 
       156 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       157 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 169 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 170 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/ERROR/) }
         
     | 
| 
       158 
171 
     | 
    
         
             
              end
         
     | 
| 
       159 
172 
     | 
    
         | 
| 
       160 
173 
     | 
    
         
             
              context 'when disabling a check' do
         
     | 
| 
         @@ -163,8 +176,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       163 
176 
     | 
    
         
             
                  'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       164 
177 
     | 
    
         
             
                ] }
         
     | 
| 
       165 
178 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
                its(:exitstatus) {  
     | 
| 
       167 
     | 
    
         
            -
                its(:stdout) {  
     | 
| 
      
 179 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 180 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq("") }
         
     | 
| 
       168 
181 
     | 
    
         
             
              end
         
     | 
| 
       169 
182 
     | 
    
         | 
| 
       170 
183 
     | 
    
         
             
              context 'when changing the log format' do
         
     | 
| 
         @@ -174,8 +187,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       174 
187 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       175 
188 
     | 
    
         
             
                  ] }
         
     | 
| 
       176 
189 
     | 
    
         | 
| 
       177 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       178 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 190 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 191 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('fail.pp') }
         
     | 
| 
       179 
192 
     | 
    
         
             
                end
         
     | 
| 
       180 
193 
     | 
    
         | 
| 
       181 
194 
     | 
    
         
             
                context 'to print %{path}' do
         
     | 
| 
         @@ -184,8 +197,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       184 
197 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       185 
198 
     | 
    
         
             
                  ] }
         
     | 
| 
       186 
199 
     | 
    
         | 
| 
       187 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       188 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 200 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 201 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('spec/fixtures/test/manifests/fail.pp') }
         
     | 
| 
       189 
202 
     | 
    
         
             
                end
         
     | 
| 
       190 
203 
     | 
    
         | 
| 
       191 
204 
     | 
    
         
             
                context 'to print %{fullpath}' do
         
     | 
| 
         @@ -194,9 +207,9 @@ describe PuppetLint::Bin do 
     | 
|
| 
       194 
207 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       195 
208 
     | 
    
         
             
                  ] }
         
     | 
| 
       196 
209 
     | 
    
         | 
| 
       197 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
      
 210 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
       198 
211 
     | 
    
         
             
                  its(:stdout) {
         
     | 
| 
       199 
     | 
    
         
            -
                     
     | 
| 
      
 212 
     | 
    
         
            +
                    is_expected.to match(%r{^/.+/spec/fixtures/test/manifests/fail\.pp$})
         
     | 
| 
       200 
213 
     | 
    
         
             
                  }
         
     | 
| 
       201 
214 
     | 
    
         
             
                end
         
     | 
| 
       202 
215 
     | 
    
         | 
| 
         @@ -206,8 +219,19 @@ describe PuppetLint::Bin do 
     | 
|
| 
       206 
219 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       207 
220 
     | 
    
         
             
                  ] }
         
     | 
| 
       208 
221 
     | 
    
         | 
| 
       209 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       210 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 222 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 223 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('2') }
         
     | 
| 
      
 224 
     | 
    
         
            +
                  its(:stderr) { is_expected.to eq('DEPRECATION: Please use %{line} instead of %{linenumber}') }
         
     | 
| 
      
 225 
     | 
    
         
            +
                end
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                context 'to print %{line}' do
         
     | 
| 
      
 228 
     | 
    
         
            +
                  let(:args) { [
         
     | 
| 
      
 229 
     | 
    
         
            +
                    '--log-format', '%{line}',
         
     | 
| 
      
 230 
     | 
    
         
            +
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
      
 231 
     | 
    
         
            +
                  ] }
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 234 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('2') }
         
     | 
| 
       211 
235 
     | 
    
         
             
                end
         
     | 
| 
       212 
236 
     | 
    
         | 
| 
       213 
237 
     | 
    
         
             
                context 'to print %{kind}' do
         
     | 
| 
         @@ -216,8 +240,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       216 
240 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       217 
241 
     | 
    
         
             
                  ] }
         
     | 
| 
       218 
242 
     | 
    
         | 
| 
       219 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       220 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 243 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 244 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('error') }
         
     | 
| 
       221 
245 
     | 
    
         
             
                end
         
     | 
| 
       222 
246 
     | 
    
         | 
| 
       223 
247 
     | 
    
         
             
                context 'to print %{KIND}' do
         
     | 
| 
         @@ -226,8 +250,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       226 
250 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       227 
251 
     | 
    
         
             
                  ] }
         
     | 
| 
       228 
252 
     | 
    
         | 
| 
       229 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       230 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 253 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 254 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('ERROR') }
         
     | 
| 
       231 
255 
     | 
    
         
             
                end
         
     | 
| 
       232 
256 
     | 
    
         | 
| 
       233 
257 
     | 
    
         
             
                context 'to print %{check}' do
         
     | 
| 
         @@ -236,8 +260,8 @@ describe PuppetLint::Bin do 
     | 
|
| 
       236 
260 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       237 
261 
     | 
    
         
             
                  ] }
         
     | 
| 
       238 
262 
     | 
    
         | 
| 
       239 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       240 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 263 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 264 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('autoloader_layout') }
         
     | 
| 
       241 
265 
     | 
    
         
             
                end
         
     | 
| 
       242 
266 
     | 
    
         | 
| 
       243 
267 
     | 
    
         
             
                context 'to print %{message}' do
         
     | 
| 
         @@ -246,44 +270,40 @@ describe PuppetLint::Bin do 
     | 
|
| 
       246 
270 
     | 
    
         
             
                    'spec/fixtures/test/manifests/fail.pp'
         
     | 
| 
       247 
271 
     | 
    
         
             
                  ] }
         
     | 
| 
       248 
272 
     | 
    
         | 
| 
       249 
     | 
    
         
            -
                  its(:exitstatus) {  
     | 
| 
       250 
     | 
    
         
            -
                  its(:stdout) {  
     | 
| 
      
 273 
     | 
    
         
            +
                  its(:exitstatus) { is_expected.to eq(1) }
         
     | 
| 
      
 274 
     | 
    
         
            +
                  its(:stdout) { is_expected.to eq('test::foo not in autoload module layout') }
         
     | 
| 
       251 
275 
     | 
    
         
             
                end
         
     | 
| 
      
 276 
     | 
    
         
            +
              end
         
     | 
| 
       252 
277 
     | 
    
         | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
             
     | 
| 
       262 
     | 
    
         
            -
             
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
             
     | 
| 
       265 
     | 
    
         
            -
             
     | 
| 
       266 
     | 
    
         
            -
             
     | 
| 
       267 
     | 
    
         
            -
             
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
             
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
     | 
    
         
            -
             
     | 
| 
       274 
     | 
    
         
            -
             
     | 
| 
       275 
     | 
    
         
            -
             
     | 
| 
       276 
     | 
    
         
            -
             
     | 
| 
       277 
     | 
    
         
            -
             
     | 
| 
       278 
     | 
    
         
            -
             
     | 
| 
       279 
     | 
    
         
            -
             
     | 
| 
       280 
     | 
    
         
            -
             
     | 
| 
       281 
     | 
    
         
            -
             
     | 
| 
       282 
     | 
    
         
            -
             
     | 
| 
       283 
     | 
    
         
            -
             
     | 
| 
       284 
     | 
    
         
            -
                    msg = 'Depreciated: Read .puppet-lintrc instead of .puppet-lint.rc'
         
     | 
| 
       285 
     | 
    
         
            -
                    subject.stderr.should == msg
         
     | 
| 
       286 
     | 
    
         
            -
                  end
         
     | 
| 
       287 
     | 
    
         
            -
                end
         
     | 
| 
      
 278 
     | 
    
         
            +
              context 'when hiding ignored problems' do
         
     | 
| 
      
 279 
     | 
    
         
            +
                let(:args) { [
         
     | 
| 
      
 280 
     | 
    
         
            +
                  'spec/fixtures/test/manifests/ignore.pp'
         
     | 
| 
      
 281 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 284 
     | 
    
         
            +
                its(:stdout) { is_expected.to_not match(/IGNORED/) }
         
     | 
| 
      
 285 
     | 
    
         
            +
              end
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
              context 'when showing ignored problems' do
         
     | 
| 
      
 288 
     | 
    
         
            +
                let(:args) { [
         
     | 
| 
      
 289 
     | 
    
         
            +
                  '--show-ignored',
         
     | 
| 
      
 290 
     | 
    
         
            +
                  'spec/fixtures/test/manifests/ignore.pp',
         
     | 
| 
      
 291 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 294 
     | 
    
         
            +
                its(:stdout) { is_expected.to match(/IGNORED/) }
         
     | 
| 
      
 295 
     | 
    
         
            +
              end
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
              context 'when showing ignored problems with a reason' do
         
     | 
| 
      
 298 
     | 
    
         
            +
                let(:args) { [
         
     | 
| 
      
 299 
     | 
    
         
            +
                  '--show-ignored',
         
     | 
| 
      
 300 
     | 
    
         
            +
                  'spec/fixtures/test/manifests/ignore_reason.pp',
         
     | 
| 
      
 301 
     | 
    
         
            +
                ] }
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
                its(:exitstatus) { is_expected.to eq(0) }
         
     | 
| 
      
 304 
     | 
    
         
            +
                its(:stdout) { is_expected.to eq([
         
     | 
| 
      
 305 
     | 
    
         
            +
                  "IGNORED: double quoted string containing no variables on line 1",
         
     | 
| 
      
 306 
     | 
    
         
            +
                  "  for a good reason",
         
     | 
| 
      
 307 
     | 
    
         
            +
                ].join("\n")) }
         
     | 
| 
       288 
308 
     | 
    
         
             
              end
         
     | 
| 
       289 
309 
     | 
    
         
             
            end
         
     | 
| 
         @@ -4,53 +4,53 @@ describe PuppetLint::Configuration do 
     | 
|
| 
       4 
4 
     | 
    
         
             
              subject { PuppetLint::Configuration.new }
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
              it 'should create check methods on the fly' do
         
     | 
| 
       7 
     | 
    
         
            -
                 
     | 
| 
       8 
     | 
    
         
            -
                subject.add_check('foo',  
     | 
| 
      
 7 
     | 
    
         
            +
                klass = Class.new
         
     | 
| 
      
 8 
     | 
    
         
            +
                subject.add_check('foo', klass)
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                subject. 
     | 
| 
       11 
     | 
    
         
            -
                subject. 
     | 
| 
       12 
     | 
    
         
            -
                subject. 
     | 
| 
       13 
     | 
    
         
            -
                subject. 
     | 
| 
      
 10 
     | 
    
         
            +
                expect(subject).to respond_to(:foo_enabled?)
         
     | 
| 
      
 11 
     | 
    
         
            +
                expect(subject).to_not respond_to(:bar_enabled?)
         
     | 
| 
      
 12 
     | 
    
         
            +
                expect(subject).to respond_to(:enable_foo)
         
     | 
| 
      
 13 
     | 
    
         
            +
                expect(subject).to respond_to(:disable_foo)
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                subject.disable_foo
         
     | 
| 
       16 
     | 
    
         
            -
                subject.settings['foo_disabled']. 
     | 
| 
       17 
     | 
    
         
            -
                subject.foo_enabled 
     | 
| 
      
 16 
     | 
    
         
            +
                expect(subject.settings['foo_disabled']).to be_truthy
         
     | 
| 
      
 17 
     | 
    
         
            +
                expect(subject.foo_enabled?).to be_falsey
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                subject.enable_foo
         
     | 
| 
       20 
     | 
    
         
            -
                subject.settings['foo_disabled']. 
     | 
| 
       21 
     | 
    
         
            -
                subject.foo_enabled 
     | 
| 
      
 20 
     | 
    
         
            +
                expect(subject.settings['foo_disabled']).to be_falsey
         
     | 
| 
      
 21 
     | 
    
         
            +
                expect(subject.foo_enabled?).to be_truthy
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              it 'should know what checks have been added' do
         
     | 
| 
       25 
     | 
    
         
            -
                 
     | 
| 
       26 
     | 
    
         
            -
                subject.add_check('foo',  
     | 
| 
       27 
     | 
    
         
            -
                subject.checks. 
     | 
| 
      
 25 
     | 
    
         
            +
                klass = Class.new
         
     | 
| 
      
 26 
     | 
    
         
            +
                subject.add_check('foo', klass)
         
     | 
| 
      
 27 
     | 
    
         
            +
                expect(subject.checks).to include('foo')
         
     | 
| 
       28 
28 
     | 
    
         
             
              end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
              it 'should respond nil to unknown config options' do
         
     | 
| 
       31 
     | 
    
         
            -
                subject.foobarbaz. 
     | 
| 
      
 31 
     | 
    
         
            +
                expect(subject.foobarbaz).to be_nil
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
              it 'should create options on the fly' do
         
     | 
| 
       35 
35 
     | 
    
         
             
                subject.add_option('bar')
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                subject.bar. 
     | 
| 
      
 37 
     | 
    
         
            +
                expect(subject.bar).to be_nil
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
                subject.bar = 'aoeui'
         
     | 
| 
       40 
     | 
    
         
            -
                subject.bar. 
     | 
| 
      
 40 
     | 
    
         
            +
                expect(subject.bar).to eq('aoeui')
         
     | 
| 
       41 
41 
     | 
    
         
             
              end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
              it 'should be able to set sane defaults' do
         
     | 
| 
       44 
44 
     | 
    
         
             
                subject.defaults
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
                subject.settings. 
     | 
| 
      
 46 
     | 
    
         
            +
                expect(subject.settings).to eq({
         
     | 
| 
       47 
47 
     | 
    
         
             
                  'with_filename' => false,
         
     | 
| 
       48 
48 
     | 
    
         
             
                  'fail_on_warnings' => false,
         
     | 
| 
       49 
49 
     | 
    
         
             
                  'error_level' => :all,
         
     | 
| 
       50 
50 
     | 
    
         
             
                  'log_format' => '',
         
     | 
| 
       51 
51 
     | 
    
         
             
                  'with_context' => false,
         
     | 
| 
       52 
52 
     | 
    
         
             
                  'fix' => false,
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 53 
     | 
    
         
            +
                  'show_ignored' => false,
         
     | 
| 
      
 54 
     | 
    
         
            +
                })
         
     | 
| 
       54 
55 
     | 
    
         
             
              end
         
     | 
| 
       55 
56 
     | 
    
         
             
            end
         
     | 
| 
       56 
     | 
    
         
            -
             
     |