puppetlabs / puppet-lint

Check that your Puppet manifests conform to the style guide
https://puppetlabs.github.io/puppet-lint/
MIT License
18 stars 12 forks source link

Fix function call name token type in function_indexes method #198

Closed hsnodgrass closed 3 hours ago

hsnodgrass commented 2 months ago

Summary

Currently, the method function_indexes in lib/puppet-lint/data.rb doesn't work and only returns empty arrays. This is because, when iterating over the token array, tokens are skipped if their type does not equal :NAME but tokens that represent function call declarations have the type :FUNCTION_NAME and are skipped during iteration.

Additional Context

Steps to reproduce:

  1. Create a basic puppet-lint plugin gem.
  2. In a lib/puppet-lint/plugins/<what ever your plugin name is>.rb file, add require 'pry'; binding.pry as the first line in the plugin's #check method definition.
  3. Create (or edit) the RSpec test for the plugin ensure that the :code block that your plugin test will execute against has a Puppet function call in it (i.e. notice('This is the func'))
  4. Run RSpec. When the pry session starts, type function_indexes and see that it returns an empty array.

Checklist

I didn't see any spec tests specific to this method so I didn't update any tests. Let me know if there are tests I should have updated for this.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.19%. Comparing base (66ed4a2) to head (0a278ac).

Files Patch % Lines
lib/puppet-lint/data.rb 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #198 +/- ## ======================================= Coverage 93.19% 93.19% ======================================= Files 55 55 Lines 1792 1792 ======================================= Hits 1670 1670 Misses 122 122 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.