Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError when multiple heredocs are used #395

Closed
halfninja opened this issue Feb 20, 2015 · 3 comments · Fixed by #650
Closed

NoMethodError when multiple heredocs are used #395

halfninja opened this issue Feb 20, 2015 · 3 comments · Fixed by #650
Labels
Milestone

Comments

@halfninja
Copy link

Having multiple heredocs in one file causes an error. Seems fine with just one heredoc. I don't know if there are even any style rules for heredocs yet, but it executes fine on future parser so it would be good for it to at least quietly pass over them.

Example file:

class heredoc() {
  warning @(END)
    Multiline text.
    Text
    |- END

  warning @(END)
    More text
    Hello
    |- END
}

bin/puppet-lint heredoc.pp results in:

check_classes.rb:258:in `block (2 levels) in check': undefined method `line' for nil:NilClass (NoMethodError)
        from /home/nick/code/puppet-lint/lib/puppet-lint/plugins/check_classes.rb:224:in `each'
        from /home/nick/code/puppet-lint/lib/puppet-lint/plugins/check_classes.rb:224:in `block in check'
        from /home/nick/code/puppet-lint/lib/puppet-lint/plugins/check_classes.rb:206:in `each'
        from /home/nick/code/puppet-lint/lib/puppet-lint/plugins/check_classes.rb:206:in `check'
@halfninja
Copy link
Author

It's only when using the pipe modifier (which strips the left hand margin) - could be getting mixed up with the future scope parsing for lambda parameters in pipes.

@halfninja
Copy link
Author

I've done a pretty naive fix here, which I can PR if it looks sane?

https://github.com/UniversityofWarwick/puppet-lint/commit/02ea8964d51cdb0e8f81a95d7d9ee8dfa47c1349

@halfninja
Copy link
Author

Just bumped into a similar problem in check_nodes.rb. Might be something better fixed in the parser in which case I'm out of my depth. In fact it's triggered by the word "node" in the heredoc content, so definitely think the parser will need to be made aware of heredoc to avoid it tripping on keywords in string content.

@rodjek rodjek mentioned this issue Mar 22, 2017
@rodjek rodjek added the heredoc label Mar 22, 2017
@rodjek rodjek added this to PR Open in Bug fixerisation Mar 22, 2017
@rodjek rodjek modified the milestone: 2.2.0 Mar 25, 2017
@rodjek rodjek moved this from PR Open to Done in Bug fixerisation Mar 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

3 participants