Hi,
I want to simply run a static code analysis of my Platformio projects (C++ sketch/libs)
I want to launch this analysis via GitHub actions during the build process, is there something
that platformio can do to help me doing it?
Is there some integrations with platformio to the major analysis tools like SonarQube and others?
Thanks
It’s ready for use. Just use pio check — PlatformIO latest documentation
There is an example how to setup Github Actions and PlatformIO Core GitHub Actions — PlatformIO latest documentation
love your PlatformIO, thanks for it Ivan and congratulations.
this is the output of the command (I runned it in the GitHub Actions environment with a config similar to the one in your docs),
platformio check --verbose --severity=high
I don’t understand the output :
Checking /home/runner/work/smart_thermostat/smart_thermostat/src/Smartostat.cpp: PLATFORMIO=40303;ESP8266=1;ARDUINO_ARCH_ESP8266=1;ARDUINO_ESP8266_WEMOS_D1MINI=1;TARGET_SMARTOSTAT=1;MQTT_MAX_PACKET_SIZE=1024;F_CPU=160000000L;__ets__=1;ICACHE_FLASH=1;ARDUINO=10805;ARDUINO_BOARD="PLATFORMIO_D1_MINI";FLASHMODE_DIO=1;LWIP_OPEN_SRC=1;NONOSDK22x_190703=1;TCP_MSS=536;LWIP_FEATURES=1;LWIP_IPV6=0;VTABLES_IN_FLASH=1;__DBL_MIN_EXP__=(-1021);__UINT_LEAST16_MAX__=65535;__ATOMIC_ACQUIRE=2;__FLT_MIN__=1.1754943508222875e-38F;__UINT_LEAST8_TYPE__=unsigned char;__INTMAX_C(c)=c ## LL;__CHAR_BIT__=8;__UINT8_MAX__=255;__WINT_MAX__=4294967295U;__ORDER_LITTLE_ENDIAN__=1234;__SIZE_MAX__=4294967295U;__WCHAR_MAX__=65535;__DBL_DENORM_MIN__=double(4.9406564584124654e-324L);__GCC_ATOMIC_CHAR_LOCK_FREE=1;__FLT_EVAL_METHOD__=0;__GCC_ATOMIC_CHAR32_T_LOCK_FREE=1;__UINT_FAST64_MAX__=18446744073709551615ULL;__SIG_ATOMIC_TYPE__=int;__DBL_MIN_10_EXP__=(-307);__FINITE_MATH_ONLY__=0;__GNUC_PATCHLEVEL__=2;__UINT_FAST8_MAX__=4294967295U;__DEC64_MAX_EXP__=385;__INT8_C(c)=c;__UINT_LEAST64_MAX__=18446744073709551615ULL;__SHRT_MAX__=32767;__LDBL_MAX__=1.7976931348623157e+308L;__UINT_LEAST8_MAX__=255;__GCC_ATOMIC_BOOL_LOCK_FREE=1;__UINTMAX_TYPE__=long long unsigned int;__DEC32_EPSILON__=1E-6DF;__CHAR_UNSIGNED__=1;__UINT32_MAX__=4294967295UL;__LDBL_MAX_EXP__=1024;__WINT_MIN__=0U;__SCHAR_MAX__=127;__WCHAR_MIN__=0;__INT64_C(c)=c ## LL;__DBL_DIG__=15;__GCC_ATOMIC_POINTER_LOCK_FREE=1;__XTENSA_CALL0_ABI__=1;__SIZEOF_INT__=4;__SIZEOF_POINTER__=4;__GCC_ATOMIC_CHAR16_T_LOCK_FREE=1;__USER_LABEL_PREFIX__=1;__STDC_HOSTED__=1;__LDBL_HAS_INFINITY__=1;__XTENSA_EL__=1;__FLT_EPSILON__=1.1920928955078125e-7F;__GXX_WEAK__=1;__LDBL_MIN__=2.2250738585072014e-308L;__DEC32_MAX__=9.999999E96DF;__INT32_MAX__=2147483647L;__SIZEOF_LONG__=4;__UINT16_C(c)=c;__DECIMAL_DIG__=17;__LDBL_HAS_QUIET_NAN__=1;__GNUC__=4;__FLT_HAS_DENORM__=1;__SIZEOF_LONG_DOUBLE__=8;__BIGGEST_ALIGNMENT__=16;__DBL_MAX__=double(1.7976931348623157e+308L);__INT_FAST32_MAX__=2147483647;__DBL_HAS_INFINITY__=1;__INT64_MAX__=9223372036854775807LL;__DEC32_MIN_EXP__=(-94);__INT_FAST16_TYPE__=int;__LDBL_HAS_DENORM__=1;__cplusplus=199711L;__DEC128_MAX__=9.999999999999999999999999999999999E6144DL;__INT_LEAST32_MAX__=2147483647L;__DEC32_MIN__=1E-95DF;__DEPRECATED=1;__DBL_MAX_EXP__=1024;__DEC128_EPSILON__=1E-33DL;__PTRDIFF_MAX__=2147483647;__GNUG__=4;__LONG_LONG_MAX__=9223372036854775807LL;__SIZEOF_SIZE_T__=4;__SIZEOF_WINT_T__=4;__GXX_ABI_VERSION=1002;__FLT_MIN_EXP__=(-125);__INT_FAST64_TYPE__=long long int;__DBL_MIN__=double(2.2250738585072014e-308L);__FLT_MIN_10_EXP__=(-37);__DEC128_MIN__=1E-6143DL;__REGISTER_PREFIX__=1;__UINT16_MAX__=65535;__DBL_HAS_DENORM__=1;__UINT8_TYPE__=unsigned char;__NO_INLINE__=1;__FLT_MANT_DIG__=24;__VERSION__="4.8.2";__UINT64_C(c)=c ## ULL;__XTENSA_SOFT_FLOAT__=1;__GCC_ATOMIC_INT_LOCK_FREE=1;__FLOAT_WORD_ORDER__=__ORDER_LITTLE_ENDIAN__;__INT32_C(c)=c ## L;__DEC64_EPSILON__=1E-15DD;__ORDER_PDP_ENDIAN__=3412;__DEC128_MIN_EXP__=(-6142);__INT_FAST32_TYPE__=int;__UINT_LEAST16_TYPE__=short unsigned int;__INT16_MAX__=32767;__SIZE_TYPE__=unsigned int;__UINT64_MAX__=18446744073709551615ULL;__INT8_TYPE__=signed char;__ELF__=1;__xtensa__=1;__FLT_RADIX__=2;__INT_LEAST16_TYPE__=short int;__LDBL_EPSILON__=2.2204460492503131e-16L;__UINTMAX_C(c)=c ## ULL;__SIG_ATOMIC_MAX__=2147483647;__GCC_ATOMIC_WCHAR_T_LOCK_FREE=1;__SIZEOF_PTRDIFF_T__=4;__DEC32_SUBNORMAL_MIN__=0.000001E-95DF;__INT_FAST16_MAX__=2147483647;__UINT_FAST32_MAX__=4294967295U;__UINT_LEAST64_TYPE__=long long unsigned int;__FLT_HAS_QUIET_NAN__=1;__FLT_MAX_10_EXP__=38;__LONG_MAX__=2147483647L;__DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL;__FLT_HAS_INFINITY__=1;__UINT_FAST16_TYPE__=unsigned int;__DEC64_MAX__=9.999999999999999E384DD;__CHAR16_TYPE__=short unsigned int;__PRAGMA_REDEFINE_EXTNAME=1;__INT_LEAST16_MAX__=32767;__DEC64_MANT_DIG__=16;__UINT_LEAST32_MAX__=4294967295UL;__GCC_ATOMIC_LONG_LOCK_FREE=1;__INT_LEAST64_TYPE__=long long int;__INT16_TYPE__=short int;__INT_LEAST8_TYPE__=signed char;__DEC32_MAX_EXP__=97;__INT_FAST8_MAX__=2147483647;__INTPTR_MAX__=2147483647;__LDBL_MANT_DIG__=53;__DBL_HAS_QUIET_NAN__=1;__SIG_ATOMIC_MIN__=(-__SIG_ATOMIC_MAX__ - 1);__INTPTR_TYPE__=int;__UINT16_TYPE__=short unsigned int;__WCHAR_TYPE__=short unsigned int;__SIZEOF_FLOAT__=4;__UINTPTR_MAX__=4294967295U;__DEC64_MIN_EXP__=(-382);__INT_FAST64_MAX__=9223372036854775807LL;__GCC_ATOMIC_TEST_AND_SET_TRUEVAL=1;__FLT_DIG__=6;__UINT_FAST64_TYPE__=long long unsigned int;__INT_MAX__=2147483647;__INT64_TYPE__=long long int;__FLT_MAX_EXP__=128;__DBL_MANT_DIG__=53;__INT_LEAST64_MAX__=9223372036854775807LL;__DEC64_MIN__=1E-383DD;__WINT_TYPE__=unsigned int;__UINT_LEAST32_TYPE__=long unsigned int;__SIZEOF_SHORT__=2;__LDBL_MIN_EXP__=(-1021);__INT_LEAST8_MAX__=127;__WCHAR_UNSIGNED__=1;__LDBL_MAX_10_EXP__=308;__ATOMIC_RELAXED=0;__DBL_EPSILON__=double(2.2204460492503131e-16L);__UINT8_C(c)=c;__INT_LEAST32_TYPE__=long int;__SIZEOF_WCHAR_T__=2;__UINT64_TYPE__=long long unsigned int;__INT_FAST8_TYPE__=int;__DBL_DECIMAL_DIG__=17;__DEC_EVAL_METHOD__=2;__XTENSA__=1;__ORDER_BIG_ENDIAN__=4321;__UINT32_C(c)=c ## UL;__INTMAX_MAX__=9223372036854775807LL;__BYTE_ORDER__=__ORDER_LITTLE_ENDIAN__;__FLT_DENORM_MIN__=1.4012984643248171e-45F;__INT8_MAX__=127;__UINT_FAST32_TYPE__=unsigned int;__CHAR32_TYPE__=long unsigned int;__FLT_MAX__=3.4028234663852886e+38F;__INT32_TYPE__=long int;__SIZEOF_DOUBLE__=8;__INTMAX_TYPE__=long long int;__DEC128_MAX_EXP__=6145;__ATOMIC_CONSUME=1;__GNUC_MINOR__=8;__UINTMAX_MAX__=18446744073709551615ULL;__DEC32_MANT_DIG__=7;__DBL_MAX_10_EXP__=308;__LDBL_DENORM_MIN__=4.9406564584124654e-324L;__INT16_C(c)=c;__STDC__=1;__PTRDIFF_TYPE__=int;__ATOMIC_SEQ_CST=5;__UINT32_TYPE__=long unsigned int;__UINTPTR_TYPE__=unsigned int;__DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD;__DEC128_MANT_DIG__=34;__LDBL_MIN_10_EXP__=(-307);__SIZEOF_LONG_LONG__=8;__GCC_ATOMIC_LLONG_LOCK_FREE=1;__LDBL_DIG__=15;__FLT_DECIMAL_DIG__=9;__UINT_FAST16_MAX__=4294967295U;__GNUC_GNU_INLINE__=1;__GCC_ATOMIC_SHORT_LOCK_FREE=1;__UINT_FAST8_TYPE__=unsigned int;__ATOMIC_ACQ_REL=4;__ATOMIC_RELEASE=3...
[91](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:91)
[92](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:92)2/2 files checked 100% done
[93](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:93)
[94](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:94)
[95](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:95)Error: cppcheck failed to perform check! Please examine tool output in verbose mode.
[96](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:96)========================== [FAILED] Took 2.04 seconds ==========================
[97](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:97)
[98](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:98)Environment Tool Status Duration
[99](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:99)------------- -------- -------- ------------
[100](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:100)smartoled cppcheck FAILED 00:00:02.963
[101](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:101)smartostat cppcheck FAILED 00:00:02.041
[102](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:102)==================== 2 failed, 0 succeeded in 00:00:05.004 ====================
[103](https://github.com/sblantipodi/smart_thermostat/runs/659163373?check_suite_focus=true#step:8:103)##[error]Process completed with exit code 1.
This message is triggered when the checking tool return a return-code not equal to 0
Which is weird if the Checking ...
output comes that should be from cppcheck
right?
When you run the verbose command, the first output should be the invocation of the tool itself, like
C:\Users\Maxi\.platformio\packages\tool-cppcheck\cppcheck --error-exitcode=1 --verbose --template="severity={severity}<&PIO&>message={message}<&PIO&>file={file}<&PIO&>line={line}<&PIO&>column={column}<&PIO&>callstack={callstack}<&PIO&>cwe={cwe}<&PIO&>id={id}" --inline-suppr --platform=unspecified --enable=warning,style,performance,portability,unusedFunction --language=c -DPLATFORMIO=40304 -DSTM32F1xx -DSTM32F105xC -DARM_MATH_CM3 -DCOMPONENT_NSPE=1 -DCOMPONENT_PSA_SRV_EMUL=1 -DCOMPONENT_PSA_SRV_IMPL=1 -DDEVICE_ANALOGIN=1 -DDEVICE_CAN=1 -DDEVICE_CRC=1 -DDEVICE_FLASH=1 -DDEVICE_I2C=1 -DDEVICE_I2CSLAVE=1 -DDEVICE_I2C_ASYNCH=1 -DDEVICE_INTERRUPTIN=1 -DDEVICE_PORTIN=1 -DDEVICE_PORTINOUT=1 -DDEVICE_PORTOUT=1 -DD
Can you manually execute that command and see if there is any error output?
found this error by manually triggering the command:
Error: Found a breaking defect ‘syntax error’ in /home/runner/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_features.h:44
Please note: check results might not be valid!
Try adding --skip-packages
“severity=error<&PIO&>message=syntax error<&PIO&>file=/home/runner/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_features.h<&PIO&>line=44<&PIO&>column=5<&PIO&>callstack=[/home/runner/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/core_esp8266_features.h:44]<&PIO&>cwe=0<&PIO&>id=syntaxError”
sblantipodi:
–skip-packages
if I add --skip-package to the command it works.
is this a platformio bug? it seems that is found blocking errors on
core_esp8266_features.h
and I don’t think that this is true.
what kind of static analysis this tool does?
what kind of errors does it detects?
thanks
Can you give a minimal project with which the problem occurs? Does this already happen on an ESP8266 Arduino Blinky sketch?
See cppcheck
documentation at cppcheck / Wiki / ListOfChecks .
It’s a bug in Cppcheck tool #9685 (Handle 'extern "C++"') – Cppcheck , please use -–skip-packages
so PlatformIO will only check your project sources.
1 Like
When using the platformIO interface in VSCode, where am I to set the setting --skip-packages
?
It works if I check using the command line, but not from the IDE, as I am not able to set the flag for the pio check
command emitted by the IDE.
If it’s not included in the VSCode GUI, you can also use Advanced scripting to call into pio check --skip-packages
– that’s basically the example only slightly adapted. Since this looks like a bug in cppcheck that hopefully gets resolved sometime, we shouldn’t put this workaround option in the GUI…
EDIT: Use what @valeros said instead of my solution
valeros
November 3, 2020, 7:05pm
12
Hi @lsangild ! You can use check_skip_packages = yes
in your platformio.ini
.
3 Likes
This has just taken me 1h to find, found the commit and everything Refactor PIO Check feature by valeros · Pull Request #3478 · platformio/platformio-core · GitHub
but no idea how to set it so that PIO home would run it. can this be added to the documentation please!
Although it works in the command line im still getting BAD JSON in the GUI for code analysis.
You have set check_skip_packages = yes
in the platformio.ini
?
yes, got there in the end. It was throwing bad json, even though the pio check passed on the command line because of another error in a different [env]. some more verbose output would be good, but got it working thank you
1 Like