naming.py: Fix FP for constructors/destructors (#2375)
This commit is contained in:
parent
0dd180d5a2
commit
4f1db90367
|
@ -140,6 +140,8 @@ matrix:
|
|||
- cd addons/test
|
||||
- ${CPPCHECK} --dump naming_test.c
|
||||
- python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump
|
||||
- ${CPPCHECK} --dump naming_test.cpp
|
||||
- python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump
|
||||
- cd ../..
|
||||
# check addons/namingng.py
|
||||
- cd addons/test
|
||||
|
|
|
@ -34,9 +34,11 @@ for arg in sys.argv[1:]:
|
|||
RE_FUNCTIONNAME = arg[11:]
|
||||
validate_regex(RE_FUNCTIONNAME)
|
||||
|
||||
|
||||
def reportError(token, severity, msg, errorId):
|
||||
cppcheckdata.reportError(token, severity, msg, 'naming', errorId)
|
||||
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if not arg.endswith('.dump'):
|
||||
continue
|
||||
|
@ -63,6 +65,9 @@ for arg in sys.argv[1:]:
|
|||
if RE_FUNCTIONNAME:
|
||||
for scope in cfg.scopes:
|
||||
if scope.type == 'Function':
|
||||
function = scope.function
|
||||
if function is not None and function.type in ('Constructor', 'Destructor'):
|
||||
continue
|
||||
res = re.match(RE_FUNCTIONNAME, scope.className)
|
||||
if not res:
|
||||
reportError(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// To test:
|
||||
// ~/cppcheck/cppcheck --dump naming_test.cpp && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump
|
||||
|
||||
// No error for mismatching Constructor/Destructor names should be issued, they can not be changed.
|
||||
class TestClass1
|
||||
{
|
||||
TestClass1() {}
|
||||
~TestClass1() {}
|
||||
};
|
Loading…
Reference in New Issue