Skip to content

Allow users to pass project args to the "static-analysis" cppcheck reusable workflow #607

@jphickey

Description

@jphickey

Checklist (Please check before submitting)

  • I reviewed the Contributing Guide.
  • I reviewed the cFS README.md file to see if the feature is in the major future work.
  • I performed a cursory search to see if the feature request is relevant, not redundant, nor in conflict with other tickets.

Is your feature request related to a problem? Please describe.
The issue observed in nasa/osal#1324 is due to the fact that cppcheck is being executed in each C source file in isolation. In this case it does not see the definition of UT_DEFAULT_STUB and thus does not know how to examine this line.

Describe the solution you'd like
cppcheck allows command line options to specify various project-specific preprocessor settings, such as -D and -U options to specify if a macro is set or unset, respectively, as well as -I option(s) indicating where to find include files.

Furthermore, with CMake, the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON option causes cmake to export a json file containing the full include path being used, which can then be passed to cppcheck via the --project option. With this, the code will be examined using the configuration that is actually being compiled.

Describe alternatives you've considered

  1. Skip checking of UT stubs in general (but stubs could have bugs like uninitialized vars and things that cppcheck could flag)
  2. Remove use of UT_DEFAULT_STUB, as this will not be checkable unless the definition of this macro is also supplied.

Additional context
Using --project causes cppcheck to be much more thorough in its results. In particular, it now "sees" the common_types.h file and the ifdef macros that exist in there, and it will check each macro both ways. The upside to this is it finds more potential issues, particularly with ifdef branches that aren't regularly used, but the downside is that it significantly increases the runtime of cppcheck as it tests all the permutations. This may need to be limited if it becomes excessive.

Requester Info
Joseph Hickey, Vantage Systems, Inc.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions