fin*_*oot 2 c c++ doxygen static-code-analysis linter
我想对 C/C++ 代码运行某种 linter 或静态代码分析,如果存在缺少文档的代码(例如没有 doxygen 样式文档注释的函数),则会发出警告。换句话说,我想强制执行某些代码标准。我研究了clang-tidy
和cppcheck
,但没有走得太远。
为了让我更清楚我对 Python 的期望,我习惯了这样的事情:
$ cat test.py
def answer():
return 42
$ python3 -m pylint test.py
************* Module test
test.py:1:0: C0111: Missing module docstring (missing-docstring)
test.py:1:0: C0111: Missing function docstring (missing-docstring)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
Run Code Online (Sandbox Code Playgroud)
Clang 可以选择-Wdocumentation
静态检查 Doxygen 风格的注释。\参见https://clang.llvm.org/docs/UsersManual.html。
另外,正如 @Null 在评论中提到的,doxygen 工具本身会警告某些文档问题。