forked from rodjek/puppet-lint
-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
Description
Describe the Bug
Puppet lint will crash when attempting to fix the first line, if it contains only whitespace
Expected Behavior
This should be treated like a standard trailing_whitespace
linter violation.
Steps to Reproduce
$ echo " \n# foo" > file.pp && puppet-lint --fix file.pp
Environment
- Version 3.0.1
- Platform Ubuntu 22.10
Additional Context
puppet-lint version: 3.0.1
ruby version: 3.0.4-p208
platform: x86_64-linux-gnu
file path: file.pp
file contents:
# foo
error:
NoMethodError: undefined method `next_token=' for nil:NilClass
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/plugins/check_whitespace/trailing_whitespace.rb:33:in `fix'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checkplugin.rb:42:in `block in fix_problems'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checkplugin.rb:38:in `each'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checkplugin.rb:38:in `fix_problems'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checks.rb:67:in `block in run'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checks.rb:65:in `each'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/checks.rb:65:in `run'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint.rb:220:in `run'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/bin.rb:83:in `block in run'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/bin.rb:79:in `each'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/lib/puppet-lint/bin.rb:79:in `run'
/home/natewo/.local/share/gem/ruby/3.0.0/gems/puppet-lint-3.0.1/bin/puppet-lint:7:in `<top (required)>'
/home/natewo/.local/bin/puppet-lint:25:in `load'
/home/natewo/.local/bin/puppet-lint:25:in `<main>'