Skip to content

Commit

Permalink
rename variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDold committed Sep 8, 2023
1 parent d4797f1 commit b5fc740
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/search/plugins/raw_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,68 +118,68 @@ SubcategoryPlugins RawRegistry::collect_subcategory_plugins(
Features RawRegistry::collect_features(
const SubcategoryPlugins &subcategory_plugins, vector<string> &errors) const {
Features features;
unordered_map<string, int> key_occurrences;
unordered_map<string, int> feature_key_occurrences;
for (const Plugin *plugin : plugins) {
shared_ptr<Feature> feature = plugin->create_feature();
string key = feature->get_key();
key_occurrences[key]++;
features[key] = move(feature);
string feature_key = feature->get_key();
feature_key_occurrences[feature_key]++;
features[feature_key] = move(feature);
}

// Check that keys are unique
for (const auto &pair : key_occurrences) {
const string &key = pair.first;
// Check that feature_keys are unique
for (const auto &pair : feature_key_occurrences) {
const string &feature_key = pair.first;
int occurrences = pair.second;
if (occurrences > 1) {
errors.push_back(
to_string(occurrences) + " Features are defined for the key '" +
key + "'.");
feature_key + "'.");
}
}

// Check that all subcategories used in features are defined
for (const auto &item : features) {
const string &key = item.first;
const string &feature_key = item.first;
const Feature &feature = *item.second;
string subcategory = feature.get_subcategory();

if (!subcategory.empty() && !subcategory_plugins.count(subcategory)) {
const Type &type = feature.get_type();
errors.push_back(
"Missing SubcategoryPlugin '" + subcategory + "' for Plugin '" +
key + "' of type " + type.name());
feature_key + "' of type " + type.name());
}
}

// Check that all types used in features are defined
unordered_set<type_index> missing_types;
for (const auto &item : features) {
const string &key = item.first;
const string &feature_key = item.first;
const Feature &feature = *item.second;

const Type &type = feature.get_type();
if (type == TypeRegistry::NO_TYPE) {
errors.push_back(
"Missing Plugin for type of feature '" + key + "'.");
"Missing Plugin for type of feature '" + feature_key + "'.");
}

unordered_map<string, int> occurrences;
unordered_map<string, int> argument_key_occurrences;
for (const ArgumentInfo &arg_info : feature.get_arguments()) {
if (arg_info.type == TypeRegistry::NO_TYPE) {
errors.push_back(
"Missing Plugin for type of argument '" + arg_info.key
+ "' of feature '" + key + "'.");
+ "' of feature '" + feature_key + "'.");
}
++occurrences[arg_info.key];
++argument_key_occurrences[arg_info.key];
}
// Check that arg_keys are unique
for (const auto &pair : occurrences) {
for (const auto &pair : argument_key_occurrences) {
const string &arg_key = pair.first;
int occurrence = pair.second;
if (occurrence > 1) {
int arg_key_occurrence = pair.second;
if (arg_key_occurrence > 1) {
errors.push_back(
"The Argument '" + arg_key + "' in '" + key + "' is defined " +
to_string(occurrence) + " times.");
"The Argument '" + arg_key + "' in '" + feature_key + "' is defined " +
to_string(arg_key_occurrence) + " times.");
}
}
}
Expand Down

0 comments on commit b5fc740

Please sign in to comment.