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.
This commit is contained in:
parent
11bd6bcd30
commit
7d6e923bd4
|
@ -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())
|
||||
|
|
|
@ -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 << "<error";
|
||||
if (!_callStack.empty())
|
||||
{
|
||||
|
@ -219,6 +223,10 @@ std::string ErrorLogger::ErrorMessage::toXML(bool verbose, int version) const
|
|||
// The xml format you get when you use --xml-version=2
|
||||
else if (version == 2)
|
||||
{
|
||||
// TODO: How should inconclusive messages be saved in the xml version 2?
|
||||
if (Severity::toString(_severity).compare(0,12,"inconclusive")==0)
|
||||
return "";
|
||||
|
||||
xml << " <error";
|
||||
xml << " id=\"" << _id << "\"";
|
||||
xml << " severity=\"" << Severity::toString(_severity) << "\"";
|
||||
|
|
|
@ -40,6 +40,9 @@ private:
|
|||
TEST_CASE(ToXml);
|
||||
TEST_CASE(ToVerboseXml);
|
||||
TEST_CASE(ToXmlV2);
|
||||
|
||||
// Inconclusive results in xml reports..
|
||||
TEST_CASE(InconclusiveXml);
|
||||
}
|
||||
|
||||
void FileLocationDefaults()
|
||||
|
@ -162,5 +165,24 @@ private:
|
|||
message += " <location file=\"foo.cpp\" line=\"5\"/>\n </error>";
|
||||
ASSERT_EQUALS(message, msg.toXML(false,2));
|
||||
}
|
||||
|
||||
void InconclusiveXml()
|
||||
{
|
||||
// Location
|
||||
ErrorLogger::ErrorMessage::FileLocation loc;
|
||||
loc.setfile("foo.cpp");
|
||||
loc.line = 5;
|
||||
std::list<ErrorLogger::ErrorMessage::FileLocation> 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)
|
||||
|
|
Loading…
Reference in New Issue