1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

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>
This commit is contained in:
Philip Top 2025-04-19 09:14:59 -07:00 committed by GitHub
parent 70f98cb218
commit cbbf20ed93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 53 additions and 38 deletions

View File

@ -14,6 +14,8 @@ Checks: |
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-bugprone-forwarding-reference-overload, -bugprone-forwarding-reference-overload,
-bugprone-exception-escape, -bugprone-exception-escape,
-bugprone-crtp-constructor-accessibility,
-bugprone-chained-comparison,
clang-analyzer-optin.cplusplus.VirtualCall, clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-optin.performance.Padding, clang-analyzer-optin.performance.Padding,
-clang-diagnostic-float-equal, -clang-diagnostic-float-equal,
@ -40,9 +42,16 @@ Checks: |
-modernize-make-unique, -modernize-make-unique,
-modernize-type-traits, -modernize-type-traits,
-modernize-macro-to-enum, -modernize-macro-to-enum,
-modernize-use-constraints,
-modernize-use-ranges,
-modernize-use-starts-ends-with,
-modernize-use-integer-sign-comparison,
-modernize-use-designated-initializers,
-modernize-use-std-numbers,
*performance*, *performance*,
-performance-unnecessary-value-param, -performance-unnecessary-value-param,
-performance-inefficient-string-concatenation, -performance-inefficient-string-concatenation,
-performance-enum-size,
readability-const-return-type, readability-const-return-type,
readability-container-size-empty, readability-container-size-empty,
readability-delete-null-pointer, readability-delete-null-pointer,
@ -62,6 +71,7 @@ Checks: |
readability-string-compare, readability-string-compare,
readability-suspicious-call-argument, readability-suspicious-call-argument,
readability-uniqueptr-delete-release, readability-uniqueptr-delete-release,
-clang-analyzer-optin.core.EnumCastOutOfRange
CheckOptions: CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines - key: google-readability-braces-around-statements.ShortStatementLines

View File

@ -22,7 +22,7 @@ jobs:
- name: Configure - name: Configure
run: | run: |
cmake -S . -B build \ cmake -S . -B build \
-DCMAKE_CXX_STANDARD=17 \ -DCMAKE_CXX_STANDARD=20 \
-DCLI11_SINGLE_FILE_TESTS=OFF \ -DCLI11_SINGLE_FILE_TESTS=OFF \
-DCLI11_BUILD_EXAMPLES=OFF \ -DCLI11_BUILD_EXAMPLES=OFF \
-DCLI11_FUZZ_TARGET=ON \ -DCLI11_FUZZ_TARGET=ON \

View File

@ -88,13 +88,13 @@ jobs:
clang-tidy: clang-tidy:
name: Clang-Tidy name: Clang-Tidy
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: silkeh/clang:17 container: silkeh/clang:20
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Configure - name: Configure
run: > run: >
cmake -S . -B build -DCMAKE_CXX_STANDARD=17 cmake -S . -B build -DCMAKE_CXX_STANDARD=20
-DCMAKE_CXX_CLANG_TIDY="$(which -DCMAKE_CXX_CLANG_TIDY="$(which
clang-tidy);--use-color;--warnings-as-errors=*" clang-tidy);--use-color;--warnings-as-errors=*"
@ -133,7 +133,7 @@ jobs:
boost-build: boost-build:
name: Boost build name: Boost build
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
@ -233,9 +233,9 @@ jobs:
run: ctest --output-on-failure -L Packaging run: ctest --output-on-failure -L Packaging
working-directory: build working-directory: build
cmake-config-ubuntu-2004: cmake-config-ubuntu-2204:
name: CMake config check (Ubuntu 20.04) name: CMake config check (Ubuntu 22.04)
runs-on: ubuntu-20.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -282,9 +282,9 @@ jobs:
cmake-version: "3.16" cmake-version: "3.16"
if: success() || failure() if: success() || failure()
cmake-config-ubuntu-2204: cmake-config-ubuntu-2404:
name: CMake config check (Ubuntu 22.04) name: CMake config check (Ubuntu 24.04)
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@ -178,8 +178,8 @@ jobs:
containerImage: silkeh/clang:17 containerImage: silkeh/clang:17
cli11.std: 23 cli11.std: 23
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23 cli11.options: -DCMAKE_CXX_FLAGS=-std=c++23
clang19_26: clang20_26:
containerImage: silkeh/clang:19 containerImage: silkeh/clang:20
cli11.std: 26 cli11.std: 26
cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c cli11.options: -DCMAKE_CXX_FLAGS=-std=c++2c
container: $[ variables['containerImage'] ] container: $[ variables['containerImage'] ]

View File

@ -9,6 +9,7 @@
#include <map> #include <map>
#include <string> #include <string>
// NOLINTNEXTLINE
enum class Level : int { High, Medium, Low }; enum class Level : int { High, Medium, Low };
int main(int argc, char **argv) { int main(int argc, char **argv) {

View File

@ -46,7 +46,15 @@ namespace CLI {
#endif #endif
namespace detail { namespace detail {
enum class Classifier { NONE, POSITIONAL_MARK, SHORT, LONG, WINDOWS_STYLE, SUBCOMMAND, SUBCOMMAND_TERMINATOR }; enum class Classifier : std::uint8_t {
NONE,
POSITIONAL_MARK,
SHORT,
LONG,
WINDOWS_STYLE,
SUBCOMMAND,
SUBCOMMAND_TERMINATOR
};
struct AppFriend; struct AppFriend;
} // namespace detail } // namespace detail
@ -60,7 +68,7 @@ CLI11_INLINE std::string help(const App *app, const Error &e);
/// enumeration of modes of how to deal with extras in config files /// enumeration of modes of how to deal with extras in config files
enum class config_extras_mode : char { error = 0, ignore, ignore_all, capture }; enum class config_extras_mode : std::uint8_t { error = 0, ignore, ignore_all, capture };
class App; class App;
@ -242,7 +250,7 @@ class App {
/// specify that positional arguments come at the end of the argument sequence not inheritable /// specify that positional arguments come at the end of the argument sequence not inheritable
bool positionals_at_end_{false}; bool positionals_at_end_{false};
enum class startup_mode : char { stable, enabled, disabled }; enum class startup_mode : std::uint8_t { stable, enabled, disabled };
/// specify the startup mode for the app /// specify the startup mode for the app
/// stable=no change, enabled= startup enabled, disabled=startup disabled /// stable=no change, enabled= startup enabled, disabled=startup disabled
startup_mode default_startup{startup_mode::stable}; startup_mode default_startup{startup_mode::stable};

View File

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

View File

@ -29,7 +29,7 @@ class App;
/// This is passed in by App; all user classes must accept this as /// This is passed in by App; all user classes must accept this as
/// the second argument. /// the second argument.
enum class AppFormatMode { enum class AppFormatMode : std::uint8_t {
Normal, ///< The normal, detailed help Normal, ///< The normal, detailed help
All, ///< A fully expanded help All, ///< A fully expanded help
Sub, ///< Used when printed as part of expanded subcommand Sub, ///< Used when printed as part of expanded subcommand

View File

@ -33,7 +33,7 @@ namespace CLI {
namespace detail { namespace detail {
// Based generally on https://rmf.io/cxx11/almost-static-if // Based generally on https://rmf.io/cxx11/almost-static-if
/// Simple empty scoped class /// Simple empty scoped class
enum class enabler {}; enum class enabler : std::uint8_t {};
/// An instance to use in EnableIf /// An instance to use in EnableIf
constexpr enabler dummy = {}; constexpr enabler dummy = {};
@ -628,7 +628,7 @@ struct expected_count<T, typename std::enable_if<!is_mutable_container<T>::value
}; };
// Enumeration of the different supported categorizations of objects // Enumeration of the different supported categorizations of objects
enum class object_category : int { enum class object_category : std::uint8_t {
char_value = 1, char_value = 1,
integral_value = 2, integral_value = 2,
unsigned_integral = 4, unsigned_integral = 4,

View File

@ -185,7 +185,7 @@ class CustomValidator : public Validator {
namespace detail { namespace detail {
/// CLI enumeration of different file types /// CLI enumeration of different file types
enum class path_type { nonexistent, file, directory }; enum class path_type : std::uint8_t { nonexistent, file, directory };
/// get the type of the path from a file name /// get the type of the path from a file name
CLI11_INLINE path_type check_path(const char *file) noexcept; CLI11_INLINE path_type check_path(const char *file) noexcept;
@ -356,6 +356,7 @@ template <
typename T, typename T,
enable_if_t<!is_copyable_ptr<typename std::remove_reference<T>::type>::value, detail::enabler> = detail::dummy> enable_if_t<!is_copyable_ptr<typename std::remove_reference<T>::type>::value, detail::enabler> = detail::dummy>
typename std::remove_reference<T>::type &smart_deref(T &value) { typename std::remove_reference<T>::type &smart_deref(T &value) {
// NOLINTNEXTLINE
return value; return value;
} }
/// Generate a string representation of a set /// Generate a string representation of a set
@ -721,7 +722,7 @@ class AsNumberWithUnit : public Validator {
/// CASE_SENSITIVE/CASE_INSENSITIVE controls how units are matched. /// CASE_SENSITIVE/CASE_INSENSITIVE controls how units are matched.
/// UNIT_OPTIONAL/UNIT_REQUIRED throws ValidationError /// UNIT_OPTIONAL/UNIT_REQUIRED throws ValidationError
/// if UNIT_REQUIRED is set and unit literal is not found. /// if UNIT_REQUIRED is set and unit literal is not found.
enum Options { enum Options : std::uint8_t {
CASE_SENSITIVE = 0, CASE_SENSITIVE = 0,
CASE_INSENSITIVE = 1, CASE_INSENSITIVE = 1,
UNIT_OPTIONAL = 0, UNIT_OPTIONAL = 0,

View File

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

View File

@ -109,7 +109,7 @@ get_names(const std::vector<std::string> &input, bool allow_non_standard) {
std::vector<std::string> long_names; std::vector<std::string> long_names;
std::string pos_name; std::string pos_name;
for(std::string name : input) { for(std::string name : input) {
if(name.length() == 0) { if(name.empty()) {
continue; continue;
} }
if(name.length() > 1 && name[0] == '-' && name[1] != '-') { if(name.length() > 1 && name[0] == '-' && name[1] != '-') {

View File

@ -2615,7 +2615,6 @@ TEST_CASE_METHOD(TApp, "EmptyOptionEach", "[app]") {
// #122 // #122
TEST_CASE_METHOD(TApp, "EmptyOptionFail", "[app]") { TEST_CASE_METHOD(TApp, "EmptyOptionFail", "[app]") {
std::string q;
app.add_option("--each"); app.add_option("--each");
args = {"--each", "that"}; args = {"--each", "that"};

View File

@ -1590,7 +1590,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVector", "[config]") {
run(); run();
auto str = app.config_to_str();
CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}})); CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}}));
CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6})); CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6}));
CHECK(four == std::vector<int>({1, 2, 3, 4, 5, 6, 7, 8})); CHECK(four == std::vector<int>({1, 2, 3, 4, 5, 6, 7, 8}));
@ -1621,7 +1620,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVectorSeparated", "[config]") {
run(); run();
auto str = app.config_to_str();
CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}})); CHECK(two == std::vector<std::vector<int>>({{1, 2, 3}, {4, 5, 6}}));
CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6})); CHECK(three == std::vector<int>({1, 2, 3, 4, 5, 6}));
} }
@ -1653,7 +1651,6 @@ TEST_CASE_METHOD(TApp, "TOMLVectorVectorSeparatedSingleElement", "[config]") {
run(); run();
auto str = app.config_to_str();
CHECK(two == std::vector<std::vector<int>>({{1}, {2}, {3}})); CHECK(two == std::vector<std::vector<int>>({{1}, {2}, {3}}));
CHECK(three == std::vector<int>({1, 4, 5})); CHECK(three == std::vector<int>({1, 4, 5}));
} }

View File

@ -342,7 +342,6 @@ TEST_CASE("app_roundtrip_parse_normal_fail") {
CLI::FuzzApp fuzzdata; CLI::FuzzApp fuzzdata;
auto app = fuzzdata.generateApp(); auto app = fuzzdata.generateApp();
int index = GENERATE(range(1, 4)); int index = GENERATE(range(1, 4));
std::string optionString, flagString;
auto parseData = loadFailureFile("parse_fail_check", index); auto parseData = loadFailureFile("parse_fail_check", index);
std::size_t pstring_start{0}; std::size_t pstring_start{0};
pstring_start = fuzzdata.add_custom_options(app.get(), parseData); pstring_start = fuzzdata.add_custom_options(app.get(), parseData);

View File

@ -1320,7 +1320,7 @@ TEST_CASE("Types: TypeName", "[helpers]") {
std::string text2_name = CLI::detail::type_name<char *>(); std::string text2_name = CLI::detail::type_name<char *>();
CHECK(text2_name == "TEXT"); CHECK(text2_name == "TEXT");
enum class test { test1, test2, test3 }; enum class test : std::uint8_t { test1, test2, test3 };
std::string enum_name = CLI::detail::type_name<test>(); std::string enum_name = CLI::detail::type_name<test>();
CHECK(enum_name == "ENUM"); CHECK(enum_name == "ENUM");

View File

@ -29,7 +29,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
using Catch::literals::operator"" _a; using Catch::Matchers::WithinRel;
TEST_CASE_METHOD(TApp, "OneStringAgain", "[optiontype]") { TEST_CASE_METHOD(TApp, "OneStringAgain", "[optiontype]") {
std::string str; std::string str;
@ -56,9 +56,9 @@ TEST_CASE_METHOD(TApp, "doubleFunction", "[optiontype]") {
app.add_option_function<double>("--val", [&res](double val) { res = std::abs(val + 54); }); app.add_option_function<double>("--val", [&res](double val) { res = std::abs(val + 54); });
args = {"--val", "-354.356"}; args = {"--val", "-354.356"};
run(); run();
CHECK(300.356_a == res); CHECK_THAT(res, WithinRel(300.356));
// get the original value as entered as an integer // get the original value as entered as an integer
CHECK(-354.356_a == app["--val"]->as<float>()); CHECK_THAT(app["--val"]->as<float>(), WithinRel(-354.356f));
} }
TEST_CASE_METHOD(TApp, "doubleFunctionFail", "[optiontype]") { TEST_CASE_METHOD(TApp, "doubleFunctionFail", "[optiontype]") {
@ -77,8 +77,8 @@ TEST_CASE_METHOD(TApp, "doubleVectorFunction", "[optiontype]") {
args = {"--val", "5", "--val", "6", "--val", "7"}; args = {"--val", "5", "--val", "6", "--val", "7"};
run(); run();
CHECK(3u == res.size()); CHECK(3u == res.size());
CHECK(10.0_a == res[0]); CHECK_THAT(res[0], WithinRel(10.0));
CHECK(12.0_a == res[2]); CHECK_THAT(res[2], WithinRel(12.0));
} }
TEST_CASE_METHOD(TApp, "doubleVectorFunctionFail", "[optiontype]") { TEST_CASE_METHOD(TApp, "doubleVectorFunctionFail", "[optiontype]") {