Menu

naming.py aborts when there is no variable name in an argument

Jim Pattee
2019-03-20
2019-03-27
  • Jim Pattee

    Jim Pattee - 2019-03-20

    naming.py aborts when there is no variable name in an argument

    The addon naming.py aborts when there is an unnamed variable in a function argument. This happens for both function declarations and function definitions. Some compilers issue a warning for unused variables so it is convenient to leave then unnamed.

    1) A sample test follows. Tested with cppcheck 1.87.

    Make a c++ file with an unnamed variable:
    “void func(int number, bool);”

    Create a dump file for the above file:
    "C:/Program Files/Cppcheck/cppcheck.exe" --dump --force <filename></filename>

    Input the dump file to naming.py:
    "C:/Program Files/Python37/python.exe" “C:/Program Files/Cppcheck/addons/naming.py” --var="[a-z].” --function="[a-z].” <dump_filename></dump_filename>

    cppcheckdata.py aborts with:
    AttributeError: 'NoneType' object has no attribute 'str'

    2) Correct the error in the above sample by naming the variable:
    “void func(int number, bool xxx);”

    Create a dump file and run naming.py as above.

    The script will run successfully without aborting.

     
  • versat

    versat - 2019-03-26

    Thank you for the report.
    I have created a pull request that fixes this issue:
    https://github.com/danmar/cppcheck/pull/1762

     

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.