doc/develop/sca/codechecker.rst
.. _codechecker:
CodeChecker support ###################
CodeChecker <https://codechecker.readthedocs.io/>__ is a static analysis infrastructure.
It executes analysis tools available on the build system, such as
Clang-Tidy <https://clang.llvm.org/extra/clang-tidy/>,
Clang Static Analyzer <https://clang-analyzer.llvm.org/> and
Cppcheck <https://cppcheck.sourceforge.io/>__. Refer to the analyzer's websites for installation
instructions.
Installing CodeChecker
CodeChecker itself is a python package available on pypi <https://pypi.org/project/codechecker/>__.
.. code-block:: shell
pip install codechecker
Building with CodeChecker
To run CodeChecker, :ref:west build <west-building> should be
called with a -DZEPHYR_SCA_VARIANT=codechecker parameter, e.g.
.. code-block:: shell
west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker
Configuring CodeChecker
CodeChecker uses different command steps, each with their respective configuration parameters. The following table lists all these options.
.. list-table:: :header-rows: 1
CODECHECKER_ANALYZE_JOBSCODECHECKER_ANALYZE_OPTSanalyze command directly. (e.g. --timeout;360)CODECHECKER_CLEANUPplist files.CODECHECKER_CONFIG_FILECODECHECKER_EXPORThtml,json,codeclimate,gerrit,baseline.CODECHECKER_NAMEzephyr)CODECHECKER_PARSE_EXIT_STATUSCODECHECKER_PARSE_OPTSparse command directly. (e.g. --verbose;debug)CODECHECKER_PARSE_SKIPCODECHECKER_STOREstore command after analysis.CODECHECKER_STORE_OPTSstore command directly. Implies CODECHECKER_STORE.
(e.g. --url;localhost:8001/Default)CODECHECKER_STORE_TAG--tag to the store command.CODECHECKER_TRIM_PATH_PREFIX/home/user/zephyrproject.
The value from west topdir is added by default.These parameters can be passed on the command line, or be set as environment variables.
Running twister with CodeChecker
When running CodeChecker as part of twister some default options are set as following:
.. list-table:: :header-rows: 1
CODECHECKER_ANALYZE_JOBS1CODECHECKER_NAME<board target>:<testsuite name>CODECHECKER_STORE_TAGgit describe in the application source directory.To override these values, set an environment variable or pass them as extra arguments.