ncc
1.0.0
C/C++ 命名约定检查器 (ncc)
ncc 是一个开发工具,可帮助程序员编写遵循某些命名约定的 C/C++ 代码。它自动执行检查 C/C++ 代码的过程,从而使人类摆脱这项无聊(但重要)的任务。这使其成为想要强制执行编码标准的项目的理想选择。
以下软件包是 ncc 工具的先决条件。请注意,python 'clang' 提供 libclang python 绑定。 clang 版本应该与您系统上的 libclang.so 版本匹配
pip install clang
pip install pyyaml
在 Microsoft Windows 上安装 32 位版本的 LLVM 编译器工具链。
ncc . py [ - - help ] [ - - recurse ] [ - - style STYLE_FILE ] [ - - cdbdir CDBDIR ] [ - - dump ]
[ - - output OUTPUT ] [ - - filetype FILETYPE ] [ - - exclude EXCLUDE [ EXCLUDE ...]]
[ - - path PATH [ PATH ...]] [ - - include INCLUDE [ INCLUDE ...]]
[ - - definition DEFINITION [ DEFINITION ...]] [ - - clang - lib CLANG_LIB ]
有关所有选项的详细说明:
ncc . py - - help
打印所有规则:
ncc . py - - dump
c/c++ 构造的样式由正则表达式定义。例如,以下规则规定结构体可以具有任何字符,类名应以“C”开头,类成员变量应以 m_ 开头,函数名应以大写字母开头
ClassName : ' C.* '
CppMethod : ' [A-Z].* '
VariableName :
ScopePrefix :
Global : ' g_ '
Static : ' s_ '
ClassMember : ' m_ '
DataTypePrefix :
String : ' str '
Pointer : ' p '
Integer : ' n '
Bool : ' b '
Pattern : ' ^.*$ '
./ncc.py --style examples/ncc.style --path examples/test.cpp
examples/test.cpp:16:7: " B " does not match " ^C.*$ " associated with ClassName
examples/test.cpp:28:9: " b " does not match " ^m_.*$ " associated with ClassMemberVariable
examples/test.cpp:31:5: " main(int, const char **) " does not match " ^[A-Z].*$ " associated with FunctionName
Total number of errors = 3
./ncc.py --style examples/ncc.style --recurse --exclude * .cpp * .h --path examples
examples/test.hpp:4:7: " Test " does not match " ^C.*$ " associated with ClassName
examples/test.hpp:12:9: " t " does not match " ^m_.*$ " associated with ClassMemberVariable
examples/test.hpp:19:9: " _aaa " does not match " ^[a-z].*$ " associated with StructMemberVariable
examples/test.c:8:9: " _b " does not match " ^[a-z].*$ " associated with StructMemberVariable
examples/test.c:9:9: " _c " does not match " ^[a-z].*$ " associated with StructMemberVariable
examples/tmp/test.hpp:4:7: " Test " does not match " ^C.*$ " associated with ClassName
examples/tmp/test.hpp:12:9: " t " does not match " ^m_.*$ " associated with ClassMemberVariable
examples/tmp/test.hpp:19:9: " _aaa " does not match " ^[a-z].*$ " associated with StructMemberVariable
Total number of errors = 8
版权所有 © 2018 Nithin Nellikunnu
根据麻省理工学院许可证 (MIT) 分发。
丹尼尔·J·霍夫曼