diff --git a/doc/howto/custom_types/custom_type.cpp b/doc/howto/custom_types/custom_type.cpp index 5df73a77..df0c1cf8 100644 --- a/doc/howto/custom_types/custom_type.cpp +++ b/doc/howto/custom_types/custom_type.cpp @@ -48,7 +48,7 @@ int main(int argc, char const ** argv) return -1; } - std::cout << "my_bar was initialised with a = " << my_bar.a << std::endl; + std::cout << "my_bar was initialised with a = " << my_bar.a << '\n'; return 0; } diff --git a/doc/howto/custom_types/external_custom_type.cpp b/doc/howto/custom_types/external_custom_type.cpp index 5c53a16b..c4664e9f 100644 --- a/doc/howto/custom_types/external_custom_type.cpp +++ b/doc/howto/custom_types/external_custom_type.cpp @@ -52,7 +52,7 @@ int main(int argc, char const ** argv) return -1; } - std::cout << "ext_bar was initialised with a = " << ext_bar.a << std::endl; + std::cout << "ext_bar was initialised with a = " << ext_bar.a << '\n'; return 0; } diff --git a/include/sharg/auxiliary.hpp b/include/sharg/auxiliary.hpp index 4d326312..a8723ee9 100644 --- a/include/sharg/auxiliary.hpp +++ b/include/sharg/auxiliary.hpp @@ -22,7 +22,7 @@ namespace sharg * \details * \stableapi{Since version 1.0.} */ -enum class update_notifications +enum class update_notifications : uint8_t { on, //!< Automatic update notifications should be enabled. off //!< Automatic update notifications should be disabled. diff --git a/include/sharg/detail/format_parse.hpp b/include/sharg/detail/format_parse.hpp index 01a6b384..ccc400c5 100644 --- a/include/sharg/detail/format_parse.hpp +++ b/include/sharg/detail/format_parse.hpp @@ -199,7 +199,7 @@ class format_parse : public format_base private: //!\brief Describes the result of parsing the user input string given the respective option value type. - enum class option_parse_result + enum class option_parse_result : uint8_t { success, //!< Parsing of user input was successful. error, //!< There was some error while trying to parse the user input. @@ -605,7 +605,7 @@ class format_parse : public format_base { for (auto it = arguments.begin(); it != end_of_options_it; ++it) { - std::string arg{*it}; + std::string & arg{*it}; if (!arg.empty() && arg[0] == '-') // may be an identifier { if (arg == "-") diff --git a/include/sharg/detail/format_tdl.hpp b/include/sharg/detail/format_tdl.hpp index 66066437..d608691b 100644 --- a/include/sharg/detail/format_tdl.hpp +++ b/include/sharg/detail/format_tdl.hpp @@ -89,7 +89,7 @@ inline auto to_tdl(std::string const & v) } //!\copydetails sharg::detail::to_tdl -auto to_tdl(auto SHARG_DOXYGEN_ONLY(v)) +auto to_tdl(auto SHARG_DOXYGEN_ONLY(v)) // NOLINT(performance-unnecessary-value-param) { return tdl::BoolValue(false); } @@ -106,7 +106,7 @@ class format_tdl : format_base { public: //!\brief Supported tool description file formats. - enum class FileFormat + enum class FileFormat : uint8_t { CTD, //! const & arguments, + parser(std::string app_name, + std::vector arguments, update_notifications version_updates = update_notifications::on, - std::vector subcommands = {}) : + std::vector const & subcommands = {}) : version_check_dev_decision{version_updates}, - arguments{arguments} + arguments{std::move(arguments)} { - add_subcommands(std::move(subcommands)); - info.app_name = app_name; + add_subcommands(subcommands); + info.app_name = std::move(app_name); } //!\overload - parser(std::string const & app_name, + parser(std::string app_name, int const argc, char const * const * const argv, update_notifications version_updates = update_notifications::on, - std::vector subcommands = {}) : - parser{app_name, std::vector{argv, argv + argc}, version_updates, std::move(subcommands)} + std::vector const & subcommands = {}) : + parser{std::move(app_name), std::vector{argv, argv + argc}, version_updates, subcommands} {} //!\brief The destructor. diff --git a/include/sharg/validators.hpp b/include/sharg/validators.hpp index 8a30dc74..e73e4cb5 100644 --- a/include/sharg/validators.hpp +++ b/include/sharg/validators.hpp @@ -246,7 +246,7 @@ class value_list_validator { std::for_each(std::ranges::begin(range), std::ranges::end(range), - [&](auto cmp) + [&](auto && cmp) { (*this)(cmp); }); @@ -353,7 +353,7 @@ class file_validator_base { std::for_each(v.begin(), v.end(), - [&](auto cmp) + [&](auto && cmp) { this->operator()(cmp); }); @@ -414,7 +414,8 @@ class file_validator_base if (std::filesystem::is_directory(path)) { std::error_code ec{}; - std::filesystem::directory_iterator{path, ec}; // if directory iterator cannot be created, ec will be set. + // if directory iterator cannot be created, ec will be set. + std::filesystem::directory_iterator{path, ec}; // NOLINT(bugprone-unused-raii) if (static_cast(ec)) throw validation_error{"Cannot read the directory \"" + path.string() + "\"!"}; } diff --git a/test/include/sharg/test/test_fixture.hpp b/test/include/sharg/test/test_fixture.hpp index b1607bc1..90bdcbed 100644 --- a/test/include/sharg/test/test_fixture.hpp +++ b/test/include/sharg/test/test_fixture.hpp @@ -50,12 +50,9 @@ class test_fixture : public ::testing::Test private: friend class early_exit_guardian; - static sharg::parser impl(std::vector arguments, std::vector subcommands = {}) + static sharg::parser impl(std::vector arguments, std::vector const & subcommands = {}) { - sharg::parser parser{"test_parser", - std::move(arguments), - sharg::update_notifications::off, - std::move(subcommands)}; + sharg::parser parser{"test_parser", std::move(arguments), sharg::update_notifications::off, subcommands}; sharg::detail::test_accessor::set_terminal_width(parser, 80u); return parser; } @@ -69,10 +66,11 @@ class test_fixture : public ::testing::Test return impl(std::vector{"./test_parser", std::forward(arguments)...}); } - static sharg::parser get_subcommand_parser(std::vector arguments, std::vector subcommands) + static sharg::parser get_subcommand_parser(std::vector arguments, + std::vector const & subcommands) { arguments.insert(arguments.begin(), "./test_parser"); - return impl(std::move(arguments), std::move(subcommands)); + return impl(std::move(arguments), subcommands); } static std::string get_parse_cout_on_exit(sharg::parser & parser) @@ -238,7 +236,7 @@ class early_exit_guardian }; }; -early_exit_guardian early_exit_guard{}; +early_exit_guardian early_exit_guard{}; // NOLINT(misc-definitions-in-headers) inline void test_fixture::toggle_guardian() { diff --git a/test/snippet/custom_enumeration.cpp b/test/snippet/custom_enumeration.cpp index 780b59c7..3a4cec45 100644 --- a/test/snippet/custom_enumeration.cpp +++ b/test/snippet/custom_enumeration.cpp @@ -7,7 +7,7 @@ namespace foo { -enum class bar +enum class bar : uint8_t { one, two, diff --git a/test/unit/detail/format_help_test.cpp b/test/unit/detail/format_help_test.cpp index 253cd6db..3888824a 100644 --- a/test/unit/detail/format_help_test.cpp +++ b/test/unit/detail/format_help_test.cpp @@ -373,7 +373,7 @@ TEST_F(format_help_test, advanced_options) EXPECT_EQ(get_parse_cout_on_exit(parser), expected); } -enum class foo +enum class foo : uint8_t { one, two, diff --git a/test/unit/parser/enumeration_names_test.cpp b/test/unit/parser/enumeration_names_test.cpp index e6300c36..1efb6367 100644 --- a/test/unit/parser/enumeration_names_test.cpp +++ b/test/unit/parser/enumeration_names_test.cpp @@ -13,7 +13,7 @@ namespace foo { -enum class bar +enum class bar : uint8_t { one, two, @@ -30,7 +30,7 @@ auto enumeration_names(bar) namespace Other { -enum class bar +enum class bar : uint8_t { one, two diff --git a/test/unit/parser/format_parse_test.cpp b/test/unit/parser/format_parse_test.cpp index dd5e295c..3bb0b2a3 100644 --- a/test/unit/parser/format_parse_test.cpp +++ b/test/unit/parser/format_parse_test.cpp @@ -637,7 +637,7 @@ TEST_F(format_parse_test, subcommand_parser_success) bool flag_value{false}; std::string option_value{}; - auto check_and_reset_options = [&](bool flag, std::string option) + auto check_and_reset_options = [&](bool flag, std::string const & option) { EXPECT_EQ(flag_value, flag); EXPECT_EQ(option_value, option); @@ -846,7 +846,7 @@ TEST_F(format_parse_test, executable_name) bool flag{false}; auto parser = get_parser(); - auto check = [&](std::string expected) + auto check = [&](std::string const & expected) { parser = sharg::parser{"test_parser", {expected, std::string{"-t"}}, sharg::update_notifications::off}; parser.add_flag(flag, sharg::config{.short_id = 't'}); diff --git a/test/unit/parser/format_parse_validators_test.cpp b/test/unit/parser/format_parse_validators_test.cpp index b57fbfec..ed9c6474 100644 --- a/test/unit/parser/format_parse_validators_test.cpp +++ b/test/unit/parser/format_parse_validators_test.cpp @@ -404,7 +404,7 @@ TEST_F(validator_test, inputfile_not_readable) TEST_F(validator_test, inputfile_not_regular) { sharg::test::tmp_filename const tmp{"my_file.test"}; - std::filesystem::path const filename = tmp.get_path(); + std::filesystem::path const & filename = tmp.get_path(); mkfifo(filename.c_str(), 0644); EXPECT_THROW(sharg::input_file_validator{}(filename), sharg::validation_error); @@ -662,7 +662,7 @@ TEST_F(validator_test, arithmetic_range_validator_error) EXPECT_FLOAT_EQ(value2, 0.9); } -enum class foo +enum class foo : uint8_t { one, two,