Remove Exhaustive parameter for documentation

This commit is contained in:
Alexander Bock
2017-07-27 14:46:46 -04:00
parent e794f6ae01
commit 35a41d3283
19 changed files with 39 additions and 108 deletions
+5 -34
View File
@@ -131,20 +131,18 @@ DocumentationEntry::DocumentationEntry(std::string key, Verifier* v, Optional op
std::move(doc))
{}
Documentation::Documentation(std::string n, std::string id, DocumentationEntries entries,
Exhaustive exh)
Documentation::Documentation(std::string n, std::string id, DocumentationEntries entries)
: name(std::move(n))
, id(std::move(id))
, entries(std::move(entries))
, exhaustive(std::move(exh))
{}
Documentation::Documentation(std::string n, DocumentationEntries entries, Exhaustive exh)
: Documentation(n, "", entries, exh)
Documentation::Documentation(std::string n, DocumentationEntries entries)
: Documentation(n, "", entries)
{}
Documentation::Documentation(DocumentationEntries entries, Exhaustive exh)
: Documentation("", "", entries, exh)
Documentation::Documentation(DocumentationEntries entries)
: Documentation("", "", entries)
{}
TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& dict) {
@@ -184,33 +182,6 @@ TestResult testSpecification(const Documentation& d, const ghoul::Dictionary& di
}
}
if (d.exhaustive) {
// If the documentation is exhaustive, we have to check if there are extra values
// in the table that are not covered by the Documentation
for (const std::string& key : dict.keys()) {
auto it = std::find_if(
d.entries.begin(),
d.entries.end(),
[&key](const DocumentationEntry& entry) {
if (entry.key == DocumentationEntry::Wildcard) {
return true;
}
else {
return entry.key == key;
}
}
);
if (it == d.entries.end()) {
result.success = false;
result.offenses.push_back(
{ key, TestResult::Offense::Reason::ExtraKey }
);
}
}
}
// Remove duplicate offenders that might occur if multiple rules apply to a single
// key and more than one of these rules are broken
std::set<TestResult::Offense, OffenseCompare> uniqueOffenders(