forked from rodjek/puppet-lint
-
Notifications
You must be signed in to change notification settings - Fork 13
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
(CONT-666) Skip classref types #93
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chelnak
force-pushed
the
CONT-666-skip_classref_types
branch
2 times, most recently
from
February 27, 2023 17:20
aa19756
to
6c74495
Compare
chelnak
force-pushed
the
CONT-666-skip_classref_types
branch
from
February 27, 2023 17:24
6c74495
to
c1bac50
Compare
ekohl
reviewed
Feb 27, 2023
chelnak
force-pushed
the
CONT-666-skip_classref_types
branch
from
February 27, 2023 20:52
c1bac50
to
8d29841
Compare
jordanbreen28
approved these changes
Feb 28, 2023
ekohl
approved these changes
Feb 28, 2023
chelnak
force-pushed
the
CONT-666-skip_classref_types
branch
from
February 28, 2023 11:43
8d29841
to
812dff0
Compare
This commit fixes voxpupuli/puppet-lint-trailing_comma-check#31. It appears that the `resource_indexes` method cannot differentiate between a resource declaration and a defaults declaration. If we compare the two, you can see that a defaults declaration type starts with a capital letter whereas a resource declaration does not. ```puppet Service { 'foo': ensure => running, } ``` ```puppet service { 'foo': ensure => running, } ``` When the `resource_indexes` method runs, it initially selects tokens by the presence of a colon then works to the right to decide if there are any violations. That means we are actually only starting to collect information about the declaration after the name.. so we never know the actual type of the declaration. ```puppet Service { 'foo': ↑ (here) ensure => running, } ``` https://github.com/puppetlabs/puppet-lint/blob/main/lib/puppet-lint/data.rb#L167 In contrast, `defaults_indexes` will skip any tokens that do not have a type of `:CLASSREF` because we know that a defaults declaration will always start with a capital letter (See [puppet-lint.com](http://puppet-lint.com/developer/tokens/) for more information on token types). This commit fixes the above by ensuring that `resource_indexes` checks the type of resource that it is analysing and skips the itteration if it detects a `:CLASSREF`.
This commit introduces some new spec test for the resource_indexes method. We check that it does not pick up any defaults declarations and also that it can properly parse resource declarations after the change.
chelnak
force-pushed
the
CONT-666-skip_classref_types
branch
from
February 28, 2023 11:48
812dff0
to
df978a2
Compare
GSPatton
approved these changes
Feb 28, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the
resource_indexes
method so that it will skip CLASSREF tokens.For more background on this PR please see #31