Method: Puppet::Pops::Types::TypeMismatchDescriber#merge_descriptions
- Defined in:
- lib/puppet/pops/types/type_mismatch_describer.rb
#merge_descriptions(varying_path_position, size_mismatch_class, variant_descriptions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
# File 'lib/puppet/pops/types/type_mismatch_describer.rb', line 757 def merge_descriptions(, size_mismatch_class, variant_descriptions) descriptions = variant_descriptions.flatten [size_mismatch_class, MissingRequiredBlock, UnexpectedBlock, TypeMismatch].each do |mismatch_class| mismatches = descriptions.select { |desc| desc.is_a?(mismatch_class) } next unless mismatches.size == variant_descriptions.size # If they all have the same canonical path, then we can compact this into one generic_mismatch = mismatches.inject do |prev, curr| break nil unless prev.canonical_path == curr.canonical_path prev.merge(prev.path, curr) end next if generic_mismatch.nil? # Report the generic mismatch and skip the rest descriptions = [generic_mismatch] break end descriptions = descriptions.uniq descriptions.size == 1 ? [descriptions[0].chop_path()] : descriptions end |