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

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

Projects

None yet

2 participants

@jonlives

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
Owner

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

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
Owner

Great - thank you sir.

@acrmp
Owner

Hi Jon,

This change has now been released in foodcritic 1.2.0.

Thanks,

Andrew.

@acrmp
Owner

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

Cheers,

Andrew.

@acrmp acrmp closed this May 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment