(CAT-2635) Add rubocop-hash_inspect to PDK rubocop gem group and plugins#646
Merged
Conversation
gavindidrichsen
approved these changes
Jun 17, 2026
This file contains hidden or 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
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.
Summary
Ruby 3.4 (December 2024, Bug #20433) changed the output of
Hash#inspectfrom the legacy rocket syntax to colon syntax:{a: 1, "b" => 2}.inspectoutput{:a=>1, "b"=>2}{a: 1, "b" => 2}Test assertions that hardcode the old format — for example
eq("{:a=>1}")ormatch(/\{:name=>"foo"\}/)— silently break on Puppet 9. Therubocop-hash_inspectgem provides a single conservative cop (HashInspect/LegacyHashInspectFormat) that flags those literals statically duringpdk validate, so module authors can fix them before upgrading.This PR adds
rubocop-hash_inspect ~> 0.2to the:developmentgem group inconfig_defaults.yml(alongsiderubocop-performanceandrubocop-rspec) and adds'rubocop-hash_inspect'to thedefaults['plugins']array inmoduleroot/.rubocop.yml.erb, so the cop runs automatically on everypdk validateafter apdk update.Additional Context
Before (Ruby 3.4 / Puppet 9 breaks silently):
After — the cop flags these on
pdk validate:Correct form:
Version constraint:
~> 0.2targets the published0.2.0release (pessimistic minor lock — compatible with any0.2.xpatch but will not automatically pull in a future0.3.0/1.0.0that may change detection semantics).On by default: The cop ships enabled at
conventionseverity, matchingrubocop-performance. It is non-blocking (PDK does not failvalidateon convention offenses) and produces no false positives against thepuppetlabs-stdlibandpuppetlabs-concatbaseline corpora.A note on the ERB template comment:
moduleroot/.rubocop.yml.erbcarries the comment "note that these hashes need to use rockets, not colons, because rubocop config requires strings as keys". That refers to the ERB hash-key syntax used to render the template (writing'plugins' => [...]rather thanplugins: [...]), and is unrelated to the string values the cop flags. Config files are outside the cop's detection scope — only string and regexp literals in module source code are checked.Related Issues (if any)
0.2.0live)Checklist