Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various clang tidy recommendations #227

Merged
merged 18 commits into from
Jan 8, 2025

Conversation

hikinggrass
Copy link
Contributor

  • More const ref usage
  • fix narrowing and widening conversion warnings

@hikinggrass hikinggrass requested a review from a-w50 January 7, 2025 11:57
Signed-off-by: Kai-Uwe Hermann <[email protected]>
lib/everest.cpp Outdated
@@ -71,7 +71,8 @@ Everest::Everest(std::string module_id_, const Config& config_, bool validate_da
// setup error_manager_req_global if enabled + error_database + error_state_monitor
if (this->module_manifest.contains("enable_global_errors") &&
this->module_manifest.at("enable_global_errors").get<bool>()) {
std::shared_ptr<error::ErrorDatabaseMap> global_error_database = std::make_shared<error::ErrorDatabaseMap>();
const std::shared_ptr<error::ErrorDatabaseMap>& global_error_database =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a reference, also auto can be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

lib/everest.cpp Outdated
@@ -90,7 +91,7 @@ Everest::Everest(std::string module_id_, const Config& config_, bool validate_da
// setup error_managers, error_state_monitors, error_factories and error_databases for all implementations
for (const std::string& impl : Config::keys(this->module_manifest.at("provides"))) {
// setup shared database
std::shared_ptr<error::ErrorDatabaseMap> error_database = std::make_shared<error::ErrorDatabaseMap>();
const std::shared_ptr<error::ErrorDatabaseMap> error_database = std::make_shared<error::ErrorDatabaseMap>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to auto

@@ -70,7 +70,7 @@ MessageHandler::MessageHandler() : running(true) {
std::vector<std::shared_ptr<TypedHandler>> local_handlers;
{
const std::lock_guard<std::mutex> handlers_lock(handler_list_mutex);
for (auto handler : this->handlers) {
for (const auto& handler : this->handlers) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use local_handlers = this->handlers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this->handlers is a unordered_set, so just a copy-assignment to the local_handlers vector doesn't work, that's probably why this is done this way

@hikinggrass hikinggrass merged commit 78c1de0 into main Jan 8, 2025
4 checks passed
@hikinggrass hikinggrass deleted the feature/clang-tidy-recommendations branch January 8, 2025 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants