You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.
There is something weird with how foodcritic treats node methods depending on whether they have arguments or not. I noticed this because foodcritic didn't catch where someone used in their recipe:
node.in_shard(1)
We have a custom sharding method but the method is 'in_shard?()' and he forgot the ? . This returns a method_missing failure in chef which is correct, but foodcritic missed it. So I played with this more using another custom node method that doesn't take an argument (centos?).
Normally if you do something like:
node.centos?
If you forgot to list as a dependency in your metadata the cookbook that provides this node method, you'll get:
FC019: Access node attributes in a consistent manner
If you do have your metadata right, you won't get an error.
However, if you try to intentionally cause FC019 as above using a method that takes an argument, you can't. So:
node.centos? -> causes FC019
node.centos?() -> doesn't cause FC019
Literally having () or not which is both empty and also invalid for that method gives you different behavior in foodcritic. Any idea what is going on here?
The text was updated successfully, but these errors were encountered:
We did... but now that it properly detects methods added in libraries, I don't think there's any real need for that hardcoded override anymore, do you?
There is something weird with how foodcritic treats node methods depending on whether they have arguments or not. I noticed this because foodcritic didn't catch where someone used in their recipe:
node.in_shard(1)
We have a custom sharding method but the method is 'in_shard?()' and he forgot the ? . This returns a method_missing failure in chef which is correct, but foodcritic missed it. So I played with this more using another custom node method that doesn't take an argument (centos?).
Normally if you do something like:
node.centos?
If you forgot to list as a dependency in your metadata the cookbook that provides this node method, you'll get:
FC019: Access node attributes in a consistent manner
If you do have your metadata right, you won't get an error.
However, if you try to intentionally cause FC019 as above using a method that takes an argument, you can't. So:
node.centos? -> causes FC019
node.centos?() -> doesn't cause FC019
Literally having () or not which is both empty and also invalid for that method gives you different behavior in foodcritic. Any idea what is going on here?
The text was updated successfully, but these errors were encountered: