mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-07 09:02:08 +00:00
feat(build): add COMPILER_STATIC_ANALYZER option
This commit is contained in:
14
docs/en/api-guides/code-quality/index.rst
Normal file
14
docs/en/api-guides/code-quality/index.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
Code Quality
|
||||
============
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
Code quality refers to how well-written and maintainable a piece of software code is. It encompasses aspects like readability, efficiency, reliability, and adherence to coding standards. High-quality code is easier to understand, modify, and extend, leading to reduced development time and fewer bugs.
|
||||
|
||||
Guides
|
||||
------
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
static-analyzer
|
||||
31
docs/en/api-guides/code-quality/static-analyzer.rst
Normal file
31
docs/en/api-guides/code-quality/static-analyzer.rst
Normal file
@@ -0,0 +1,31 @@
|
||||
Static Analyzer
|
||||
===============
|
||||
|
||||
:link_to_translation:`zh_CN:[中文]`
|
||||
|
||||
A static analyzer is a tool that checks source code for errors and vulnerabilities without running it. It helps developers find issues early, improving code quality.
|
||||
|
||||
GNU Static Analyzer
|
||||
-------------------
|
||||
|
||||
The GNU Static Analyzer is distributed with GCC (refer to `GCC documentation <https://gcc.gnu.org/onlinedocs/gcc/Static-Analyzer-Options.html>`_). It can be enabled with :ref:`CONFIG_COMPILER_STATIC_ANALYZER` to perform code checks during application builds.
|
||||
|
||||
Suppressing Warnings
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
GNU Static Analyzer is still under development and may give some false-positive warnings. Here is an example of how to suppress unwanted warnings using IDF:
|
||||
|
||||
.. code-block:: c
|
||||
|
||||
#include "esp_compiler.h"
|
||||
/* .... */
|
||||
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-null-dereference")
|
||||
*((volatile int *) 0) = 0;
|
||||
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-null-dereference")
|
||||
/* .... */
|
||||
|
||||
|
||||
Clang Static Analyzer
|
||||
---------------------
|
||||
|
||||
See :doc:`IDF Clang-Tidy <../../api-guides/tools/idf-clang-tidy>`
|
||||
Reference in New Issue
Block a user