Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

node methods with/without arguments treated differently #128

Open
kcbraunschweig opened this issue Apr 29, 2013 · 2 comments
Open

node methods with/without arguments treated differently #128

kcbraunschweig opened this issue Apr 29, 2013 · 2 comments

Comments

@kcbraunschweig
Copy link

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?

@acrmp
Copy link
Member

acrmp commented Apr 30, 2013

Hi KC,

Thanks for raising this. I think the reason for the discrepancy is that we deliberately added logic to ignore calls with parentheses for FC019 in #22.

Cheers,

Andrew.

@jaymzh
Copy link
Collaborator

jaymzh commented May 9, 2013

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants