Skip to content

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

@zbentley

Description

@zbentley

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

  • Version puppet-lint (4.2.4)
  • MacOS 14, Ruby 3.3.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions