Commit bea833bbcd9d99dd4dc81f74e50cfd493f314404

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent 268c26ad

Adding and fixing more warnings

.ci/check_tidy.sh
@@ -6,7 +6,7 @@ set -evx @@ -6,7 +6,7 @@ set -evx
6 6
7 mkdir -p build-tidy 7 mkdir -p build-tidy
8 cd build-tidy 8 cd build-tidy
9 -CXX_FLAGS="-Werror -Wall -Wextra -pedantic -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON 9 +CXX_FLAGS="-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON
10 cmake --build . 10 cmake --build .
11 11
12 set -evx 12 set -evx
CMakeLists.txt
@@ -27,7 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) @@ -27,7 +27,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
27 if(MSVC) 27 if(MSVC)
28 add_definitions("/W4") 28 add_definitions("/W4")
29 else() 29 else()
30 - add_definitions("-Wall -Wextra -pedantic") 30 + add_definitions(-Wall -Wextra -pedantic)
31 endif() 31 endif()
32 32
33 if(CMAKE_VERSION VERSION_GREATER 3.6) 33 if(CMAKE_VERSION VERSION_GREATER 3.6)
include/CLI/App.hpp
@@ -1048,10 +1048,10 @@ class App { @@ -1048,10 +1048,10 @@ class App {
1048 1048
1049 /// This returns the number of remaining options, minus the -- seperator 1049 /// This returns the number of remaining options, minus the -- seperator
1050 size_t remaining_size(bool recurse = false) const { 1050 size_t remaining_size(bool recurse = false) const {
1051 - size_t count = std::count_if( 1051 + size_t count = static_cast<size_t>(std::count_if(
1052 std::begin(missing_), std::end(missing_), [](const std::pair<detail::Classifer, std::string> &val) { 1052 std::begin(missing_), std::end(missing_), [](const std::pair<detail::Classifer, std::string> &val) {
1053 return val.first != detail::Classifer::POSITIONAL_MARK; 1053 return val.first != detail::Classifer::POSITIONAL_MARK;
1054 - }); 1054 + }));
1055 if(recurse) { 1055 if(recurse) {
1056 for(const App_p &sub : subcommands_) { 1056 for(const App_p &sub : subcommands_) {
1057 count += sub->remaining_size(recurse); 1057 count += sub->remaining_size(recurse);
tests/AppTest.cpp
@@ -633,24 +633,24 @@ TEST_F(TApp, RequiredFlags) { @@ -633,24 +633,24 @@ TEST_F(TApp, RequiredFlags) {
633 633
634 TEST_F(TApp, CallbackFlags) { 634 TEST_F(TApp, CallbackFlags) {
635 635
636 - int value = 0; 636 + size_t value = 0;
637 637
638 auto func = [&value](size_t x) { value = x; }; 638 auto func = [&value](size_t x) { value = x; };
639 639
640 app.add_flag_function("-v", func); 640 app.add_flag_function("-v", func);
641 641
642 run(); 642 run();
643 - EXPECT_EQ(value, 0); 643 + EXPECT_EQ(value, (size_t)0);
644 644
645 app.reset(); 645 app.reset();
646 args = {"-v"}; 646 args = {"-v"};
647 run(); 647 run();
648 - EXPECT_EQ(value, 1); 648 + EXPECT_EQ(value, (size_t)1);
649 649
650 app.reset(); 650 app.reset();
651 args = {"-vv"}; 651 args = {"-vv"};
652 run(); 652 run();
653 - EXPECT_EQ(value, 2); 653 + EXPECT_EQ(value, (size_t)2);
654 654
655 EXPECT_THROW(app.add_flag_function("hi", func), CLI::IncorrectConstruction); 655 EXPECT_THROW(app.add_flag_function("hi", func), CLI::IncorrectConstruction);
656 } 656 }
@@ -658,24 +658,24 @@ TEST_F(TApp, CallbackFlags) { @@ -658,24 +658,24 @@ TEST_F(TApp, CallbackFlags) {
658 #if __cplusplus >= 201402L 658 #if __cplusplus >= 201402L
659 TEST_F(TApp, CallbackFlagsAuto) { 659 TEST_F(TApp, CallbackFlagsAuto) {
660 660
661 - int value = 0; 661 + size_t value = 0;
662 662
663 auto func = [&value](size_t x) { value = x; }; 663 auto func = [&value](size_t x) { value = x; };
664 664
665 app.add_flag("-v", func); 665 app.add_flag("-v", func);
666 666
667 run(); 667 run();
668 - EXPECT_EQ(value, 0); 668 + EXPECT_EQ(value, (size_t)0);
669 669
670 app.reset(); 670 app.reset();
671 args = {"-v"}; 671 args = {"-v"};
672 run(); 672 run();
673 - EXPECT_EQ(value, 1); 673 + EXPECT_EQ(value, (size_t)1);
674 674
675 app.reset(); 675 app.reset();
676 args = {"-vv"}; 676 args = {"-vv"};
677 run(); 677 run();
678 - EXPECT_EQ(value, 2); 678 + EXPECT_EQ(value, (size_t)2);
679 679
680 EXPECT_THROW(app.add_flag("hi", func), CLI::IncorrectConstruction); 680 EXPECT_THROW(app.add_flag("hi", func), CLI::IncorrectConstruction);
681 } 681 }
tests/CMakeLists.txt
1 -set(GOOGLE_TEST_INDIVIDUAL ON) 1 +set(GOOGLE_TEST_INDIVIDUAL OFF)
2 include(AddGoogletest) 2 include(AddGoogletest)
3 3
4 set(CLI_TESTS 4 set(CLI_TESTS
tests/HelpersTest.cpp
@@ -415,8 +415,8 @@ TEST(Types, LexicalCastParsable) { @@ -415,8 +415,8 @@ TEST(Types, LexicalCastParsable) {
415 415
416 std::complex<double> output; 416 std::complex<double> output;
417 EXPECT_TRUE(CLI::detail::lexical_cast(input, output)); 417 EXPECT_TRUE(CLI::detail::lexical_cast(input, output));
418 - EXPECT_EQ(output.real(), 4.2); // Doing this in one go sometimes has trouble  
419 - EXPECT_EQ(output.imag(), 7.3); // on clang + c++4.8 due to missing const 418 + EXPECT_DOUBLE_EQ(output.real(), 4.2); // Doing this in one go sometimes has trouble
  419 + EXPECT_DOUBLE_EQ(output.imag(), 7.3); // on clang + c++4.8 due to missing const
420 420
421 EXPECT_FALSE(CLI::detail::lexical_cast(fail_input, output)); 421 EXPECT_FALSE(CLI::detail::lexical_cast(fail_input, output));
422 EXPECT_FALSE(CLI::detail::lexical_cast(extra_input, output)); 422 EXPECT_FALSE(CLI::detail::lexical_cast(extra_input, output));
tests/NewParseTest.cpp
@@ -34,8 +34,8 @@ TEST_F(TApp, AddingComplexParser) { @@ -34,8 +34,8 @@ TEST_F(TApp, AddingComplexParser) {
34 34
35 run(); 35 run();
36 36
37 - EXPECT_EQ(1.5, comp.real());  
38 - EXPECT_EQ(2.5, comp.imag()); 37 + EXPECT_DOUBLE_EQ(1.5, comp.real());
  38 + EXPECT_DOUBLE_EQ(2.5, comp.imag());
39 } 39 }
40 40
41 TEST_F(TApp, DefaultComplex) { 41 TEST_F(TApp, DefaultComplex) {
@@ -48,13 +48,13 @@ TEST_F(TApp, DefaultComplex) { @@ -48,13 +48,13 @@ TEST_F(TApp, DefaultComplex) {
48 EXPECT_THAT(help, HasSubstr("1")); 48 EXPECT_THAT(help, HasSubstr("1"));
49 EXPECT_THAT(help, HasSubstr("2")); 49 EXPECT_THAT(help, HasSubstr("2"));
50 50
51 - EXPECT_EQ(1, comp.real());  
52 - EXPECT_EQ(2, comp.imag()); 51 + EXPECT_DOUBLE_EQ(1, comp.real());
  52 + EXPECT_DOUBLE_EQ(2, comp.imag());
53 53
54 run(); 54 run();
55 55
56 - EXPECT_EQ(4, comp.real());  
57 - EXPECT_EQ(3, comp.imag()); 56 + EXPECT_DOUBLE_EQ(4, comp.real());
  57 + EXPECT_DOUBLE_EQ(3, comp.imag());
58 } 58 }
59 59
60 TEST_F(TApp, BuiltinComplex) { 60 TEST_F(TApp, BuiltinComplex) {
@@ -68,13 +68,13 @@ TEST_F(TApp, BuiltinComplex) { @@ -68,13 +68,13 @@ TEST_F(TApp, BuiltinComplex) {
68 EXPECT_THAT(help, HasSubstr("2")); 68 EXPECT_THAT(help, HasSubstr("2"));
69 EXPECT_THAT(help, HasSubstr("COMPLEX")); 69 EXPECT_THAT(help, HasSubstr("COMPLEX"));
70 70
71 - EXPECT_EQ(1, comp.real());  
72 - EXPECT_EQ(2, comp.imag()); 71 + EXPECT_DOUBLE_EQ(1, comp.real());
  72 + EXPECT_DOUBLE_EQ(2, comp.imag());
73 73
74 run(); 74 run();
75 75
76 - EXPECT_EQ(4, comp.real());  
77 - EXPECT_EQ(3, comp.imag()); 76 + EXPECT_DOUBLE_EQ(4, comp.real());
  77 + EXPECT_DOUBLE_EQ(3, comp.imag());
78 } 78 }
79 79
80 TEST_F(TApp, BuiltinComplexIgnoreI) { 80 TEST_F(TApp, BuiltinComplexIgnoreI) {
@@ -85,8 +85,8 @@ TEST_F(TApp, BuiltinComplexIgnoreI) { @@ -85,8 +85,8 @@ TEST_F(TApp, BuiltinComplexIgnoreI) {
85 85
86 run(); 86 run();
87 87
88 - EXPECT_EQ(4, comp.real());  
89 - EXPECT_EQ(3, comp.imag()); 88 + EXPECT_DOUBLE_EQ(4, comp.real());
  89 + EXPECT_DOUBLE_EQ(3, comp.imag());
90 } 90 }
91 91
92 TEST_F(TApp, BuiltinComplexFail) { 92 TEST_F(TApp, BuiltinComplexFail) {