Foodcritic / foodcritic

Lint tool for Chef cookbooks.
http://foodcritic.io
MIT License
408 stars 153 forks source link

Erroneous FC109 when calling a method extended to Chef::Node object #797

Open stgarf opened 5 years ago

stgarf commented 5 years ago

We have a NodeHelpers module and extend the Chef::Node object with it.

module NodeHelpers
  def envparser
    chef_gem_install('environment-parser', node['parsers']['environment_parser']['version'])
    require 'environment/parser'
    EnvironmentParser.new(node.chef_environment)
  end
  def phase
    envparser.phase
  end
end

class Chef
  class Node
    include NodeHelpers
  end
end

FoodCritic returns the follow lint warning presumably because it doesn't know about the helper libraries and how Chef::Node is being extended. Any way to get FC to know about the added methods and not complain here? (edit: formatting)

FC019: Access node attributes in a consistent manner

default['sensu_server']['digest']['password'] = "/#{node.phase}/sigint/sensu_server/digest/password"