Skip to content

Commit 77c657a

Browse files
authored
Merge pull request #268 from eseiler/fix/codechecker
[FIX] some codechecker reports
2 parents aacfd2a + db9a67e commit 77c657a

19 files changed

+147
-144
lines changed

.github/config/codechecker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ analyze:
77
- --enable=bugprone
88
- --enable=clang-diagnostic-shadow
99
- --disable=bugprone-easily-swappable-parameters
10+
- --disable=cert-dcl58-cpp
1011
- --disable=clang-diagnostic-implicit-int-float-conversion
1112
- --disable=clang-diagnostic-float-conversion
1213
- --disable=clang-diagnostic-implicit-int-conversion

doc/tutorial/parser/solution3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ number_type to_number(range_type && range)
1919
return s;
2020
}();
2121
number_type num;
22-
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);
22+
auto res = std::from_chars(str.data(), str.data() + str.size(), num);
2323

2424
if (res.ec != std::errc{})
2525
{

doc/tutorial/parser/solution4.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ number_type to_number(range_type && range)
1818
return s;
1919
}();
2020
number_type num;
21-
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);
21+
auto res = std::from_chars(str.data(), str.data() + str.size(), num);
2222

2323
if (res.ec != std::errc{})
2424
{

doc/tutorial/parser/solution5.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ number_type to_number(range_type && range)
1818
return s;
1919
}();
2020
number_type num;
21-
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);
21+
auto res = std::from_chars(str.data(), str.data() + str.size(), num);
2222

2323
if (res.ec != std::errc{})
2424
{

doc/tutorial/parser/solution6.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ number_type to_number(range_type && range)
1818
return s;
1919
}();
2020
number_type num;
21-
auto res = std::from_chars(&str[0], &str[0] + str.size(), num);
21+
auto res = std::from_chars(str.data(), str.data() + str.size(), num);
2222

2323
if (res.ec != std::errc{})
2424
{

include/sharg/detail/format_base.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class format_help_base : public format_base
373373
if (!meta.description.empty())
374374
{
375375
derived_t().print_section("Description");
376-
for (auto desc : meta.description)
376+
for (auto && desc : meta.description)
377377
print_line(desc);
378378
}
379379

@@ -397,14 +397,14 @@ class format_help_base : public format_base
397397
derived_t().print_section("Positional Arguments");
398398

399399
// each call will evaluate the function derived_t().print_list_item()
400-
for (auto f : positional_option_calls)
400+
for (auto && f : positional_option_calls)
401401
f();
402402

403403
// There are always options because of the common options
404404
derived_t().print_section("Options");
405405

406406
// each call will evaluate the function derived_t().print_list_item()
407-
for (auto f : parser_set_up_calls)
407+
for (auto && f : parser_set_up_calls)
408408
f();
409409

410410
// print Common options after developer options
@@ -424,7 +424,7 @@ class format_help_base : public format_base
424424
if (!meta.examples.empty())
425425
{
426426
derived_t().print_section("Examples");
427-
for (auto example : meta.examples)
427+
for (auto && example : meta.examples)
428428
print_line(example);
429429
}
430430

include/sharg/detail/format_html.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ class format_html : public format_help_base<format_html>
172172
*/
173173
std::string to_html(std::string const & input)
174174
{
175-
std::string buffer = escape_special_xml_chars(input);
175+
// Todo: Input is escaped, but then not used. Same in SeqAn2. Why?
176+
// std::string buffer = escape_special_xml_chars(input);
176177
std::string result;
177178
std::vector<std::string> open_tags; // acts as a stack of html tags
178179

include/sharg/detail/format_man.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class format_man : public format_help_base<format_man>
7979
std::cout << " " << meta.version << "\" \"" << meta.man_page_title << "\"\n";
8080

8181
// Print NAME section.
82-
std::cout << ".SH NAME\n" << meta.app_name << " \\- " << meta.short_description << std::endl;
82+
std::cout << ".SH NAME\n" << meta.app_name << " \\- " << meta.short_description << '\n';
8383
}
8484

8585
/*!\brief Prints a section title in man page format to std::cout.

include/sharg/detail/format_parse.hpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class format_parse : public format_base
331331

332332
std::string result{'['};
333333
for (auto const & [key, value] : key_value_pairs)
334-
result += std::string{key.data()} + ", ";
334+
result += std::string{key} + ", ";
335335
result.replace(result.size() - 2, 2, "]"); // replace last ", " by "]"
336336
return result;
337337
}();
@@ -402,11 +402,11 @@ class format_parse : public format_base
402402
requires std::is_arithmetic_v<option_t> && istreamable<option_t>
403403
option_parse_result parse_option_value(option_t & value, std::string const & in)
404404
{
405-
auto res = std::from_chars(&in[0], &in[in.size()], value);
405+
auto res = std::from_chars(in.data(), in.data() + in.size(), value);
406406

407407
if (res.ec == std::errc::result_out_of_range)
408408
return option_parse_result::overflow_error;
409-
else if (res.ec == std::errc::invalid_argument || res.ptr != &in[in.size()])
409+
else if (res.ec == std::errc::invalid_argument || res.ptr != in.data() + in.size())
410410
return option_parse_result::error;
411411

412412
return option_parse_result::success;
@@ -424,14 +424,10 @@ class format_parse : public format_base
424424
*/
425425
option_parse_result parse_option_value(bool & value, std::string const & in)
426426
{
427-
if (in == "0")
427+
if (in == "0" || in == "false")
428428
value = false;
429-
else if (in == "1")
429+
else if (in == "1" || in == "true")
430430
value = true;
431-
else if (in == "true")
432-
value = true;
433-
else if (in == "false")
434-
value = false;
435431
else
436432
return option_parse_result::error;
437433

include/sharg/detail/format_tdl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ auto to_tdl(std::integral auto v)
7979
//!\copydetails sharg::detail::to_tdl
8080
auto to_tdl(std::floating_point auto v)
8181
{
82-
return tdl::DoubleValue(v);
82+
return tdl::DoubleValue(static_cast<double>(v));
8383
}
8484

8585
//!\copydetails sharg::detail::to_tdl
@@ -339,7 +339,7 @@ class format_tdl : format_base
339339
.description = std::accumulate(begin(meta.description),
340340
end(meta.description),
341341
std::string{},
342-
[](auto a, auto v)
342+
[](auto const & a, auto const & v)
343343
{
344344
return a + v + '\n';
345345
}),

0 commit comments

Comments
 (0)