From 7d6e923bd4945ddb3b11c5390b877a664656a86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 10 Apr 2011 21:51:27 +0200 Subject: [PATCH] inconclusive: don't report such messages in xml version 1 format. until we decide how they will be reported in xml version 2 format I don't report it. --- lib/cppcheck.cpp | 4 +++- lib/errorlogger.cpp | 8 ++++++++ test/testerrorlogger.cpp | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index cec114d84..c4e118a68 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -396,7 +396,9 @@ Settings &CppCheck::settings() void CppCheck::reportErr(const ErrorLogger::ErrorMessage &msg) { - std::string errmsg = msg.toString(_settings._verbose); + const std::string errmsg = msg.toString(_settings._verbose); + if (errmsg.empty()) + return; // Alert only about unique errors if (std::find(_errorList.begin(), _errorList.end(), errmsg) != _errorList.end()) diff --git a/lib/errorlogger.cpp b/lib/errorlogger.cpp index c96c12854..a32874113 100644 --- a/lib/errorlogger.cpp +++ b/lib/errorlogger.cpp @@ -204,6 +204,10 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const // The default xml format if (version == 1) { + // No inconclusive messages in the xml version 1 + if (Severity::toString(_severity).compare(0,12,"inconclusive")==0) + return ""; + xml << "\n "; ASSERT_EQUALS(message, msg.toXML(false,2)); } + + void InconclusiveXml() + { + // Location + ErrorLogger::ErrorMessage::FileLocation loc; + loc.setfile("foo.cpp"); + loc.line = 5; + std::list locs; + locs.push_back(loc); + + // Error message + ErrorMessage msg(locs, Severity::inconclusive_error, "Programming error", "errorId"); + + // Don't save inconclusive messages if the xml version is 1 + ASSERT_EQUALS("", msg.toXML(false, 1)); + + // TODO: how should inconclusive messages be saved when the xml version is 2? + ASSERT_EQUALS("", msg.toXML(false, 2)); + } }; REGISTER_TEST(TestErrorLogger)