CppNameLint is a naming convention linter of C/C++ source code (Based on LLVM's libtooling), which runs with command line on Windows/Linux/macOS.
My name is Upper Camel. (My partner drew this mascot for the project)
Windows | Linux | macOS |
---|---|---|
The project is a naming convention checking tool executing on Windows/Linux/MacOS. It is based on LLVM's LibTooling as a compiler frontend to retrieve AST of C/C++ source files, then check your naming convention.
UpperCamelCase
, lowerCamelCase
, UPPER_SNAKE_CASE
, lower_snake_case
, and szHungarainNotion
.⭐If you like this project or this project gives you some help, please also give me a STAR on GitHub, let me know I am not alone.
————————————————————————————————————————————
You are an user:
Use it directly, please goto the release
page to download the artifacts files by Azure DevOps.
https://github.com/dougpuob/cpp-namelint/releases
Know more, please start from Usage.
You are a developer
llvmorg-8.0.0
.————————————————————————————————————————————
Run Check command
# Check source file with a specfic config file.
$ cppnamelint check YouPlayGround.cpp -config cppnamelint.toml
# Check source file with a specfic config file, and specific header directories (Dir1 and Dir2)
$ cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -include Dir1 -include Dir2
# Check source file with a specfic config file, and save check result as a JSON file to the specific path.
$ cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -jsonout result.json
# Check source file with a specfic config file, and save log to the specific path.
$ cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -logfile logout.log
$ cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -jsonout result.json -logfile logout.log
Run Test command
# Run Unit Test (Google Test)
$ cppnamelint test
# Show usage help to subcommands.
$ cppnamelint -help
# Show usage help to `check` subcommand.
$ cppnamelint check -help
————————————————————————————————————————————
————————————————————————————————————————————
cppnamelint.py
This is a Python script, which privodes several features:
cppnamelint
utility, making it more convenient to integrated into your project.$ python .\cppnamelint.py -h
usage: cppnamelint.py [-h] [-verbose] [-dbg] [-log LOG]
{check,checkdir,format,test,chkenv,bldgtest,bldgpack,bldgcfg} ...
positional arguments:
{check,checkdir,format,test,chkenv,bldgtest,bldgpack,bldgcfg}
check check command
checkdir checkdir command
format format command
test test command
chkenv chkenv command for checking build environment
bldgtest bldgtest command for building this project
bldgpack bldgpack command for packing this project
bldgcfg bldgcfg command for doing config via Cmake
optional arguments:
-h, --help show this help message and exit
-verbose increase output verbosity
-dbg enable debug mode output verbosity
-log LOG log file path
$ python .\cppnamelint.py checkdir -h
usage: cppnamelint.py checkdir [-h] [-cfg CFG] [-json JSON] [-inc INC] srcdir
positional arguments:
srcdir Input source code file dir
optional arguments:
-h, --help show this help message and exit
-cfg CFG Config file path
-json JSON Json result output file path
-inc INC None or more include directory. (-inc Dir1 -inc Dir2 ...)
# Check source file with a specfic config file.
$ python .\cppnamelint.py checkdir ../source -cfg ../cppnamelint.toml
————————————————————————————————————————————
C:\>cppnamelint.exe check YouPlayGround.cpp -config cppnamelint.toml
cppnamelint utility v0.3.1
---------------------------------------------------
File = YouPlayGround.cpp
Config = cppnamelint.toml
Checked = 6 [File:0 | Func: 5 | Param: 1 | Var: 0 | Enum: 0 | Struct: 0 | Union: 0 | Class: 0]
Error = 0 [File:0 | Func: 0 | Param: 0 | Var: 0 | Enum: 0 | Struct: 0 | Union: 0 | Class: 0]
------------------------------------------------------------
C:\>cppnamelint.exe check YouPlayGround.cpp -config cppnamelint.toml
cppnamelint utility v0.3.1
---------------------------------------------------
File = YouPlayGround.cpp
Config = cppnamelint.toml
Checked = 6 [File:0 | Func: 5 | Param: 1 | Var: 0 | Enum: 0 | Struct: 0 | Union: 0 | Class: 0]
Error = 1 [File:0 | Func: 0 | Param: 1 | Var: 0 | Enum: 0 | Struct: 0 | Union: 0 | Class: 0]
------------------------------------------------------------
< 16, 25> Parameter : inputValue (int)
------------------------------------------------------------
Check command with -verbose
option.
JSON result (Good case)
JSON result (Bad case)
[{
"Checked": {
"Function": 5,
"Parameter": 1,
"Variable": 0
},
"Error": {
"Function": 0,
"Parameter": 1,
"Variable": 0
},
"ErrorDetailList": [
{
"Column": 25,
"Expected": "",
"Line": 16,
"TargetName": "inputValue",
"Type": 4,
"TypeName": "int"
}
],
"File": {
"Config": "cppnamelint.toml",
"Source": "C:\\petzone\\cpp-namelint\\sample\\YouPlayGround.cpp"
}
}]
————————————————————————————————————————————
MIT
————————————————————————————————————————————
Douglas Chen [email protected]