.pio/libdeps being included in cppcheck static checks

I am running the Platformio static checking using pio check --skip-packages -e esp32 and files in .pio/libdeps are being included in the output and polluting it (it’s surprising how many warnings these libraries have!).

My platformio.ini is:

[platformio]

[env] ;Common is done for all environments
monitor_speed = 115200
monitor_flags= --raw

lib_extra_dirs =
  ./shared-config

lib_deps =
  bblanchon/ArduinoJson @ ^6.17.2
  adafruit/Adafruit ADS1X15 @ ^1.1.1
  adafruit/Adafruit MCP4728 @ ^1.0.7
  adafruit/Adafruit NeoPixel @ ^1.7.0
  arduino-libraries/NTPClient @ ^3.1.0

test_build_project_src = true ;The test protocol will build the contents of the src folder when running tests. Allows us to test functions inside src

; ==== STATIC CHECKING ====
check_tool = cppcheck ; pvs-studio, cppcheck, clangtidy
check_flags = 
 cppcheck: --enable=all
 cppcheck: --inline-suppr
 cppcheck: --suppress=*:.pio/*

[extra]
extra_scripts_default =
  shared/moveOutputBinaries.py

build_flags_default =
  -DDEBUG_ESP_PORT=Serial
  -DDEBUG_BUILD
  -DWEBSOCKET_DISABLED
  !python shared/GetCurrentDateTime.py
  !python shared/GetGitHash.py
;==========ESP32===========
[env:esp32]
platform = espressif32
board = esp32dev
framework = arduino
build_type = debug
debug_tool = esp-prog
; monitor_filters = esp32_exception_decoder
build_flags =
  ${extra.build_flags_default}
extra_scripts = ${extra.extra_scripts_default}
debug_init_break = tbreak setup

I have also tried including check_flags = cppcheck: --suppress=*:.pio/* but that doesn’t work.

Is there something I’m doing wrong?

Anyone have any ideas for this?

Still can’t quite figure it out, it is a bit strange though since only some of the libraries from .pio are being included. Like the ADS1x15 package has so many problems with it but is not included in the output.

Maybe @valeros can help.

Hi @fr1 ! I guess the warnings are from header files? The reason you see that defects is because headers from that libraries are included somewhere in your main code. Cppecheck analyzes code on the level of translation units which means that headers and macros are expanded (including those from external libs). It seems that they should be suppressed according to your check flags, but I have some doubts about your syntax:

check_flags = 
 cppcheck: --enable=all
 cppcheck: --inline-suppr
 cppcheck: --suppress=*:.pio/*

You’d better declare your flags in one line as in the docs Redirecting...

check_flags = 
 cppcheck: --enable=all --inline-suppr --suppress=*:.pio/*
1 Like

It looks like all on one line vs separate lines didn’t make a difference but I found the problem. I was referencing it relative to my project root: --suppress=*:.pio/* but changing it to --suppress=*:*/.pio/* has fixed it.

Thanks for your help, making it a one-liner has made .ini look a bit cleaner at least