7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/feature_map/private/validations/files_have_unique_features.rb', line 7
def validation_errors(files:, autocorrect: true, stage_changes: true)
cache = Private.glob_cache
file_mappings = cache.mapper_descriptions_that_map_files(files)
files_mapped_by_multiple_mappers = file_mappings.select do |_file, mapper_descriptions|
mapper_descriptions.count > 1
end
errors = []
if files_mapped_by_multiple_mappers.any?
errors << <<~MSG
Feature assignment should only be defined for each file in one way. The following files have had features assigned in multiple ways.
#{files_mapped_by_multiple_mappers.map { |file, descriptions| "- #{file} (#{descriptions.to_a.join(', ')})" }.join("\n")}
MSG
end
errors
end
|