Skip to content

[Code health] Perform cppcheck cleanup #5

[Code health] Perform cppcheck cleanup

[Code health] Perform cppcheck cleanup #5

Workflow file for this run

name: cppcheck
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up dependencies
run: |
sudo apt update -y
sudo apt install -y --no-install-recommends --no-install-suggests \
build-essential \
cppcheck \
cmake \
ninja-build \
libssl-dev \
libcurl4-openssl-dev \
libprotobuf-dev \
protobuf-compiler \
libgmock-dev \
libgtest-dev \
libbenchmark-dev
- name: Prepare CMake
run: |
mkdir build && cd build
CC="clang" CXX="clang++" cmake ..
- name: Run cppcheck
run: |
cppcheck \
--force \
--enable=warning,performance,portability \
--inline-suppr \
--suppress=unknownMacro:exporters/etw/include/opentelemetry/exporters/etw/TraceLoggingDynamic.h \
--language=c++ \
--std=c++14 \
-I api/include \
-I exporters/elasticsearch/include \
-I exporters/etw/include \
-I exporters/memory/include \
-I exporters/ostream/include \
-I exporters/otlp/include \
-I exporters/prometheus/include \
-I exporters/zipkin/include \
-I ext/include \
-I opentracing-shim/include \
-I sdk/include \
-i build \
-i test \
-i third_party \
-j $(nproc) \
. 2>&1 | tee cppcheck.log
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Logs (cppcheck)
path: ./cppcheck.log
- name: Count warnings
run: |
set +e
COUNT=`grep -c -E "\[.+\]" cppcheck.log`
echo "cppcheck reported ${COUNT} warning(s)"
if [ $COUNT -ne 0 ] ; then exit 1 ; fi