Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

WARNING: double quoted string containing no variables #895

Closed
mitchdubdub opened this issue Oct 15, 2019 · 3 comments
Closed

WARNING: double quoted string containing no variables #895

mitchdubdub opened this issue Oct 15, 2019 · 3 comments

Comments

@mitchdubdub
Copy link

mitchdubdub commented Oct 15, 2019

We started receiving failures on the new version of puppet-lint, we are getting a warning " WARNING: double quoted string containing no variables"

onlyif => "test $( subscription-manager refresh >/dev/null 2>&1; echo $? ) -ne 0 ",

It seems to follow the style guide for quotes.

https://puppet.com/docs/puppet/6.4/style_guide.html#quoting

puppet-lint 2.3.6 manifests/subscription_manager.pp

puppet-lint 2.4.1 manifests/subscription_manager.pp
WARNING: double quoted string containing no variables on line 19
WARNING: double quoted string containing no variables on line 36

@dioni21
Copy link
Contributor

dioni21 commented Oct 16, 2019

The warning is correct! There are NO PUPPET variables inside string. You should use single quotes.

BTW, Why complicate? Just use:

unless => 'subscription-manager refresh >/dev/null 2>&1',

@rodjek
Copy link
Owner

rodjek commented Oct 17, 2019

Hi @mitchdubdub,

As @dioni21 mentioned, this is actually the expected behaviour.

Looking at how that string was tokenised in 2.3.6, the lack of a warning previously was the result of an unknown bug that caused the string to be tokenised into multiple tokens rather than the single :STRING token that it should have been.

[
  <Token :DQPRE (test ) @1:2>,
  <Token :DQMID ($) @1:7>,
  <Token :DQMID (( subscription-manager refresh >/dev/null 2>&1; echo ) @1:9>,
  <Token :DQMID ($) @1:61>, <Token :DQPOST (? ) -ne 0 ) @1:63>
]

You are correct that the style guide says that this should be valid, but puppet-lint was written at a time when the style guide only preferred the use of single quotes and has not been updated to support the preference of double quotes.

@mitchdubdub
Copy link
Author

Thanks. We'll fix our code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants