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

Fix ensure_first_param fix method to retrieve the full value of the ensure parameter #673

Merged
merged 5 commits into from
Mar 27, 2017

Conversation

rodjek
Copy link
Owner

@rodjek rodjek commented Mar 27, 2017

Previously, the fix method for the ensure_first_param check looked for the first :COMMA or :SEMIC token after the ensure param name to find the end of the parameter value, which works for most cases, but not when the value of the ensure parameter is a selector.

This PR fixes this behaviour by adding a next_token_of method to PuppetLint::Lexer::Token that encapsulates the logic of finding the next token of a certain type (and optionally value) with smarts to skip over blocks. Similarly, a prev_token_of method also now exists. These two methods resolve #660 and we can later refactor a lot of the puppet-lint codebase to use these methods and simplify the code a lot.

Fixes #659 & #660

@rodjek rodjek modified the milestone: 2.2.0 Mar 27, 2017
@rnelson0 rnelson0 merged commit 60c4c92 into master Mar 27, 2017
@rnelson0 rnelson0 deleted the issue-659 branch March 27, 2017 12:44
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.

Provide helper methods to search for specific tokens ensure_first_param fix can create invalid syntax
2 participants