-
Notifications
You must be signed in to change notification settings - Fork 153
Conversation
else | ||
pass = true | ||
parts = ver.to_s.gsub(/\s|'|"/, '').split('.') | ||
if parts.length > 1 |
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.
Do we want to check <= 3
too?
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.
Yeah, this is just a rebase of the existing code, I want to add tests and fix that. CBVs actually have to be exactly 3 dotted decimals and this code can most likely be simplified considerably.
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.
Probably okay to accept one or two parts and let it extend them, or at least that is pretty common and doesn't seem like a bad idea.
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.
Okay I didn't realize 'x.y' was acceptable:
ERROR: Chef::Exceptions::InvalidCookbookVersion: '1' does not match 'x.y.z' or 'x.y'
We should just do that.
@coderanger @tas50 @acrmp hows this look now? |
I would make throw in one test using double quotes because I'm paranoid, but 👍 |
A expr = '1.0.0'
version expr |
Uhm, yeah, that's actually terrible and blocker for this. We need to only select string or double string literals here and check them. Peeps with CI/CD style cookbook delivery systems may be calling out to random ruby libraries to set their versions. (probably single quoted or double quoted string literals that have no interpolation in them) |
Also we should probably not file_match but match with a line number... |
- one checks for version presence - one checks for valid version syntax - version syntax requires a fixed string with no interpolation to trigger
7924ba1
to
a6e242c
Compare
@coderanger @acrmp @tas50 think this one is ready. |
@@ -826,3 +826,21 @@ def invalid_name(ast) | |||
end | |||
end | |||
end | |||
|
|||
rule 'FC061', 'Valid cookbook versions are of the form x.y or x.y.z' do | |||
tags %w{metadata} |
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 also include the tag correctness here
New Rule 61 - valid cookbook version
Thanks. I think FC061 would still match this case: version generated('like this') In some rules I believe we count ancestors to avoid this kind of issue. We could also return the matching node so that we get the correct line number rather than using |
working on a fix... |
closes #351