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 インストールでは、LLVM コンパイラ ツール チェーンの 32 ビット バージョンをインストールします。
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
Copyright © 2018 ニシン・ネリクンヌ
MIT ライセンス (MIT) に基づいて配布されます。
ダニエル・J・ホフマン