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

resource_attribute(cmd, 'foo') does not return blocks #23

Closed
jonlives opened this issue Apr 16, 2012 · 5 comments
Closed

resource_attribute(cmd, 'foo') does not return blocks #23

jonlives opened this issue Apr 16, 2012 · 5 comments

Comments

@jonlives
Copy link

resource_attribute(cmd, 'foo) returns nil when the attribute's value is a block not a literal.

ie, using

not_if "test -e /home/auto/.rvm/bin/rvm"

we get:

[2] pry(#FoodCritic::RuleDsl)> resource_attribute(cmd, 'not_if')
=> "test -e /home/auto/.rvm/bin/rvm"

but with

only_if {!File.exists?(foo) || (File.exists?(bar) && File.mtime(baz) < last_changedate)}

we get

[2] pry(#FoodCritic::RuleDsl)> resource_attribute(cmd, 'only_if')
=> nil

@acrmp
Copy link
Member

acrmp commented Apr 19, 2012

Hi Jon,

So I think the call here after our chat on IRC the other day was what to return in the case of attributes that have block values.

Does just returning the portion of the AST for the attribute value work for you?

Cheers,

Andrew.

@jonlives
Copy link
Author

I think that should be fine - in the specific case we discussed the other day all I'm interested in finding out is if there's a conditional full stop (and block conditionals being returned). Having the AST of the attribute value should be totally sufficient for more in depth checking I'd say.

@acrmp
Copy link
Member

acrmp commented Apr 19, 2012

Great - thank you sir.

@acrmp
Copy link
Member

acrmp commented Apr 21, 2012

Hi Jon,

This change has now been released in foodcritic 1.2.0.

Thanks,

Andrew.

@acrmp
Copy link
Member

acrmp commented May 2, 2012

Closing this one, let me know if it's still an issue and I'll re-open.

Cheers,

Andrew.

@acrmp acrmp closed this as completed May 2, 2012
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

2 participants