-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Clarify why this check is needed #3
Comments
I was actually bitten by this once, in production. It was embarrassing. |
It should also be note that as of puppet 4.something (not sure if 4.0.0 or sometime after), puppet only uses absolute class names. |
I can't speak for puppet 4 but the following presentation also suggests that there are performance gains to be had in using the absolute namespace https://www.slideshare.net/mobile/ripienaar/puppet-performance-profiling |
@natemccurdy would you be willing to patch the readme with the 'why this check is needed?' Otherwise I feel like there is consensus on it being needed and why and I'm inclinded to resolve the issue |
@nibalizer Sure thing. Before I do though, I've got to double check on which versions of Puppet this is necessary. At first pass, the consensus is that |
In Puppet 4.0.0 and newer, the old relative namespacing for classes has been called out as a bug and fixed. See https://tickets.puppetlabs.com/browse/PUP-121. This means there is no need or reason to include ::class_name Doing that should in fact be discouraged as it provides no benefit, and becomes unnecessary mental noise. In the future parser and Puppet ≥ 4.0.0, it is correct to use include class_name Using an absolute namespace operator when referencing a class name is a workaround for undesirable behavior and is only necessary in versions of Puppet that had this bug. Namely, puppet < 4.0.0 using the old parser. |
Now that Vox modules are mostly 4.x only, should there be a version of this check that only requires it in places where it might be actually needed (variables?) I personally prefer the appearance of include foo vs include '::foo' While I've already spent a lot of time resolving these warnings in the past, since it seems pretty clear that with Puppet >=4, it's not really necessary, I feel like either this check should be made looser (requiring it only in places where it might actually resolve ambiguity), or else we should just stop using it. Some discussion in: |
In modern Puppet (≥4.0.0) is is MORE CORRECT to use include foo and LESS CORRECT to use include '::foo' The linter should (maybe) not penalize I would be strongly in support of removing it as a default check, or even removing it entirely. |
Can we go so far as to ERROR on Puppet 3 when |
@ffrank As per my original comment, I think that erroring on Puppet 3 when The bug is that on Puppet 3, including |
It looks like there are 4 options:
Right now I consider most users are still in the early/mid stages of dropping Puppet 3. They may have some Puppet 3 somewhere and having one consistent style that works everywhere is a good thing. That means for now I think the current conservative behaviour should be the default but it would be good to have the options configurable for those who want to move to modern standards. |
I think it makes most sense to simply only use an absolute classname check with puppet 3, and users on puppet 4+ should remove this plugin entirely. The plugin can't really detect this from the code, since it's just a linter, and doing something like checking the gem/bundle/system to determine what puppet is in use adds a dependency that isn't there, and may not match the version in use on the actual target systems anyway. As such, I don't see any real need for the plugin in modern puppet development, and development can be frozen at the current status. |
@rnelson0 that makes sense. It also makes sense to build a new plugin that does the strict checking so Puppet 4+ users can clean up again but I don't have time for that. |
Ugh, good point. Here I was somehow assuming that puppet-lint relied on Puppet for the lexing. But no. It comes with its own lexer. Kudos to @rodjek, but it's definitely true that we cannot make any assumptions about the version of Puppet that a given piece of manifest code has been written for. As such, I agree with @rnelson0 - we should just be very explicit in telling users of Puppet 4+ that they should not install this plugin. |
fwiw, puppet-lint already checks variables for top scope namespace I think (even when this gem isn't installed)
|
Thanks for making that change @rnelson0 👍 I'm happy with closing this ticket now that your patch is merged in. |
It's important to point out that this check is only really needed under one circumstance. In all other circumstances it is perfectly acceptable to not use
::
when declaring a class.The only time that a class should be fully scoped is when the containing class's last name-segment matches the class being declared. For example:
Wrong Way
Correct Way
The text was updated successfully, but these errors were encountered: