Skip to content

Commit cbbf20e

Browse files
Ci build update (#1151)
update ci build images, remove ubuntu 20.04 and update a few others, fix some newer clang-tidy warnings --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 70f98cb commit cbbf20e

17 files changed

+53
-38
lines changed

.clang-tidy

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Checks: |
1414
-bugprone-easily-swappable-parameters,
1515
-bugprone-forwarding-reference-overload,
1616
-bugprone-exception-escape,
17+
-bugprone-crtp-constructor-accessibility,
18+
-bugprone-chained-comparison,
1719
clang-analyzer-optin.cplusplus.VirtualCall,
1820
clang-analyzer-optin.performance.Padding,
1921
-clang-diagnostic-float-equal,
@@ -40,9 +42,16 @@ Checks: |
4042
-modernize-make-unique,
4143
-modernize-type-traits,
4244
-modernize-macro-to-enum,
45+
-modernize-use-constraints,
46+
-modernize-use-ranges,
47+
-modernize-use-starts-ends-with,
48+
-modernize-use-integer-sign-comparison,
49+
-modernize-use-designated-initializers,
50+
-modernize-use-std-numbers,
4351
*performance*,
4452
-performance-unnecessary-value-param,
4553
-performance-inefficient-string-concatenation,
54+
-performance-enum-size,
4655
readability-const-return-type,
4756
readability-container-size-empty,
4857
readability-delete-null-pointer,
@@ -62,6 +71,7 @@ Checks: |
6271
readability-string-compare,
6372
readability-suspicious-call-argument,
6473
readability-uniqueptr-delete-release,
74+
-clang-analyzer-optin.core.EnumCastOutOfRange
6575
6676
CheckOptions:
6777
- key: google-readability-braces-around-statements.ShortStatementLines

.github/workflows/fuzz.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Configure
2323
run: |
2424
cmake -S . -B build \
25-
-DCMAKE_CXX_STANDARD=17 \
25+
-DCMAKE_CXX_STANDARD=20 \
2626
-DCLI11_SINGLE_FILE_TESTS=OFF \
2727
-DCLI11_BUILD_EXAMPLES=OFF \
2828
-DCLI11_FUZZ_TARGET=ON \

.github/workflows/tests.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ jobs:
8888
clang-tidy:
8989
name: Clang-Tidy
9090
runs-on: ubuntu-latest
91-
container: silkeh/clang:17
91+
container: silkeh/clang:20
9292
steps:
9393
- uses: actions/checkout@v4
9494

9595
- name: Configure
9696
run: >
97-
cmake -S . -B build -DCMAKE_CXX_STANDARD=17
97+
cmake -S . -B build -DCMAKE_CXX_STANDARD=20
9898
-DCMAKE_CXX_CLANG_TIDY="$(which
9999
clang-tidy);--use-color;--warnings-as-errors=*"
100100
@@ -133,7 +133,7 @@ jobs:
133133

134134
boost-build:
135135
name: Boost build
136-
runs-on: ubuntu-22.04
136+
runs-on: ubuntu-24.04
137137
steps:
138138
- uses: actions/checkout@v4
139139
with:
@@ -233,9 +233,9 @@ jobs:
233233
run: ctest --output-on-failure -L Packaging
234234
working-directory: build
235235

236-
cmake-config-ubuntu-2004:
237-
name: CMake config check (Ubuntu 20.04)
238-
runs-on: ubuntu-20.04
236+
cmake-config-ubuntu-2204:
237+
name: CMake config check (Ubuntu 22.04)
238+
runs-on: ubuntu-22.04
239239
steps:
240240
- uses: actions/checkout@v4
241241

@@ -282,9 +282,9 @@ jobs:
282282
cmake-version: "3.16"
283283
if: success() || failure()
284284

285-
cmake-config-ubuntu-2204:
286-
name: CMake config check (Ubuntu 22.04)
287-
runs-on: ubuntu-22.04
285+
cmake-config-ubuntu-2404:
286+
name: CMake config check (Ubuntu 24.04)
287+
runs-on: ubuntu-24.04
288288
steps:
289289
- uses: actions/checkout@v4
290290

azure-pipelines.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ jobs:
178178
containerImage: silkeh/clang:17
179179
cli11.std: 23
180180
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23
181-
clang19_26:
182-
containerImage: silkeh/clang:19
181+
clang20_26:
182+
containerImage: silkeh/clang:20
183183
cli11.std: 26
184184
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c
185185
container: $[ variables['containerImage'] ]

examples/enum.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <map>
1010
#include <string>
1111

12+
// NOLINTNEXTLINE
1213
enum class Level : int { High, Medium, Low };
1314

1415
int main(int argc, char **argv) {

include/CLI/App.hpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ namespace CLI {
4646
#endif
4747

4848
namespace detail {
49-
enum class Classifier { NONE, POSITIONAL_MARK, SHORT, LONG, WINDOWS_STYLE, SUBCOMMAND, SUBCOMMAND_TERMINATOR };
49+
enum class Classifier : std::uint8_t {
50+
NONE,
51+
POSITIONAL_MARK,
52+
SHORT,
53+
LONG,
54+
WINDOWS_STYLE,
55+
SUBCOMMAND,
56+
SUBCOMMAND_TERMINATOR
57+
};
5058
struct AppFriend;
5159
} // namespace detail
5260

@@ -60,7 +68,7 @@ CLI11_INLINE std::string help(const App *app, const Error &e);
6068

6169
/// enumeration of modes of how to deal with extras in config files
6270

63-
enum class config_extras_mode : char { error = 0, ignore, ignore_all, capture };
71+
enum class config_extras_mode : std::uint8_t { error = 0, ignore, ignore_all, capture };
6472

6573
class App;
6674

@@ -242,7 +250,7 @@ class App {
242250
/// specify that positional arguments come at the end of the argument sequence not inheritable
243251
bool positionals_at_end_{false};
244252

245-
enum class startup_mode : char { stable, enabled, disabled };
253+
enum class startup_mode : std::uint8_t { stable, enabled, disabled };
246254
/// specify the startup mode for the app
247255
/// stable=no change, enabled= startup enabled, disabled=startup disabled
248256
startup_mode default_startup{startup_mode::stable};

include/CLI/Error.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace CLI {
4141

4242
/// These codes are part of every error in CLI. They can be obtained from e using e.exit_code or as a quick shortcut,
4343
/// int values from e.get_error_code().
44-
enum class ExitCodes {
44+
enum class ExitCodes : int {
4545
Success = 0,
4646
IncorrectConstruction = 100,
4747
BadNameString,

include/CLI/FormatterFwd.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class App;
2929
/// This is passed in by App; all user classes must accept this as
3030
/// the second argument.
3131

32-
enum class AppFormatMode {
32+
enum class AppFormatMode : std::uint8_t {
3333
Normal, ///< The normal, detailed help
3434
All, ///< A fully expanded help
3535
Sub, ///< Used when printed as part of expanded subcommand

include/CLI/TypeTools.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace CLI {
3333
namespace detail {
3434
// Based generally on https://rmf.io/cxx11/almost-static-if
3535
/// Simple empty scoped class
36-
enum class enabler {};
36+
enum class enabler : std::uint8_t {};
3737

3838
/// An instance to use in EnableIf
3939
constexpr enabler dummy = {};
@@ -628,7 +628,7 @@ struct expected_count<T, typename std::enable_if<!is_mutable_container<T>::value
628628
};
629629

630630
// Enumeration of the different supported categorizations of objects
631-
enum class object_category : int {
631+
enum class object_category : std::uint8_t {
632632
char_value = 1,
633633
integral_value = 2,
634634
unsigned_integral = 4,

include/CLI/Validators.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class CustomValidator : public Validator {
185185
namespace detail {
186186

187187
/// CLI enumeration of different file types
188-
enum class path_type { nonexistent, file, directory };
188+
enum class path_type : std::uint8_t { nonexistent, file, directory };
189189

190190
/// get the type of the path from a file name
191191
CLI11_INLINE path_type check_path(const char *file) noexcept;
@@ -356,6 +356,7 @@ template <
356356
typename T,
357357
enable_if_t<!is_copyable_ptr<typename std::remove_reference<T>::type>::value, detail::enabler> = detail::dummy>
358358
typename std::remove_reference<T>::type &smart_deref(T &value) {
359+
// NOLINTNEXTLINE
359360
return value;
360361
}
361362
/// Generate a string representation of a set
@@ -721,7 +722,7 @@ class AsNumberWithUnit : public Validator {
721722
/// CASE_SENSITIVE/CASE_INSENSITIVE controls how units are matched.
722723
/// UNIT_OPTIONAL/UNIT_REQUIRED throws ValidationError
723724
/// if UNIT_REQUIRED is set and unit literal is not found.
724-
enum Options {
725+
enum Options : std::uint8_t {
725726
CASE_SENSITIVE = 0,
726727
CASE_INSENSITIVE = 1,
727728
UNIT_OPTIONAL = 0,

include/CLI/impl/Formatter_inl.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,11 @@ CLI11_INLINE std::string Formatter::make_option(const Option *opt, bool is_posit
291291
int shortNamesOverSize = 0;
292292

293293
// Print short names
294-
if(shortNames.length() > 0) {
294+
if(!shortNames.empty()) {
295295
shortNames = " " + shortNames; // Indent
296-
if(longNames.length() == 0 && opts.length() > 0)
296+
if(longNames.empty() && !opts.empty())
297297
shortNames += opts; // Add opts if only short names and no long names
298-
if(longNames.length() > 0)
298+
if(!longNames.empty())
299299
shortNames += ",";
300300
if(static_cast<int>(shortNames.length()) >= shortNamesColumnWidth) {
301301
shortNames += " ";
@@ -312,8 +312,8 @@ CLI11_INLINE std::string Formatter::make_option(const Option *opt, bool is_posit
312312
const auto adjustedLongNamesColumnWidth = longNamesColumnWidth - shortNamesOverSize;
313313

314314
// Print long names
315-
if(longNames.length() > 0) {
316-
if(opts.length() > 0)
315+
if(!longNames.empty()) {
316+
if(!opts.empty())
317317
longNames += opts;
318318
if(static_cast<int>(longNames.length()) >= adjustedLongNamesColumnWidth)
319319
longNames += " ";

include/CLI/impl/Split_inl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ get_names(const std::vector<std::string> &input, bool allow_non_standard) {
109109
std::vector<std::string> long_names;
110110
std::string pos_name;
111111
for(std::string name : input) {
112-
if(name.length() == 0) {
112+
if(name.empty()) {
113113
continue;
114114
}
115115
if(name.length() > 1 && name[0] == '-' && name[1] != '-') {

tests/AppTest.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,6 @@ TEST_CASE_METHOD(TApp, "EmptyOptionEach", "[app]") {
26152615

26162616
// #122
26172617
TEST_CASE_METHOD(TApp, "EmptyOptionFail", "[app]") {
2618-
std::string q;
26192618
app.add_option("--each");
26202619

26212620
args = {"--each", "that"};

tests/ConfigFileTest.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVector", "[config]") {
15901590

15911591
run();
15921592

1593-
auto str = app.config_to_str();
15941593
CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}}));
15951594
CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6}));
15961595
CHECK(four == std::vector<int>({1, 2, 3, 4, 5, 6, 7, 8}));
@@ -1621,7 +1620,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVectorSeparated", "[config]") {
16211620

16221621
run();
16231622

1624-
auto str = app.config_to_str();
16251623
CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}}));
16261624
CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6}));
16271625
}
@@ -1653,7 +1651,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVectorSeparatedSingleElement", "[config]") {
16531651

16541652
run();
16551653

1656-
auto str = app.config_to_str();
16571654
CHECK(two == std::vector<std::vector<int>>({{1}, {2}, {3}}));
16581655
CHECK(three == std::vector<int>({1, 4, 5}));
16591656
}

tests/FuzzFailTest.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ TEST_CASE("app_roundtrip_parse_normal_fail") {
342342
CLI::FuzzApp fuzzdata;
343343
auto app = fuzzdata.generateApp();
344344
int index = GENERATE(range(1, 4));
345-
std::string optionString, flagString;
346345
auto parseData = loadFailureFile("parse_fail_check", index);
347346
std::size_t pstring_start{0};
348347
pstring_start = fuzzdata.add_custom_options(app.get(), parseData);

tests/HelpersTest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ TEST_CASE("Types: TypeName", "[helpers]") {
13201320
std::string text2_name = CLI::detail::type_name<char *>();
13211321
CHECK(text2_name == "TEXT");
13221322

1323-
enum class test { test1, test2, test3 };
1323+
enum class test : std::uint8_t { test1, test2, test3 };
13241324
std::string enum_name = CLI::detail::type_name<test>();
13251325
CHECK(enum_name == "ENUM");
13261326

tests/OptionTypeTest.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <utility>
3030
#include <vector>
3131

32-
using Catch::literals::operator"" _a;
32+
using Catch::Matchers::WithinRel;
3333

3434
TEST_CASE_METHOD(TApp, "OneStringAgain", "[optiontype]") {
3535
std::string str;
@@ -56,9 +56,9 @@ TEST_CASE_METHOD(TApp, "doubleFunction", "[optiontype]") {
5656
app.add_option_function<double>("--val", [&res](double val) { res = std::abs(val + 54); });
5757
args = {"--val", "-354.356"};
5858
run();
59-
CHECK(300.356_a == res);
59+
CHECK_THAT(res, WithinRel(300.356));
6060
// get the original value as entered as an integer
61-
CHECK(-354.356_a == app["--val"]->as<float>());
61+
CHECK_THAT(app["--val"]->as<float>(), WithinRel(-354.356f));
6262
}
6363

6464
TEST_CASE_METHOD(TApp, "doubleFunctionFail", "[optiontype]") {
@@ -77,8 +77,8 @@ TEST_CASE_METHOD(TApp, "doubleVectorFunction", "[optiontype]") {
7777
args = {"--val", "5", "--val", "6", "--val", "7"};
7878
run();
7979
CHECK(3u == res.size());
80-
CHECK(10.0_a == res[0]);
81-
CHECK(12.0_a == res[2]);
80+
CHECK_THAT(res[0], WithinRel(10.0));
81+
CHECK_THAT(res[2], WithinRel(12.0));
8282
}
8383

8484
TEST_CASE_METHOD(TApp, "doubleVectorFunctionFail", "[optiontype]") {

0 commit comments

Comments
 (0)