Applied readability-use-anyofallof clang-tidy fixes

This commit is contained in:
Bartek Kryza
2022-12-20 22:23:03 +01:00
parent a7c198f96d
commit 7061243113
3 changed files with 17 additions and 25 deletions

View File

@@ -239,17 +239,14 @@ void diagram::get_parents(
bool diagram::has_element( bool diagram::has_element(
clanguml::common::model::diagram_element::id_t id) const clanguml::common::model::diagram_element::id_t id) const
{ {
for (const auto &c : classes_) { const auto has_class = std::any_of(classes_.begin(), classes_.end(),
if (c.get().id() == id) [id](const auto &c) { return c.get().id() == id; });
return true;
}
for (const auto &c : enums_) { if (has_class)
if (c.get().id() == id) return true;
return true;
}
return false; return std::any_of(enums_.begin(), enums_.end(),
[id](const auto &c) { return c.get().id() == id; });
} }
std::string diagram::to_alias( std::string diagram::to_alias(

View File

@@ -238,12 +238,8 @@ bool is_subexpr_of(const clang::Stmt *parent_stmt, const clang::Stmt *sub_stmt)
if (parent_stmt == sub_stmt) if (parent_stmt == sub_stmt)
return true; return true;
for (const auto *e : parent_stmt->children()) { return std::any_of(parent_stmt->child_begin(), parent_stmt->child_end(),
if (is_subexpr_of(e, sub_stmt)) [sub_stmt](const auto *e) { return is_subexpr_of(e, sub_stmt); });
return true;
}
return false;
} }
template <> id_t to_id(const std::string &full_name) template <> id_t to_id(const std::string &full_name)

View File

@@ -22,20 +22,19 @@ namespace clanguml::common::model {
bool decorated_element::skip() const bool decorated_element::skip() const
{ {
for (auto d : decorators_) return std::any_of(
if (std::dynamic_pointer_cast<decorators::skip>(d)) decorators_.begin(), decorators_.end(), [](const auto &d) {
return true; return std::dynamic_pointer_cast<decorators::skip>(d) != nullptr;
});
return false;
} }
bool decorated_element::skip_relationship() const bool decorated_element::skip_relationship() const
{ {
for (auto d : decorators_) return std::any_of(
if (std::dynamic_pointer_cast<decorators::skip_relationship>(d)) decorators_.begin(), decorators_.end(), [](const auto &d) {
return true; return std::dynamic_pointer_cast<decorators::skip_relationship>(
d) != nullptr;
return false; });
} }
std::pair<relationship_t, std::string> std::pair<relationship_t, std::string>