Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions addons/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ def validate_regex(expr):
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
Expand All @@ -63,6 +65,9 @@ def reportError(token, severity, msg, errorId):
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(
Expand Down
9 changes: 9 additions & 0 deletions addons/test/naming_test.cpp
Original file line number Diff line number Diff line change
@@ -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() {}
};