Menu

can cppcheck check coding style?

liushuai
2022-08-26
2022-08-27
  • liushuai

    liushuai - 2022-08-26

    I'm new in cppcheck. I just want to use it to check some coding style issue, for example,
    void checknameis(); // bad style and should give an message
    void checkNameIs(); // good style
    or
    int num;// bad style and should give an message
    int
    pNum; // good style
    can I enable cppcheck to do such check?

     
  • Daniel Marjamäki

    It seems to me you want to check the naming of functions and variables. We have an addon called namingng that should be helpful.

    https://github.com/danmar/cppcheck/blob/main/addons/namingng.py

    Basic usage seems to be:

    cppcheck --addon=namingng file1.c
    

    if you put the json configuration in a file called "naming.json" then that should be automatically read by the addon. The addon contains a bit of documentation.

    Warning about "checknameis" would probably need that it contains some kind of dictionary. As far as I know there is no functionality for that but it is a script so it can be added.

     
  • liushuai

    liushuai - 2022-08-27

    thanks alot,Where should I view the documentation about naming? In addition, I found that cppcheck on my side does not check. H files. Is there any restriction in the code? Where is it? Can I let go?

     
  • liushuai

    liushuai - 2022-08-27

    And what is the format in the JSON file?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.