From 6039c7b3db33a6056a104896315aed8158762bde Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 24 Jun 2024 10:04:53 -0600 Subject: [PATCH 1/5] Update Catch2 --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a14c50a..4f515ab 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) -find_package(Catch2 3.5.0 REQUIRED) +find_package(Catch2 3.6.0 REQUIRED) find_package(range-v3 REQUIRED) # Test library From 261f1a0f5d706221bdb0f1d29d98efe89e73ea9a Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 24 Jun 2024 10:17:27 -0600 Subject: [PATCH 2/5] Update checkout actions --- .github/workflows/docker.yaml | 2 +- .github/workflows/docs.yaml | 2 +- .github/workflows/format.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index cc47b10..881cef4 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v2 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 46b921a..0d1dc8f 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -20,7 +20,7 @@ jobs: container: ghcr.io/picknikrobotics/rsl:upstream-rolling steps: - name: Check out the repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v2 - name: Source ROS diff --git a/.github/workflows/format.yaml b/.github/workflows/format.yaml index 69ece64..260d158 100644 --- a/.github/workflows/format.yaml +++ b/.github/workflows/format.yaml @@ -12,7 +12,7 @@ jobs: name: pre-commit runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v3 - name: Install clang-format-14 run: sudo apt-get install clang-format-14 From d8858172ee02ae5b34300bd2c2aef948f12b4f16 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 24 Jun 2024 10:26:17 -0600 Subject: [PATCH 3/5] Allow all CI jobs to finish --- .github/workflows/ci.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d71b157..ef91e3e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,6 +9,7 @@ jobs: cmake: name: cmake (${{ matrix.ros_distro }}, ${{ matrix.preset }}, ${{ matrix.compiler.name }}) strategy: + fail-fast: false matrix: ros_distro: [humble, rolling] preset: [debug, release, asan, codecov] From f6b7e93059721c47197c96aac616e9b66bf874b5 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 24 Jun 2024 10:09:16 -0600 Subject: [PATCH 4/5] Fix new clang-tidy warnings --- .clang-tidy | 3 +++ include/rsl/monad.hpp | 2 +- tests/monad.cpp | 20 ++++++++++---------- tests/overload.cpp | 2 +- tests/random.cpp | 4 +++- tests/static_string.cpp | 2 +- tests/try.cpp | 4 +++- 7 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d1d7d56..a6d2021 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,13 +9,16 @@ Checks: > performance-*, portability-*, readability-*, + -bugprone-unchecked-optional-access, -concurrency-mt-unsafe, -cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-macro-usage, -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -misc-include-cleaner, -misc-non-private-member-variables-in-classes, -modernize-avoid-bind, -modernize-use-trailing-return-type, + -readability-avoid-unconditional-preprocessor-if, -readability-braces-around-statements, -readability-identifier-length, -readability-magic-numbers, diff --git a/include/rsl/monad.hpp b/include/rsl/monad.hpp index 81ea46d..3191ef7 100644 --- a/include/rsl/monad.hpp +++ b/include/rsl/monad.hpp @@ -169,7 +169,7 @@ template >::value_type>>> [[nodiscard]] constexpr auto operator|(T&& opt, Fn&& fn) { - return rsl::mbind(opt, fn); + return rsl::mbind(std::forward(opt), std::forward(fn)); } /** diff --git a/tests/monad.cpp b/tests/monad.cpp index 6d285e2..f19f73c 100644 --- a/tests/monad.cpp +++ b/tests/monad.cpp @@ -9,15 +9,14 @@ using namespace std::string_literals; -static constexpr auto maybe_non_zero(int in) { - return (in != 0) ? std::optional(in) : std::nullopt; -} +namespace { +constexpr auto maybe_non_zero(int in) { return (in != 0) ? std::optional(in) : std::nullopt; } -static auto maybe_lt_3_round(double in) { +auto maybe_lt_3_round(double in) { return (in < 3) ? std::optional(std::round(in)) : std::nullopt; } -static auto unsafe_divide_4_by(double val) { +auto unsafe_divide_4_by(double val) { if (val == 0) throw std::runtime_error("divide by zero"); return 4.0 / val; } @@ -25,16 +24,17 @@ static auto unsafe_divide_4_by(double val) { template using Result = tl::expected; -static Result divide(double x, double y) { +Result divide(double x, double y) { if (y == 0) return tl::unexpected("divide by 0"s); return x / y; } -static Result multiply(double x, double y) { return x * y; } +Result multiply(double x, double y) { return x * y; } -static Result divide_3(double x) { return divide(3, x); } +Result divide_3(double x) { return divide(3, x); } -static Result multiply_3(double x) { return multiply(3, x); } +Result multiply_3(double x) { return multiply(3, x); } +} // namespace TEST_CASE("rsl::mbind") { SECTION("Optional value") { @@ -210,7 +210,7 @@ TEST_CASE("operator|") { auto const k = [](auto x) { return [=](auto) { return x; }; }; auto const mul = [](auto x, auto y) { return x * y; }; auto const bind1 = [](auto fn, auto x) { return [=](auto y) { return fn(x, y); }; }; - auto const three = [](auto) { return int{3}; }; + auto const three = [](auto) { return 3; }; auto const wrap = [](auto x) { return Result{x}; }; CHECK((int{5} | i) == 5); diff --git a/tests/overload.cpp b/tests/overload.cpp index 34e159c..c06ad76 100644 --- a/tests/overload.cpp +++ b/tests/overload.cpp @@ -5,7 +5,7 @@ #include TEST_CASE("rsl::Overload") { - enum class Type { INT, FLOAT, STRING }; + enum class Type : std::uint8_t { INT, FLOAT, STRING }; auto const overload = rsl::Overload{[](int) { return Type::INT; }, [](float) { return Type::FLOAT; }, diff --git a/tests/random.cpp b/tests/random.cpp index e456521..d582993 100644 --- a/tests/random.cpp +++ b/tests/random.cpp @@ -6,7 +6,9 @@ #include -static auto const* const rng = &rsl::rng({0, 1}); +namespace { +auto const* const rng = &rsl::rng({0, 1}); +} TEST_CASE("rsl::rng") { SECTION("Repeated calls in thread yield same object") { diff --git a/tests/static_string.cpp b/tests/static_string.cpp index ecbfed4..bf11645 100644 --- a/tests/static_string.cpp +++ b/tests/static_string.cpp @@ -74,6 +74,6 @@ TEST_CASE("rsl::StaticString") { } TEST_CASE("rsl::to_string") { - CHECK(rsl::to_string(rsl::StaticString<0>()) == ""s); + CHECK(rsl::to_string(rsl::StaticString<0>()).empty()); CHECK(rsl::to_string(rsl::StaticString<10>("happy"s)) == "happy"s); } diff --git a/tests/try.cpp b/tests/try.cpp index 3aee236..4861f2c 100644 --- a/tests/try.cpp +++ b/tests/try.cpp @@ -9,10 +9,12 @@ using ExpectedType = tl::expected; -static ExpectedType check_try_macro(ExpectedType const& expected) { +namespace { +ExpectedType check_try_macro(ExpectedType const& expected) { ExpectedType::value_type value = TRY(expected); return ++value; } +} // namespace TEST_CASE("TRY") { CHECK(check_try_macro(ExpectedType(42)) == 43); From 019b0de2354add46836c12592bbc7cbb05a439df Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Mon, 24 Jun 2024 10:46:02 -0600 Subject: [PATCH 5/5] Ignore new lcov error --- .github/workflows/ci.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ef91e3e..4e06d8b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,8 @@ jobs: exclude: - preset: codecov compiler: { name: Clang } + - preset: codecov + ros_distro: humble runs-on: ubuntu-22.04 container: ghcr.io/picknikrobotics/rsl:upstream-${{ matrix.ros_distro }} env: @@ -53,7 +55,7 @@ jobs: run: cmake --build build/${{ matrix.preset }} --target tidy - name: Generate LCOV report if: ${{ matrix.preset == 'codecov' }} - run: lcov -c -d . -o coverage.info --no-external --exclude "*/build/**" + run: lcov -c -d . -o coverage.info --no-external --exclude "*/build/**" --ignore-errors mismatch - uses: codecov/codecov-action@v3 if: ${{ matrix.preset == 'codecov' }} with: