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·霍夫曼