You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit fixesvoxpupuli/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`.
0 commit comments