feat(build): add COMPILER_STATIC_ANALYZER option

This commit is contained in:
Alexey Lapshin
2024-06-06 15:23:02 +07:00
committed by BOT
parent e1b9985bd0
commit ed6e497c6f
46 changed files with 265 additions and 41 deletions

View 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

View 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>`