Fixed clang-tidy warnings

This commit is contained in:
Bartek Kryza
2023-06-09 01:07:49 +02:00
parent 7e416ffa97
commit 0a4e2c8855
3 changed files with 38 additions and 30 deletions

View File

@@ -191,10 +191,9 @@ tvl::value_t namespace_filter::match(
const auto &ns_pattern = std::get<namespace_>(nsit.value()); const auto &ns_pattern = std::get<namespace_>(nsit.value());
return ns.starts_with(ns_pattern) || ns == ns_pattern; return ns.starts_with(ns_pattern) || ns == ns_pattern;
} }
else {
const auto &regex = std::get<common::regex>(nsit.value()); const auto &regex = std::get<common::regex>(nsit.value());
return regex == ns.to_string(); return regex == ns.to_string();
}
}); });
} }
@@ -225,10 +224,9 @@ tvl::value_t namespace_filter::match(
return result; return result;
} }
else {
return std::get<common::regex>(nsit.value()) == return std::get<common::regex>(nsit.value()) ==
e.full_name(false); e.full_name(false);
}
}); });
} }
@@ -238,10 +236,8 @@ tvl::value_t namespace_filter::match(
return e.get_namespace().starts_with( return e.get_namespace().starts_with(
std::get<namespace_>(nsit.value())); std::get<namespace_>(nsit.value()));
} }
else {
return std::get<common::regex>(nsit.value()) == return std::get<common::regex>(nsit.value()) == e.full_name(false);
e.full_name(false);
}
}); });
} }
@@ -736,13 +732,19 @@ void diagram_filter::init_filters(const config::diagram &c)
std::vector<std::string> dependencies; std::vector<std::string> dependencies;
for (auto &&path : c.include().dependants) { for (auto &&path : c.include().dependants) {
const std::filesystem::path dep_path{*path.get<std::string>()}; if (auto p = path.get<std::string>(); p.has_value()) {
dependants.emplace_back(dep_path.lexically_normal().string()); const std::filesystem::path dep_path{*p};
dependants.emplace_back(
dep_path.lexically_normal().string());
}
} }
for (auto &&path : c.include().dependencies) { for (auto &&path : c.include().dependencies) {
const std::filesystem::path dep_path{*path.get<std::string>()}; if (auto p = path.get<std::string>(); p.has_value()) {
dependencies.emplace_back(dep_path.lexically_normal().string()); const std::filesystem::path dep_path{*p};
dependencies.emplace_back(
dep_path.lexically_normal().string());
}
} }
element_filters.emplace_back( element_filters.emplace_back(
@@ -826,23 +828,29 @@ void diagram_filter::init_filters(const config::diagram &c)
std::vector<std::string> dependencies; std::vector<std::string> dependencies;
for (auto &&path : c.exclude().dependants) { for (auto &&path : c.exclude().dependants) {
std::filesystem::path dep_path{*path.get<std::string>()}; if (auto p = path.get<std::string>(); p.has_value()) {
std::filesystem::path dep_path{*p};
if (dep_path.is_relative()) { if (dep_path.is_relative()) {
dep_path = c.base_directory() / *path.get<std::string>(); dep_path = c.base_directory() / *p;
dep_path = relative(dep_path, c.relative_to()); dep_path = relative(dep_path, c.relative_to());
} }
dependants.emplace_back(dep_path.lexically_normal().string()); dependants.emplace_back(
dep_path.lexically_normal().string());
}
} }
for (auto &&path : c.exclude().dependencies) { for (auto &&path : c.exclude().dependencies) {
std::filesystem::path dep_path{*path.get<std::string>()}; if (auto p = path.get<std::string>(); p.has_value()) {
std::filesystem::path dep_path{*p};
if (dep_path.is_relative()) { if (dep_path.is_relative()) {
dep_path = c.base_directory() / *path.get<std::string>(); dep_path = c.base_directory() / *p;
dep_path = relative(dep_path, c.relative_to()); dep_path = relative(dep_path, c.relative_to());
} }
dependencies.emplace_back(dep_path.lexically_normal().string()); dependencies.emplace_back(
dep_path.lexically_normal().string());
}
} }
add_exclusive_filter(std::make_unique< add_exclusive_filter(std::make_unique<

View File

@@ -22,6 +22,6 @@ namespace clanguml::common {
std::string to_string(const std::string &s) { return s; } std::string to_string(const std::string &s) { return s; }
std::string to_string(string_or_regex sr) { return sr.to_string(); } std::string to_string(const string_or_regex &sr) { return sr.to_string(); }
}; };

View File

@@ -231,7 +231,7 @@ private:
using string_or_regex = or_regex<std::string>; using string_or_regex = or_regex<std::string>;
std::string to_string(string_or_regex sr); std::string to_string(const string_or_regex &sr);
using namespace_or_regex = common::or_regex<common::model::namespace_>; using namespace_or_regex = common::or_regex<common::model::namespace_>;