Giter Site home page Giter Site logo

stone0107 / cppnamelint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dougpuob/cppnamelint

0.0 0.0 0.0 838 KB

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: MIT License

Shell 0.56% C++ 87.54% Python 7.75% PowerShell 2.55% CMake 1.59%

cppnamelint's Introduction

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.
  7. Integrate with Azure DevOps(CI/CD).

⭐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. You are an user:

  2. You are a developer

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

● Usage

Commands

  1. 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

  2. Run Test command

    # Run Unit Test (Google Test)
    $ cppnamelint test

Helps

# Show usage help to subcommands.
$ cppnamelint -help

# Show usage help to `check` subcommand.
$ cppnamelint check -help

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

● Tests

Unit Test

Unit Test

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

● Scripts

cppnamelint.py

This is a Python script, which privodes several features:

  1. Integrate automation with CI/CD (build, packing, and test).
  2. Enhance 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

Commands

  1. Check whole files in a specfic directory
     $ 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

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

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

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

● License

MIT

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

● Author

Douglas Chen [email protected]

cppnamelint's People

Contributors

dougpuob avatar hackmd-deploy avatar neville1 avatar codacy-badger avatar brlin-tw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.