Fix clang-tidy warning after upgrading to clang-tidy-15

This commit is contained in:
Bartek Kryza
2023-03-02 00:33:28 +01:00
parent 884e021b9a
commit 464d80eca3
25 changed files with 114 additions and 78 deletions

View File

@@ -492,12 +492,12 @@ void diagram_filter::init_filters(const config::diagram &c)
std::vector<std::string> dependencies;
for (auto &&path : c.include().dependants) {
std::filesystem::path dep_path{path};
const std::filesystem::path dep_path{path};
dependants.emplace_back(dep_path.lexically_normal().string());
}
for (auto &&path : c.include().dependencies) {
std::filesystem::path dep_path{path};
const std::filesystem::path dep_path{path};
dependencies.emplace_back(dep_path.lexically_normal().string());
}

View File

@@ -45,8 +45,8 @@ inja::json element::context() const
ctx["alias"] = alias();
ctx["full_name"] = full_name(false);
ctx["namespace"] = get_namespace().to_string();
if (comment().has_value()) {
ctx["comment"] = comment().value();
if (const auto maybe_comment = comment(); maybe_comment.has_value()) {
ctx["comment"] = maybe_comment.value();
}
return ctx;

View File

@@ -45,7 +45,10 @@ public:
std::copy(begin, end, std::back_inserter(path_));
}
path(const path &right) { path_ = right.path_; }
path(const path &right)
: path_{right.path_}
{
}
path &operator=(const path &right) = default;

View File

@@ -148,18 +148,21 @@ std::string template_parameter::to_string(
res += namespace_{type()}.relative_to(using_namespace).to_string();
}
if (concept_constraint()) {
const auto &maybe_concept_constraint = concept_constraint();
if (maybe_concept_constraint) {
if (!relative)
res += namespace_{concept_constraint().value()}.to_string();
res += namespace_{maybe_concept_constraint.value()}.to_string();
else
res += namespace_{concept_constraint().value()}
res += namespace_{maybe_concept_constraint.value()}
.relative_to(using_namespace)
.to_string();
}
if (!name().empty()) {
if (!type().empty() || concept_constraint())
if (!type().empty() || maybe_concept_constraint)
res += " ";
if (!relative)
res += namespace_{name()}.to_string();
else
@@ -169,6 +172,7 @@ std::string template_parameter::to_string(
// Render nested template params
if (!template_params_.empty()) {
std::vector<std::string> params;
params.reserve(template_params_.size());
for (const auto &template_param : template_params_) {
params.push_back(
template_param.to_string(using_namespace, relative));
@@ -197,8 +201,9 @@ bool template_parameter::find_nested_relationships(
// If this type argument should be included in the relationship
// just add it and skip recursion (e.g. this is a user defined type)
if (should_include(name())) {
if (id()) {
nested_relationships.emplace_back(id().value(), hint);
const auto maybe_id = id();
if (maybe_id) {
nested_relationships.emplace_back(maybe_id.value(), hint);
added_aggregation_relationship =
(hint == common::model::relationship_t::kAggregation);
}
@@ -207,11 +212,10 @@ bool template_parameter::find_nested_relationships(
// interested what is stored inside it
else {
for (const auto &template_argument : template_params()) {
if (should_include(template_argument.name()) &&
template_argument.id()) {
const auto maybe_id = template_argument.id();
if (should_include(template_argument.name()) && maybe_id) {
nested_relationships.emplace_back(
template_argument.id().value(), hint);
nested_relationships.emplace_back(maybe_id.value(), hint);
added_aggregation_relationship =
(hint == common::model::relationship_t::kAggregation);

View File

@@ -27,7 +27,6 @@ std::ostream &template_trait::render_template_params(std::ostream &ostr,
if (!templates_.empty()) {
std::vector<std::string> tnames;
std::vector<std::string> tnames_simplified;
std::transform(templates_.cbegin(), templates_.cend(),
std::back_inserter(tnames),