Skip to content

Commit c4fa513

Browse files
authored
Merge pull request #269 from eseiler/fix/codechecker2
[FIX] More codechecker checks
2 parents 77c657a + 2e691ec commit c4fa513

File tree

13 files changed

+36
-37
lines changed

13 files changed

+36
-37
lines changed

doc/howto/custom_types/custom_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ int main(int argc, char const ** argv)
4848
return -1;
4949
}
5050

51-
std::cout << "my_bar was initialised with a = " << my_bar.a << std::endl;
51+
std::cout << "my_bar was initialised with a = " << my_bar.a << '\n';
5252

5353
return 0;
5454
}

doc/howto/custom_types/external_custom_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int main(int argc, char const ** argv)
5252
return -1;
5353
}
5454

55-
std::cout << "ext_bar was initialised with a = " << ext_bar.a << std::endl;
55+
std::cout << "ext_bar was initialised with a = " << ext_bar.a << '\n';
5656

5757
return 0;
5858
}

include/sharg/auxiliary.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace sharg
2222
* \details
2323
* \stableapi{Since version 1.0.}
2424
*/
25-
enum class update_notifications
25+
enum class update_notifications : uint8_t
2626
{
2727
on, //!< Automatic update notifications should be enabled.
2828
off //!< Automatic update notifications should be disabled.

include/sharg/detail/format_parse.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class format_parse : public format_base
199199

200200
private:
201201
//!\brief Describes the result of parsing the user input string given the respective option value type.
202-
enum class option_parse_result
202+
enum class option_parse_result : uint8_t
203203
{
204204
success, //!< Parsing of user input was successful.
205205
error, //!< There was some error while trying to parse the user input.
@@ -605,7 +605,7 @@ class format_parse : public format_base
605605
{
606606
for (auto it = arguments.begin(); it != end_of_options_it; ++it)
607607
{
608-
std::string arg{*it};
608+
std::string & arg{*it};
609609
if (!arg.empty() && arg[0] == '-') // may be an identifier
610610
{
611611
if (arg == "-")

include/sharg/detail/format_tdl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ inline auto to_tdl(std::string const & v)
8989
}
9090

9191
//!\copydetails sharg::detail::to_tdl
92-
auto to_tdl(auto SHARG_DOXYGEN_ONLY(v))
92+
auto to_tdl(auto SHARG_DOXYGEN_ONLY(v)) // NOLINT(performance-unnecessary-value-param)
9393
{
9494
return tdl::BoolValue(false);
9595
}
@@ -106,7 +106,7 @@ class format_tdl : format_base
106106
{
107107
public:
108108
//!\brief Supported tool description file formats.
109-
enum class FileFormat
109+
enum class FileFormat : uint8_t
110110
{
111111
CTD, //!<Support for CTD format
112112
CWL, //!<Support for CWL format
@@ -324,11 +324,11 @@ class format_tdl : format_base
324324
meta = parser_meta;
325325

326326
// each call will evaluate the function print_list_item()
327-
for (auto f : positional_option_calls)
327+
for (auto && f : positional_option_calls)
328328
f(meta.app_name);
329329

330330
// each call will evaluate the function print_list_item()
331-
for (auto f : parser_set_up_calls)
331+
for (auto && f : parser_set_up_calls)
332332
f(meta.app_name);
333333

334334
info.metaInfo = tdl::MetaInfo{

include/sharg/parser.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,24 +178,24 @@ class parser
178178
* \details
179179
* \stableapi{Since version 1.0.}
180180
*/
181-
parser(std::string const & app_name,
182-
std::vector<std::string> const & arguments,
181+
parser(std::string app_name,
182+
std::vector<std::string> arguments,
183183
update_notifications version_updates = update_notifications::on,
184-
std::vector<std::string> subcommands = {}) :
184+
std::vector<std::string> const & subcommands = {}) :
185185
version_check_dev_decision{version_updates},
186-
arguments{arguments}
186+
arguments{std::move(arguments)}
187187
{
188-
add_subcommands(std::move(subcommands));
189-
info.app_name = app_name;
188+
add_subcommands(subcommands);
189+
info.app_name = std::move(app_name);
190190
}
191191

192192
//!\overload
193-
parser(std::string const & app_name,
193+
parser(std::string app_name,
194194
int const argc,
195195
char const * const * const argv,
196196
update_notifications version_updates = update_notifications::on,
197-
std::vector<std::string> subcommands = {}) :
198-
parser{app_name, std::vector<std::string>{argv, argv + argc}, version_updates, std::move(subcommands)}
197+
std::vector<std::string> const & subcommands = {}) :
198+
parser{std::move(app_name), std::vector<std::string>{argv, argv + argc}, version_updates, subcommands}
199199
{}
200200

201201
//!\brief The destructor.

include/sharg/validators.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ class value_list_validator
246246
{
247247
std::for_each(std::ranges::begin(range),
248248
std::ranges::end(range),
249-
[&](auto cmp)
249+
[&](auto && cmp)
250250
{
251251
(*this)(cmp);
252252
});
@@ -353,7 +353,7 @@ class file_validator_base
353353
{
354354
std::for_each(v.begin(),
355355
v.end(),
356-
[&](auto cmp)
356+
[&](auto && cmp)
357357
{
358358
this->operator()(cmp);
359359
});
@@ -414,7 +414,8 @@ class file_validator_base
414414
if (std::filesystem::is_directory(path))
415415
{
416416
std::error_code ec{};
417-
std::filesystem::directory_iterator{path, ec}; // if directory iterator cannot be created, ec will be set.
417+
// if directory iterator cannot be created, ec will be set.
418+
std::filesystem::directory_iterator{path, ec}; // NOLINT(bugprone-unused-raii)
418419
if (static_cast<bool>(ec))
419420
throw validation_error{"Cannot read the directory \"" + path.string() + "\"!"};
420421
}

test/include/sharg/test/test_fixture.hpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,9 @@ class test_fixture : public ::testing::Test
5050
private:
5151
friend class early_exit_guardian;
5252

53-
static sharg::parser impl(std::vector<std::string> arguments, std::vector<std::string> subcommands = {})
53+
static sharg::parser impl(std::vector<std::string> arguments, std::vector<std::string> const & subcommands = {})
5454
{
55-
sharg::parser parser{"test_parser",
56-
std::move(arguments),
57-
sharg::update_notifications::off,
58-
std::move(subcommands)};
55+
sharg::parser parser{"test_parser", std::move(arguments), sharg::update_notifications::off, subcommands};
5956
sharg::detail::test_accessor::set_terminal_width(parser, 80u);
6057
return parser;
6158
}
@@ -69,10 +66,11 @@ class test_fixture : public ::testing::Test
6966
return impl(std::vector<std::string>{"./test_parser", std::forward<arg_ts>(arguments)...});
7067
}
7168

72-
static sharg::parser get_subcommand_parser(std::vector<std::string> arguments, std::vector<std::string> subcommands)
69+
static sharg::parser get_subcommand_parser(std::vector<std::string> arguments,
70+
std::vector<std::string> const & subcommands)
7371
{
7472
arguments.insert(arguments.begin(), "./test_parser");
75-
return impl(std::move(arguments), std::move(subcommands));
73+
return impl(std::move(arguments), subcommands);
7674
}
7775

7876
static std::string get_parse_cout_on_exit(sharg::parser & parser)
@@ -238,7 +236,7 @@ class early_exit_guardian
238236
};
239237
};
240238

241-
early_exit_guardian early_exit_guard{};
239+
early_exit_guardian early_exit_guard{}; // NOLINT(misc-definitions-in-headers)
242240

243241
inline void test_fixture::toggle_guardian()
244242
{

test/snippet/custom_enumeration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace foo
88
{
99

10-
enum class bar
10+
enum class bar : uint8_t
1111
{
1212
one,
1313
two,

test/unit/detail/format_help_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ TEST_F(format_help_test, advanced_options)
373373
EXPECT_EQ(get_parse_cout_on_exit(parser), expected);
374374
}
375375

376-
enum class foo
376+
enum class foo : uint8_t
377377
{
378378
one,
379379
two,

0 commit comments

Comments
 (0)