Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/howto/custom_types/custom_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion doc/howto/custom_types/external_custom_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion include/sharg/auxiliary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions include/sharg/detail/format_parse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 == "-")
Expand Down
8 changes: 4 additions & 4 deletions include/sharg/detail/format_tdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}

//!\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)

Check warning on line 92 in include/sharg/detail/format_tdl.hpp

View check run for this annotation

Codecov / codecov/patch

include/sharg/detail/format_tdl.hpp#L92

Added line #L92 was not covered by tests
{
return tdl::BoolValue(false);
}
Expand All @@ -106,7 +106,7 @@
{
public:
//!\brief Supported tool description file formats.
enum class FileFormat
enum class FileFormat : uint8_t
{
CTD, //!<Support for CTD format
CWL, //!<Support for CWL format
Expand Down Expand Up @@ -324,11 +324,11 @@
meta = parser_meta;

// each call will evaluate the function print_list_item()
for (auto f : positional_option_calls)
for (auto && f : positional_option_calls)
f(meta.app_name);

// each call will evaluate the function print_list_item()
for (auto f : parser_set_up_calls)
for (auto && f : parser_set_up_calls)
f(meta.app_name);

info.metaInfo = tdl::MetaInfo{
Expand Down
18 changes: 9 additions & 9 deletions include/sharg/parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,24 @@ class parser
* \details
* \stableapi{Since version 1.0.}
*/
parser(std::string const & app_name,
std::vector<std::string> const & arguments,
parser(std::string app_name,
std::vector<std::string> arguments,
update_notifications version_updates = update_notifications::on,
std::vector<std::string> subcommands = {}) :
std::vector<std::string> 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<std::string> subcommands = {}) :
parser{app_name, std::vector<std::string>{argv, argv + argc}, version_updates, std::move(subcommands)}
std::vector<std::string> const & subcommands = {}) :
parser{std::move(app_name), std::vector<std::string>{argv, argv + argc}, version_updates, subcommands}
{}

//!\brief The destructor.
Expand Down
7 changes: 4 additions & 3 deletions include/sharg/validators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -353,7 +353,7 @@ class file_validator_base
{
std::for_each(v.begin(),
v.end(),
[&](auto cmp)
[&](auto && cmp)
{
this->operator()(cmp);
});
Expand Down Expand Up @@ -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<bool>(ec))
throw validation_error{"Cannot read the directory \"" + path.string() + "\"!"};
}
Expand Down
14 changes: 6 additions & 8 deletions test/include/sharg/test/test_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ class test_fixture : public ::testing::Test
private:
friend class early_exit_guardian;

static sharg::parser impl(std::vector<std::string> arguments, std::vector<std::string> subcommands = {})
static sharg::parser impl(std::vector<std::string> arguments, std::vector<std::string> 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;
}
Expand All @@ -69,10 +66,11 @@ class test_fixture : public ::testing::Test
return impl(std::vector<std::string>{"./test_parser", std::forward<arg_ts>(arguments)...});
}

static sharg::parser get_subcommand_parser(std::vector<std::string> arguments, std::vector<std::string> subcommands)
static sharg::parser get_subcommand_parser(std::vector<std::string> arguments,
std::vector<std::string> 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)
Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion test/snippet/custom_enumeration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace foo
{

enum class bar
enum class bar : uint8_t
{
one,
two,
Expand Down
2 changes: 1 addition & 1 deletion test/unit/detail/format_help_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/parser/enumeration_names_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace foo
{

enum class bar
enum class bar : uint8_t
{
one,
two,
Expand All @@ -30,7 +30,7 @@ auto enumeration_names(bar)
namespace Other
{

enum class bar
enum class bar : uint8_t
{
one,
two
Expand Down
4 changes: 2 additions & 2 deletions test/unit/parser/format_parse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'});
Expand Down
4 changes: 2 additions & 2 deletions test/unit/parser/format_parse_validators_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down