-
-
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
Add support for inherits and class references #23
Add support for inherits and class references #23
Conversation
Good stuff. I'd actually written an implementation a few days back, but hadn't gotten around to committing it yet! I prefer yours though. :) |
while s.type != :RBRACK | ||
if s.type == :SSTRING && s.value.start_with?('::') | ||
notify :warning, { | ||
message: message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use a different message here?
class included by absolute name
isn't accurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good I think. Could you update the README?
I can't decide whether the next release should be 3.0.0 or not. I suppose this is 'breaking' in so much that lots of manifests that passed before, won't now. 'inherits' could be argued to be a way of including a class, but Class references aren't and checking them doesn't fall under the current gem's description ( @bodgit Could you update the gemspec with a new summary and description as well as updating the README? |
I think this will work, but it's also valid to write |
I'd forgotten about the first syntax, thankfully the code still works with some extra tests added. |
Thanks for adding those tests. If you address #23 (comment) I think this should be good to merge. |
I guess bare words and interpolated strings are also valid puppet? Ideally the plugin would also detect (and fix) Class[::foo] -> Class["::foo::install::${osfamily}"] Not a blocker for me though. |
Is it worth making the class references check separate within this gem? |
Possibly. That would let users turn it off if they didn't like it. Or we could default it to off for a release and then turn it on in the next major release. |
But like I said in #23 (comment), getting it perfect is not a blocker. I think the new check is already going to be covering 90%+ of uses. For the existing checking of how classes are included, I can keep coming up with obscure corner cases too, but life isn't long enough to try and catch them all. eg (I've seen this style in the last week, complete with random trailing comma and all those single quotes) include '::foo::bar', '::foo:foobar', 'foo', or as an actual array (instead of the comma separated string above) include [::foo::bar,'foo','::foo::foobar'] I think even the following is valid and would compile just fine... [
'::foo::bar',
'foo',
::foo::foobar,
].include |
I've split out the class reference check, updated the gemspec and README, and added support for bare class names as that was an easy addition. Anything else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bodgit Superb contribution. Thank you!
Now detects violations such as:
and
Fixes #20