puppetlabs / puppet-specifications

Specification of the Puppet Language, Catalog, Extension points
Other
99 stars 66 forks source link

clarify bare words vs strings for include/contain/require #160

Closed bastelfreak closed 2 months ago

bastelfreak commented 2 months ago

Use Case

include/contain/require are basically function calls. They are usually used like this:

include foo
require baz::bar

or:

include 'foo'
require 'baz::bar'

I think it's a bit confusing that you can quote it but you don't have to. This makes it confusing for new users because in the first example you've a string and don't need to quote it, but in other code places you have to quote strings. I think we should settle on one style and enforce it with a puppet-lint plugin

Describe the Solution You Would Like

Always quote arguments for include/require/contain etc.

Describe Alternatives You've Considered

Invest a lot of time into teaching people when strings can be quoted vs must be quoted.

Additional Context

I checked https://www.puppet.com/docs/puppet/7/style_guide.html and I didn't see a note on this topic. Related discussion:

hlindberg commented 2 months ago

Where would "other code places" be where you think bare word strings cannot be used?

hlindberg commented 2 months ago

"Bare words" are names - names of resources/classes or names of enums (e.g. present, absent). Thus they follow the rules for naming things. Lowercase names evaluates to String values, which get passed to functions. Upper case names are always names of data types and they evaluate to a Type.

Changing the language without a huge impact on the existing puppet code base would be impossible. This is more of a style thing and could be checked with puppet-lint rules.

bastelfreak commented 2 months ago

I don't want to change the technical implementation but rather how we write code. This issue comes from https://github.com/puppetlabs/puppet-lint/pull/130 => https://github.com/puppetlabs/language-style-guide/pull/18. But I just realized that https://github.com/puppetlabs/language-style-guide is the better repo for this.