rodjek / puppet-lint

Check that your Puppet manifests conform to the style guide
MIT License
820 stars 204 forks source link

Crash when fixing ensure_first_param #938

Open felixdoerre opened 3 years ago

felixdoerre commented 3 years ago

Whoops! It looks like puppet-lint has encountered an error that it doesn't know how to handle.


puppet-lint version: 2.4.2 ruby version: 2.5.5-p157 platform: x86_64-linux-gnu file path: test.pp file contents:

node 'test' {

  file{'/path':
    target =>'/target',
    ensure => link
  }
}

error:

NoMethodError: undefined method `next_token_of' for nil:NilClass
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb:31:in `fix'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checkplugin.rb:42:in `block in fix_problems'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checkplugin.rb:38:in `each'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checkplugin.rb:38:in `fix_problems'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:67:in `block in run'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:65:in `each'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/checks.rb:65:in `run'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint.rb:205:in `run'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:66:in `block in run'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:62:in `each'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/lib/puppet-lint/bin.rb:62:in `run'
/var/lib/gems/2.5.0/gems/puppet-lint-2.4.2/bin/puppet-lint:7:in `<top (required)>'
/usr/local/bin/puppet-lint:23:in `load'
/usr/local/bin/puppet-lint:23:in `<main>'

Please note the two lines with empty spaces in the beginning of the manifest. Without them the error does not occur.

felixdoerre commented 3 years ago

Additionally, even without the two empty lines, puppet-lint fails to "--fix" the issue for ensure_first_param