From 128bcdd54f2ea60bd4453294296ce7ab90f7cbac Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 7 Jun 2026 13:47:47 +0300 Subject: [PATCH 1/2] Revise versioning and usage details in README Updated versioning information and clarified intended use case. --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6aedcbe..01deb1d 100644 --- a/README.md +++ b/README.md @@ -66,11 +66,10 @@ standards-compliant C99 compiler is available. ## Revisions -### v3.0 -- WORK IN PROGRESS +### v3.0.alpha The library has been redesigned from scratch to support Cyphal v1.1 and named topics. -No porting guide is provided since the changes are too significant; -please refer to the new API docs in `libudpard/udpard.h`. +The main intended use case is with [**Cy**](https://github.com/OpenCyphal-Garage/cy) rather than standalone. ### v2.0 From f2f74ba3e1059500f9edfd24461003baf46109fb Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 7 Jun 2026 14:04:01 +0300 Subject: [PATCH 2/2] Remove Sonar integration --- .github/workflows/main.yml | 50 ------------------------- CONTRIBUTING.md | 1 - README.md | 2 - libudpard/udpard.c | 14 +++---- tools/run_sonar.sh | 75 -------------------------------------- 5 files changed, 7 insertions(+), 135 deletions(-) delete mode 100755 tools/run_sonar.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7efd7c..3ef62de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -159,56 +159,6 @@ jobs: sudo apt-get install -y gcc-arm-none-eabi - run: arm-none-eabi-gcc -Ilib/cavl/ libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }} - sonar: - runs-on: ubuntu-latest - container: ghcr.io/opencyphal/toolshed:ts24.4.3 - if: > - ( - (github.event_name == 'pull_request' || contains(github.ref, '/main') || contains(github.ref, '/release')) && - !contains(github.event.head_commit.message, '#yolo') - ) || ( - contains(github.event.head_commit.message, '#sonar') - ) - env: - SONAR_SCANNER_VERSION: 5.0.1.3006 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - submodules: true - - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: "zulu" - # language=bash - - run: | - clang --version - - name: Install Sonar tools - env: - SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip - BUILD_WRAPPER_DOWNLOAD_URL: https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip - # language=bash - run: | - mkdir -p $HOME/.sonar - curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }} - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH - curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }} - unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ - echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH - # Sonar is not run on builds originating from forks due to secrets not being available (avoids errors). - # language=bash - - run: | - [ -z "$SONAR_TOKEN" ] || tools/run_sonar.sh - - uses: actions/upload-artifact@v4 - if: always() - with: - name: ${{github.job}} - path: ${{github.workspace}}/ - retention-days: 3 - style_check: if: github.event_name == 'push' runs-on: ubuntu-latest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2875211..9197a71 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,6 @@ ## Standards The library shall be implemented in ISO C99/C11 following MISRA C:2012. -The MISRA compliance is enforced by Clang-Tidy and SonarQube. Deviations are documented directly in the source code as follows: ```c diff --git a/README.md b/README.md index 01deb1d..8ac0807 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,6 @@ # Cyphal/UDP transport in C [![Main Workflow](https://github.com/OpenCyphal-Garage/libudpard/actions/workflows/main.yml/badge.svg)](https://github.com/OpenCyphal-Garage/libudpard/actions/workflows/main.yml) -[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=libudpard&metric=reliability_rating)](https://sonarcloud.io/summary?id=libudpard) -[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=libudpard&metric=coverage)](https://sonarcloud.io/summary?id=libudpard) [![Forum](https://img.shields.io/discourse/users.svg?server=https%3A%2F%2Fforum.opencyphal.org&color=1700b3)](https://forum.opencyphal.org) diff --git a/libudpard/udpard.c b/libudpard/udpard.c index 5c47607..75a1d22 100644 --- a/libudpard/udpard.c +++ b/libudpard/udpard.c @@ -19,15 +19,15 @@ /// To disable assertion checks completely, make it expand into `(void)(0)`. #ifndef UDPARD_ASSERT // Intentional violation of MISRA: assertion macro cannot be replaced with a function definition. -#define UDPARD_ASSERT(x) assert(x) // NOSONAR +#define UDPARD_ASSERT(x) assert(x) #endif #if __STDC_VERSION__ < 201112L // Intentional violation of MISRA: static assertion macro cannot be replaced with a function definition. -#define static_assert(x, ...) typedef char _static_assert_gl(_static_assertion_, __LINE__)[(x) ? 1 : -1] // NOSONAR -#define _static_assert_gl(a, b) _static_assert_gl_impl(a, b) // NOSONAR +#define static_assert(x, ...) typedef char _static_assert_gl(_static_assertion_, __LINE__)[(x) ? 1 : -1] +#define _static_assert_gl(a, b) _static_assert_gl_impl(a, b) // Intentional violation of MISRA: the paste operator ## cannot be avoided in this context. -#define _static_assert_gl_impl(a, b) a##b // NOSONAR +#define _static_assert_gl_impl(a, b) a##b #endif #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) @@ -36,8 +36,8 @@ #define CAVL2_T udpard_tree_t #define CAVL2_RELATION int32_t -#define CAVL2_ASSERT(x) UDPARD_ASSERT(x) // NOSONAR -#include "cavl2.h" // NOSONAR +#define CAVL2_ASSERT(x) UDPARD_ASSERT(x) +#include "cavl2.h" typedef unsigned char byte_t; ///< For compatibility with platforms where byte size is not 8 bits. @@ -135,7 +135,7 @@ static const byte_t* deserialize_u32(const byte_t* ptr, uint32_t* const out_valu UDPARD_ASSERT((ptr != NULL) && (out_value != NULL)); *out_value = 0; for (size_t i = 0; i < 4U; i++) { - *out_value |= (uint32_t)((uint32_t)*ptr << (i * 8U)); // NOLINT(google-readability-casting) NOSONAR + *out_value |= (uint32_t)((uint32_t)*ptr << (i * 8U)); // NOLINT(google-readability-casting) ptr++; } return ptr; diff --git a/tools/run_sonar.sh b/tools/run_sonar.sh deleted file mode 100755 index 0fcba11..0000000 --- a/tools/run_sonar.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env sh -# This helper script is mostly invoked from a CI workflow, -# but it can also be used to submit SonarCloud analysis from a developer's machine directly, -# which is useful during large refactorings. -# -# Usage: install the SonarCloud build wrapper and scanner as explained in the official docs -# (or simply follow the steps defined in the CI workflow that does the same), then run this script. - -set -u - -die() -{ - echo "$@" 1>&2 - exit 1 -} - -ensure_executable() { command -v $1 || die "Executable not found: $1" ; } - -# Check preconditions early. -[ -z "$SONAR_TOKEN" ] && die "SonarCloud token is not set" -ensure_executable build-wrapper-linux-x86-64 -ensure_executable sonar-scanner -ensure_executable llvm-profdata -ensure_executable llvm-cov - -cd "${0%/*}/.." && [ -f libudpard/udpard.c ] && [ -f LICENSE ] || die "Could not cd to the project root" -echo "Working directory: $(pwd)" - -# Set up a clean build directory. This is necessary for the analysis to be correct and complete. -BUILD_DIR=sonar_build -rm -rf $BUILD_DIR >/dev/null 2>&1 -mkdir $BUILD_DIR && cd $BUILD_DIR || die - -# Build everything and run the test suite; merge the coverage data. -# Clang produces better coverage reports than GCC for heavily templated code. -# It is also supposed to work well with optimizations. -# RTFM: https://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation -# https://clang.llvm.org/docs/SourceBasedCodeCoverage.html -profile_flags="-fprofile-instr-generate='%p.profraw' -fcoverage-mapping" -cmake .. \ --DNO_STATIC_ANALYSIS=1 \ --DCMAKE_BUILD_TYPE=Debug \ --DCMAKE_C_COMPILER=clang \ --DCMAKE_CXX_COMPILER=clang++ \ --DCMAKE_C_FLAGS="$profile_flags" \ --DCMAKE_CXX_FLAGS="$profile_flags" || die "CMake failed" -build-wrapper-linux-x86-64 --out-dir . make VERBOSE=1 -j"$(nproc)" || die "Build wrapper failed" -make test ARGS="--verbose" || die "Test execution failed" -# These tools shall be of the same version as LLVM/Clang. -llvm-profdata merge -sparse tests/*.profraw -o profdata || die - -# Generate coverage reports both for the SonarCloud scanner and for us humans. -llvm_cov_objects="" -for file in tests/test_*_*; do llvm_cov_objects="$llvm_cov_objects -object $file"; done -echo "llvm-cov objects: $llvm_cov_objects" -llvm-cov report $llvm_cov_objects -instr-profile=profdata || die -llvm-cov show $llvm_cov_objects -instr-profile=profdata -format=text > "coverage.txt" || die -llvm-cov show $llvm_cov_objects -instr-profile=profdata -format=html > "coverage.html" || die - -# Run SonarScanner from the project root. -cd .. -[ -d $BUILD_DIR ] || die "Unexpected directory structure" -# Please keep the entire sonar configuration only here to maintain encapsulation and simplicity. -# Related: https://community.sonarsource.com/t/analyzing-a-header-only-c-library/51468 -sonar-scanner \ ---define sonar.host.url="https://sonarcloud.io" \ ---define sonar.projectName=libudpard \ ---define sonar.organization=opencyphal-garage \ ---define sonar.projectKey=libudpard \ ---define sonar.sources=libudpard \ ---define sonar.exclusions=libudpard/_udpard_cavl.h \ ---define sonar.cfamily.compile-commands="$BUILD_DIR/compile_commands.json" \ ---define sonar.cfamily.llvm-cov.reportPath="$BUILD_DIR/coverage.txt" \ ---define sonar.cfamily.threads="$(nproc)" \ -|| die