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

"only_variable_string" repair breaks code which relies on stringification of non-primitive types: #209

Open zbentley opened 1 week ago

zbentley commented 1 week ago

Describe the Bug

The repair (--fix) for only_variable_string changes the behavior of code when implicit stringification of non-primitive types is used.

Expected Behavior

When Puppet code casts a variable to a string by enclosing it in quotes, puppet-lint should only decide those quotes are unnecessary if removing them doesn't risk removing implicit stringification/cast behavior.

Steps to Reproduce

Run the following Puppet code through puppet-lint:

$version = SemVer('3.12.4')
notify { "$version":}

Observe that puppet-lint reformats the code to be notify { $version:} which fails to compile since $version is not a string and names can only be strings.

Environment