Foodcritic / foodcritic

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

FC044 False Positive #761

Open jaymzh opened 6 years ago

jaymzh commented 6 years ago

Using any local hash in an attributes file seems to trigger this:

data = {}

# process each specified file
{}.each do |name, filepath|
  # specify the default hash first
  data[name] = {}

  # skip if the file doesn't exist (could be Internap host)
  next unless File.exists?(filepath)

  Chef::Log.info("Processing file: #{filepath}")
  File.open(filepath).readlines.each do |line|
    k, v = line.strip.split('=', 2)
    data[name][k] = v                                   # THIS LINE TRIGGERS FC044
  end
end

default['ape'] = data

yields this:

FC044: Avoid bare attribute keys: /tmp/foo/attributes/test.rb:18