Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix function call name token type in function_indexes method #198

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

hsnodgrass
Copy link

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

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified.

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.

Copy link

codecov bot commented Apr 17, 2024

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 ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #198   +/-   ##
=======================================
  Coverage   93.19%   93.19%           
=======================================
  Files          55       55           
  Lines        1792     1792           
=======================================
  Hits         1670     1670           
  Misses        122      122           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@donoghuc donoghuc force-pushed the hsnodgrass-patch-1 branch from b277462 to 95c814e Compare June 6, 2024 14:58
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.
@jordanbreen28 jordanbreen28 requested a review from a team as a code owner July 5, 2024 10:25
Copy link

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @hsnodgrass! We have added an action item to review the testing around this, but will move this forward in the meantime

@jordanbreen28 jordanbreen28 merged commit 6a6d2e6 into main Jul 5, 2024
9 of 10 checks passed
@jordanbreen28 jordanbreen28 deleted the hsnodgrass-patch-1 branch July 5, 2024 10:30
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants