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

Allow for spaces in the heredoc tag #841

Merged
merged 1 commit into from
Jul 28, 2019
Merged

Allow for spaces in the heredoc tag #841

merged 1 commit into from
Jul 28, 2019

Conversation

jarretlavallee
Copy link
Contributor

Currently, the parser will fail if there is a space in the heredoc tag. This PR updates the heredoc regex to allow for white spaces in the heredoc tag. With this PR, @("MYVAR" /) no longer causes the following error.

file contents:

class testing {
  $myvar = @("MYVAR" /)
       Some string
       in a heredoc
       | MYVAR
  notice($myvar)
}

error:

TypeError: no implicit conversion of nil into String
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/lexer.rb:496:in `initialize'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/lexer.rb:496:in `new'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/lexer.rb:496:in `interpolate_heredoc'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/lexer.rb:273:in `tokenise'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/checks.rb:25:in `load_data'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/checks.rb:55:in `run'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint.rb:205:in `run'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/bin.rb:66:in `block in run'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/bin.rb:62:in `each'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/lib/puppet-lint/bin.rb:62:in `run'
/Users/user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/puppet-lint-2.3.6/bin/puppet-lint:7:in `<top (required)>'
/Users/user/.rbenv/versions/2.5.1/bin/puppet-lint:23:in `load'
/Users/user/.rbenv/versions/2.5.1/bin/puppet-lint:23:in `<main>'

@rodjek
Copy link
Owner

rodjek commented Nov 2, 2018

Thanks @jarretlavallee! Would you mind adding a test case to the lexer spec to ensure that we don't have an accidental regression at some point in the future?

Prior to this commit, the regex for the heredoc name would not handle
spaces in the heredoc tag. This resulted in the end of the heredoc not
being found when tokenizing. This commit modifies the regex to allow for
white space after the heredoc name.
@jarretlavallee
Copy link
Contributor Author

@rodjek Sorry about that! I added a spec test and squashed the commits.

@rodjek rodjek merged commit cbd12d0 into rodjek:master Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants