class ChefCLI::Policyfile::DSL

def handle_preferred_cookbooks_conflicts

def handle_preferred_cookbooks_conflicts
  conflicting_source_messages = []
  default_source.combination(2).each do |source_a, source_b|
    conflicting_preferences = source_a.preferred_cookbooks & source_b.preferred_cookbooks
    next if conflicting_preferences.empty?
    conflicting_source_messages << "#{source_a.desc} and #{source_b.desc} are both set as the preferred source for cookbook(s) '#{conflicting_preferences.join(", ")}'"
  end
  unless conflicting_source_messages.empty?
    msg = "Multiple sources are marked as the preferred source for some cookbooks. Only one source can be preferred for a cookbook.\n"
    msg << conflicting_source_messages.join("\n") << "\n"
    @errors << msg
  end
end