Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Numeric value for mode should be 5 digits (CHEF-174) #9
In FC006, numeric value for mode should be 5 digits to ensure that ruby (jruby) parses the mode correctly. I actually run into this one myself with jruby.
As seen in
Given how working with numbers in Ruby can be tricky, "FC002: Avoid string interpolation where not required" does not sound like a good advice. My rule of thumb - quote unless you are really really sure.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Thanks for raising this - you're absolutely right the current rule implementation is broken.
I added the rule initially in reference to CHEF-174 but made a conscious decision to implement it to allow a 4-digit literal based on reading another discussion.
Whether or not Ruby treats it as an octal number is controlled by whether it has a leading zero.
The current rule works for the common case because if you don't set the setuid, setguid or sticky bits then to pass the rule you will need to specify a leading zero. However if you have a file mode that sets one of these bits then you could get away currently without specifying the zero which is just plain nasty.
I've merged your commit but it will probably need more work to allow 4-digit literals provided they have a leading zero - there are lots of examples of this (legal) usage in the Opscode cookbook tree. Is this something you could take a look at?
Can you expand on FC002 in a separate issue.
added a commit
this pull request
Feb 21, 2012
I will be glad to see how this can be expanded to cover the 4-digit literal case with leading 0. In my humble opinion though, Opscode should change their cookbooks to use the less ambiguous 5-digits or quotes rule for mode.
Here's a case that actually happened to us. We pushed the 2755 mode in production and learned the effect of that the hard way. After the incident, we decided to enforce the 5-digit rule very strictly. The result of making a mode mistake is too costly. Thus, the rule needs to very simple and unambiguous. "5-digits or quotes" is easy enough for everyone to remember.
I think your linter idea is absolutely great and I like the implementation.
Thanks, that's great.
Yes, I think the "5-digits" rule is the message Opscode are trying to send in the docs and I agree it would be great if the Opscode cookbook tree were updated to reflect this for consistency.
If you are able to complete the contributor agreement then I expect they'd probably appreciate a pull request: