platformio/platformio-core

Allow to change Include paths for cppcheck

Open

#4,398 opened on Aug 20, 2022

View on GitHub
 (3 comments) (0 reactions) (1 assignee)Python (791 forks)batch import
help wantedstatic analysis

Repository metrics

Stars
 (7,329 stars)
PR merge metrics
 (Avg merge 109d 16h) (5 merged PRs in 30d)

Description

  • Feature Request.

Configuration

Operating system:

PlatformIO Version (platformio --version): PlatformIO Core, version 6.1.4

Description of problem

Lack of ability to exclude Includes from cppcheck analysis. Long analysis and a long output. Related conversation.

Steps to Reproduce

  1. Create project which includes hal headers from within the repository.
  2. Setup cppcheck with misra check:
  3. Perform static analysis platformio.exe check

Actual Results

Analysis that is slow and outputs thousands of MISRA violations

Component     HIGH    MEDIUM    LOW
-----------  ------  --------  -----
src            0        0        4
src\CMSIS      0        0      1173
src\Device     0        0      8279

Total          0        0      9456

Environment         Tool      Status    Duration
------------------  --------  --------  ------------
genericSTM32F103C8  cppcheck  PASSED    00:00:19.038

Expected Results

A quick analysis of user code only without entering hal headers

Component     HIGH    MEDIUM    LOW
-----------  ------  --------  -----
src            0        0        4

Total          0        0      4

Environment         Tool      Status    Duration
------------------  --------  --------  ------------
genericSTM32F103C8  cppcheck  PASSED    00:00:1.234

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
board_build.ldscript = src/Device/STM32F103XB_FLASH.ld
build_flags =
    -Isrc/CMSIS/
    -Isrc/Device

check_skip_packages = yes ;don't inlcude compiler package inludes
check_patterns = 
  src/*.c
  src/*.h
check_flags =
  cppcheck:--addon=misra --suppress=suppress.txt

Source file to reproduce issue: Working example: https://github.com/dzid26/pio-exclude-cppcheck.

Contributor guide