From ee79ea6306416dc67eec03216a4075b1c342fd89 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 3 Jan 2016 17:20:46 +0300 Subject: Add finalize ignore into virtual check. --- src/rules/virtual.cpp | 5 ++++- tests/testreport.txt | 2 +- tests/testsrc/bad/virtual1.cpp | 4 +++- tests/testsrc/good/virtual1.cpp | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rules/virtual.cpp b/src/rules/virtual.cpp index 70f0e36..a52a369 100644 --- a/src/rules/virtual.cpp +++ b/src/rules/virtual.cpp @@ -32,6 +32,9 @@ endRule(virtualCheck) parseLineRule(virtualCheck) { - if (isMatch(data, "(.+)virtual[ ](.+)[ ](override|final)(.+)")) + if (isMatch(data, "(.+)virtual[ ](.+)[ ](override|final)(.*)") && + data.find("finalize") == std::string::npos) + { print("Keywords virtual is useless if used with override or final"); + } } diff --git a/tests/testreport.txt b/tests/testreport.txt index 8b47e0b..366e750 100644 --- a/tests/testreport.txt +++ b/tests/testreport.txt @@ -44,6 +44,6 @@ [testsrc/bad/packet.cpp:25]: V012: Wrong output packet creation. Must be 'createOutPacket(CMSG...' [testsrc/bad/uk.po:2257]: V010: Wrong character at end of translation line. [testsrc/bad/virtual1.cpp:33]: V013: Keywords virtual is useless if used with override or final -[testsrc/bad/virtual1.cpp:34]: V013: Keywords virtual is useless if used with override or final +[testsrc/bad/virtual1.cpp:36]: V013: Keywords virtual is useless if used with override or final [testsrc/bad/virtual1.h:31]: V013: Keywords virtual is useless if used with override or final [testsrc/bad/virtual1.h:32]: V013: Keywords virtual is useless if used with override or final diff --git a/tests/testsrc/bad/virtual1.cpp b/tests/testsrc/bad/virtual1.cpp index cfc4176..77d525a 100644 --- a/tests/testsrc/bad/virtual1.cpp +++ b/tests/testsrc/bad/virtual1.cpp @@ -31,6 +31,8 @@ class Test1 final class Test2 notfinal : public Test1 { virtual Test2() override; - virtual Test3() final; } + virtual Test2::Test3() final + { + } \ No newline at end of file diff --git a/tests/testsrc/good/virtual1.cpp b/tests/testsrc/good/virtual1.cpp index 0f72e65..5314e16 100644 --- a/tests/testsrc/good/virtual1.cpp +++ b/tests/testsrc/good/virtual1.cpp @@ -24,7 +24,7 @@ class Test1 final { - virtual Test1(); + virtual Test1finalize(); } class Test2 notfinal : public Test1 -- cgit v1.2.3-60-g2f50