Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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`.
- Loading branch information