diff options
author | 2022-02-04 23:44:43 +0100 | |
---|---|---|
committer | 2022-02-04 14:44:43 -0800 | |
commit | e0085eb72f4f55d3bd3fb30af7490c999d34b9c7 (patch) | |
tree | 6f2fa753aff5b1fbe42fb3fd5fb8878096df2e27 /Source/Utils/WarnManager.cpp | |
parent | b3d5c36fc27923200d875edde16ae98f421fab32 (diff) | |
download | WarpX-e0085eb72f4f55d3bd3fb30af7490c999d34b9c7.tar.gz WarpX-e0085eb72f4f55d3bd3fb30af7490c999d34b9c7.tar.zst WarpX-e0085eb72f4f55d3bd3fb30af7490c999d34b9c7.zip |
Apply clang-tidy suggestions to MsgLogger and WarnManager (#2823)
* Add misc suggestions from clang-tidy for MsgLogger and WarnManager
* add [[maybe_unused]] to private member variable
* fixed issue with unused variable
* fix bug
Diffstat (limited to '')
-rw-r--r-- | Source/Utils/WarnManager.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/Source/Utils/WarnManager.cpp b/Source/Utils/WarnManager.cpp index c3b8d3159..4e8332631 100644 --- a/Source/Utils/WarnManager.cpp +++ b/Source/Utils/WarnManager.cpp @@ -17,10 +17,10 @@ using namespace Utils; using namespace Utils::MsgLogger; -WarnManager::WarnManager(){ - m_rank = amrex::ParallelDescriptor::MyProc(); - m_p_logger = std::make_unique<Logger>(); -} +WarnManager::WarnManager(): + m_rank{amrex::ParallelDescriptor::MyProc()}, + m_p_logger{std::make_unique<Logger>()} +{} void WarnManager::record_warning( std::string topic, @@ -38,9 +38,9 @@ std::string WarnManager::print_local_warnings(const std::string& when) const std::stringstream ss; - ss << "\n" << get_header(when, warn_line_size, false); + ss << "\n" << WarnManager::get_header(when, warn_line_size, false); - if(all_warnings.size() == 0){ + if(all_warnings.empty()){ ss << "* No recorded warnings.\n"; } else{ @@ -69,9 +69,9 @@ std::string WarnManager::print_global_warnings(const std::string& when) const std::stringstream ss; - ss << "\n" << get_header(when, warn_line_size, true); + ss << "\n" << WarnManager::get_header(when, warn_line_size, true); - if(all_warnings.size() == 0){ + if(all_warnings.empty()){ ss << "* No recorded warnings.\n"; } else{ @@ -106,7 +106,7 @@ void WarnManager::debug_read_warnings_from_input(amrex::ParmParse& params) int all_involved = 0; pp_warn.query("all_involved", all_involved); - if(all_involved){ + if(all_involved != 0){ this->record_warning(topic, msg, priority); } else{ @@ -121,30 +121,6 @@ void WarnManager::debug_read_warnings_from_input(amrex::ParmParse& params) } -std::string WarnManager::get_header( - const std::string& when, - const int line_size, - const bool is_global) const -{ - const std::string warn_header{"**** WARNINGS "}; - - std::stringstream ss; - - ss << warn_header << - std::string(line_size - static_cast<int>(warn_header.length()), '*') << "\n" ; - - if(is_global){ - ss << "* GLOBAL warning list after " << " [ " << when << " ]\n*\n"; - } - else{ - auto const mpi_rank = amrex::ParallelDescriptor::MyProc(); - ss << "* LOCAL" << " ( rank # " << mpi_rank << " ) " - << " warning list after " << when << "\n*\n"; - } - - return ss.str(); -} - std::string WarnManager::print_warn_msg( const MsgLogger::MsgWithCounter& msg_with_counter) const { @@ -187,7 +163,31 @@ std::string WarnManager::print_warn_msg( else{ raised_by += "ALL\n"; } - ss << msg_formatter(raised_by, warn_line_size, warn_tab_size); + ss << WarnManager::msg_formatter(raised_by, warn_line_size, warn_tab_size); + + return ss.str(); +} + +std::string WarnManager::get_header( + const std::string& when, + const int line_size, + const bool is_global) +{ + const std::string warn_header{"**** WARNINGS "}; + + std::stringstream ss; + + ss << warn_header << + std::string(line_size - static_cast<int>(warn_header.length()), '*') << "\n" ; + + if(is_global){ + ss << "* GLOBAL warning list after " << " [ " << when << " ]\n*\n"; + } + else{ + auto const mpi_rank = amrex::ParallelDescriptor::MyProc(); + ss << "* LOCAL" << " ( rank # " << mpi_rank << " ) " + << " warning list after " << when << "\n*\n"; + } return ss.str(); } @@ -196,7 +196,7 @@ std::string WarnManager::msg_formatter( const std::string& msg, const int line_size, - const int tab_size) const + const int tab_size) { const auto prefix = "*" + std::string(tab_size, ' '); const auto prefix_length = static_cast<int>(prefix.length()); |