From a454aa35d01b5f9762e9d6676b3f2bcf7f2851f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 14:06:08 +0000 Subject: [PATCH] style: pre-commit.ci fixes --- include/CLI/impl/App_inl.hpp | 21 ++++++++------------- include/CLI/impl/StringTools_inl.hpp | 4 +--- tests/ConfigFileTest.cpp | 5 ++--- tests/HelpersTest.cpp | 13 ++++++------- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/include/CLI/impl/App_inl.hpp b/include/CLI/impl/App_inl.hpp index 143df5678..a8c2e0e4b 100644 --- a/include/CLI/impl/App_inl.hpp +++ b/include/CLI/impl/App_inl.hpp @@ -1015,24 +1015,19 @@ CLI11_INLINE void App::_process_config_file() { bool config_required = config_ptr_->get_required(); auto file_given = config_ptr_->count() > 0; auto config_files = config_ptr_->as>(); - if (config_files.empty() || config_files.front().empty()) { - if (!config_ptr_->envname_.empty()) - { + if(config_files.empty() || config_files.front().empty()) { + if(!config_ptr_->envname_.empty()) { std::string ename_string = detail::get_environment_value(config_ptr_->envname_); - if (!ename_string.empty()) - { - if (config_files.empty()) - { + if(!ename_string.empty()) { + if(config_files.empty()) { config_files.push_back(ename_string); - } - else - { - config_files[0]=ename_string; + } else { + config_files[0] = ename_string; } } } } - if(config_files.empty() || config_files.front().empty()) { + if(config_files.empty() || config_files.front().empty()) { if(config_required) { throw FileError("config file is required but none was given"); } @@ -1062,7 +1057,7 @@ CLI11_INLINE void App::_process_config_file() { CLI11_INLINE void App::_process_env() { for(const Option_p &opt : options_) { if(opt->count() == 0 && !opt->envname_.empty()) { - std::string ename_string=detail::get_environment_value(opt->envname_); + std::string ename_string = detail::get_environment_value(opt->envname_); if(!ename_string.empty()) { opt->add_result(ename_string); } diff --git a/include/CLI/impl/StringTools_inl.hpp b/include/CLI/impl/StringTools_inl.hpp index 8c461caec..5a809fb97 100644 --- a/include/CLI/impl/StringTools_inl.hpp +++ b/include/CLI/impl/StringTools_inl.hpp @@ -255,9 +255,7 @@ CLI11_INLINE std::string &add_quotes_if_needed(std::string &str) { return str; } - -std::string get_environment_value(const std::string& env_name) -{ +std::string get_environment_value(const std::string &env_name) { char *buffer = nullptr; std::string ename_string; diff --git a/tests/ConfigFileTest.cpp b/tests/ConfigFileTest.cpp index 66d9befbe..9bdf59394 100644 --- a/tests/ConfigFileTest.cpp +++ b/tests/ConfigFileTest.cpp @@ -677,7 +677,6 @@ TEST_CASE_METHOD(TApp, "IniEnvironmentalFileName", "[config]") { TempFile tmpini{"TestIniTmp.ini"}; - app.set_config("--config", "")->envname("CONFIG")->required(); { @@ -692,7 +691,7 @@ TEST_CASE_METHOD(TApp, "IniEnvironmentalFileName", "[config]") { app.add_option("--two", two); app.add_option("--three", three); - put_env("CONFIG",tmpini); + put_env("CONFIG", tmpini); CHECK_NOTHROW(run()); @@ -701,7 +700,7 @@ TEST_CASE_METHOD(TApp, "IniEnvironmentalFileName", "[config]") { unset_env("CONFIG"); - CHECK_THROWS_AS(run(),CLI::FileError); + CHECK_THROWS_AS(run(), CLI::FileError); } TEST_CASE_METHOD(TApp, "MultiConfig", "[config]") { diff --git a/tests/HelpersTest.cpp b/tests/HelpersTest.cpp index 56c639fab..c008f40d9 100644 --- a/tests/HelpersTest.cpp +++ b/tests/HelpersTest.cpp @@ -4,8 +4,8 @@ // // SPDX-License-Identifier: BSD-3-Clause -#include "app_helper.hpp" #include "CLI/StringTools.hpp" +#include "app_helper.hpp" #include @@ -1356,14 +1356,13 @@ TEST_CASE("FixNewLines: EdgesCheck", "[helpers]") { CHECK(output == result); } - TEST_CASE("String: environment", "[helpers]") { - put_env("TEST1","TESTS"); - - auto value=CLI::detail::get_environment_value("TEST1"); - CHECK(value=="TESTS"); + put_env("TEST1", "TESTS"); + + auto value = CLI::detail::get_environment_value("TEST1"); + CHECK(value == "TESTS"); unset_env("TEST1"); - value=CLI::detail::get_environment_value("TEST2"); + value = CLI::detail::get_environment_value("TEST2"); CHECK(value.empty()); }