Skip to content

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.

License

Notifications You must be signed in to change notification settings

dougpuob/cppnamelint

Repository files navigation

CppNameLint

My name is "Upper camel" 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.

  1. Check for C and C++ programming languages.
  2. Check naming of file, functions, variables, and parameters.
  3. Execute on Windows/Linux/macOS.
  4. Load config file format with TOML.
  5. Output results to console or save an a JSON file.
  6. Support rules with 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.

————————————————————————————————————————————

Quick Start

  1. As an user:

  2. As a developer

————————————————————————————————————————————

Usage

Commands

  1. Run Check command

    • cppnamelint check YouPlayGround.cpp -config cppnamelint.toml
    • cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -jsonout result.json
    • cppnamelint check YouPlayGround.cpp -config cppnamelint.toml -jsonout result.json -logfile logout.log

  2. Run Test command

    • cppnamelint test

Helps

  • cppnamelint -help

  • cppnamelint check -help

————————————————————————————————————————————

Tests

Unit Test

Unit Test

————————————————————————————————————————————

Screenshots

Passed case

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]
------------------------------------------------------------

Passed Case

Failed case

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)
------------------------------------------------------------

Failed Case

Others

  • 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"
        }
    }]

————————————————————————————————————————————

Author

Douglas Chen dougpuob@gmail.com

————————————————————————————————————————————

License

MIT

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •