This rule does not seem to detect that the following two notification lines are effectively the same thing:
notifies(:restart, resources(:service => "riak"))
notifies :restart, resources(:service => "riak")
The latter is detected by the rule, the former is not.
Additionally something like the following is not detected:
notifies :restart, "service[openvpn]"
Additionally if the service name happens to be a variable it won't detect it, example:
notifies :restart, resources(:service => riak)
Just to put my 2p in. If you are using foodcritic 1.4.0+ this rule should be able to be rephrased as:
find_resources(ast).select do |resource|
notifications(resource).any? do |notification|
notification[:action] == :restart
While it's more readable the notifications method also fails to catch your first example. We should fix that.
It will match the third example using new-style notifications though. In general foodcritic rules won't resolve variable values as foodcritic is performing static analysis.
Match notifications with parentheses.
Closing, changed ETSY005 to @acrmp's suggestion
Fix issue #3 by creating a new Nokogiri::XML before doing xpath query.