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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
Thank you for the report.
I have created a pull request that fixes this issue:
https://github.com/danmar/cppcheck/pull/1762
The pull request is merged.
If you want you can download the fixed naming.py and test it:
https://raw.githubusercontent.com/danmar/cppcheck/master/addons/naming.py