develop/sca/codechecker.html · develop/sca/codechecker.rst 공식 원문 ↗

Zephyr 3.7.0 · Develop · SCA · CodeChecker

CodeChecker 지원

여러 analyzer를 한 pipeline으로 실행하고 결과를 저장·export하거나 CI gate로 사용합니다.

Official pathdevelop/sca/codechecker.html
Source filedevelop/sca/codechecker.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

Clang-Tidy·Clang Static Analyzer·Cppcheck를 CodeChecker로 실행하고 analyze/store/parse option과 report 형식, exit status를 구성합니다.

Analyze

variant · config · timeout

Store

server · build name

CI

export · exit status

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 8124182BADAFA4395DD04CA91C62D1A7B9B437C873E3542D64C2FCFC471AE9FE
.. _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 <http://clang.llvm.org/extra/clang-tidy/>`__,
`Clang Static Analyzer <http://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

Running 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
***********************

To configure CodeChecker or analyzers used, arguments can be passed using the
``CODECHECKER_ANALYZE_OPTS`` parameter, e.g.

.. code-block:: shell

    west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
    -DCODECHECKER_ANALYZE_OPTS="--config;$CODECHECKER_CONFIG_FILE;--timeout;60"


Storing CodeChecker results
***************************

If a CodeChecker server is active the results can be uploaded and stored for tracking purposes.
Storing is done using the optional ``CODECHECKER_STORE=y`` or ``CODECHECKER_STORE_OPTS="arg;list"``
parameters, e.g.

.. code-block:: shell

    west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
    -DCODECHECKER_STORE_OPTS="--name;build;--url;localhost:8001/Default"

.. note::

    If ``--name`` isn't passed to either ``CODECHECKER_ANALYZE_OPTS`` or ``CODECHECKER_STORE_OPTS``,
    the default ``zephyr`` is used.


Exporting CodeChecker reports
*****************************

Optional reports can be generated using the CodeChecker results, when passing a
``-DCODECHECKER_EXPORT=<type>`` parameter. Allowed types are: ``html,json,codeclimate,gerrit,baseline``.
Multiple types can be passed as comma-separated arguments.

Optional parser configuration arguments can be passed using the
``CODECHECKER_PARSE_OPTS`` parameter, e.g.

.. code-block:: shell

    west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
    -DCODECHECKER_EXPORT=html,json -DCODECHECKER_PARSE_OPTS="--trim-path-prefix;$PWD"

Failing the build on CodeChecker issues
***************************************

By default, CodeChecker identified issues will not fail the build, only generate
a report. To fail the build if any issues are found (for example, for use in
CI), pass the ``CODECHECKER_PARSE_EXIT_STATUS=y`` parameter, e.g.

.. code-block:: shell

    west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
    -DCODECHECKER_PARSE_EXIT_STATUS=y

Part 3

한국어 전문 번역

CodeChecker 지원

CodeChecker는 static analysis infrastructure입니다. Build system에서 사용할 수 있는 Clang-Tidy, Clang Static Analyzer, Cppcheck 같은 분석 도구를 실행합니다. 설치 방법은 각 analyzer website를 참조하십시오.

CodeChecker 설치

CodeChecker 자체는 PyPI에서 제공하는 Python package입니다.

pip install codechecker

CodeChecker로 실행

west build를 -DZEPHYR_SCA_VARIANT=codechecker parameter와 함께 호출합니다.

west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker

CodeChecker 구성

CodeChecker 또는 사용하는 analyzer를 구성하려면 CODECHECKER_ANALYZE_OPTS parameter로 argument를 전달합니다.

west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
-DCODECHECKER_ANALYZE_OPTS="--config;$CODECHECKER_CONFIG_FILE;--timeout;60"

CodeChecker 결과 저장

CodeChecker server가 실행 중이면 추적 목적으로 결과를 upload하고 저장할 수 있습니다. 선택적인 CODECHECKER_STORE=y 또는 CODECHECKER_STORE_OPTS="arg;list" parameter를 사용합니다.

west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
-DCODECHECKER_STORE_OPTS="--name;build;--url;localhost:8001/Default"

CodeChecker report export

-DCODECHECKER_EXPORT=<type> parameter를 전달하면 CodeChecker 결과로 선택적 report를 생성할 수 있습니다. 허용 type은 html, json, codeclimate, gerrit, baseline입니다. 여러 type은 comma로 구분합니다.

CODECHECKER_PARSE_OPTS parameter로 선택적인 parser configuration argument를 전달할 수 있습니다.

west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
-DCODECHECKER_EXPORT=html,json -DCODECHECKER_PARSE_OPTS="--trim-path-prefix;$PWD"

CodeChecker issue 발견 시 build 실패

기본적으로 CodeChecker가 issue를 찾아도 build가 실패하지 않고 report만 생성합니다. CI 등에서 issue가 하나라도 있으면 build를 실패시키려면 CODECHECKER_PARSE_EXIT_STATUS=y를 전달합니다.

west build -b mimxrt1064_evk samples/basic/blinky -- -DZEPHYR_SCA_VARIANT=codechecker \
-DCODECHECKER_PARSE_EXIT_STATUS=y

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.