Open dzid26 opened 2 years ago
Hi @dzid26 ! As you may know Cppcheck analyzes your code in terms of translation units. Hence, Cppcheck needs to expand all specified header files (including third-party libraries/frameworks/HALs/etc.). That's the main reason why the analysis may be slow, but on the other hand, you receive the most accurate results. If the accuracy is not an issue, then the --suppress
option would be the best workaround at the moment.
Understood.
Also, I imagine that for projects using Platformio's frameworks, checking framework headers could be avoided using check_skip_packages = yes
?
Regarding the headers expansion though, cppcheck manual discourages including system headers:
Also, I imagine that for projects using Platformio's frameworks, checking framework headers could be avoided using check_skip_packages = yes?
That's right. This feature was added as a fall-back option mainly because Cppcheck's preprocessor is simply not capable of parsing some of currently available embedded frameworks.
Regarding the headers expansion though, cppcheck manual discourages including system headers:
PlatformIO supports several static analysis tools and even though Cppcheck may discourage specifying all headers, other tools may rely on complete translation units. Besides, in PlatformIO scope, only the platform packages (toolchains, frameworks, etc.) are considered system headers. That's where check_skip_packages
can be used to avoid these headers. IMO, once you put a low-level framework inside your project, the headers from that frameworks shouldn't be considered as system ones.
Configuration
Operating system:
PlatformIO Version (
platformio --version
): PlatformIO Core, version 6.1.4Description of problem
Lack of ability to exclude Includes from cppcheck analysis. Long analysis and a long output. Related conversation.
Steps to Reproduce
platformio.exe check
Actual Results
Analysis that is slow and outputs thousands of MISRA violations
Expected Results
A quick analysis of user code only without entering hal headers
If problems with PlatformIO Build System:
The content of
platformio.ini
:Source file to reproduce issue: Working example: https://github.com/dzid26/pio-exclude-cppcheck.