Cppcheck: Write product name if provided in xml output
This commit is contained in:
parent
68bb724dcc
commit
d1812c8022
|
@ -122,7 +122,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
|
|
||||||
if (parser.getShowErrorMessages()) {
|
if (parser.getShowErrorMessages()) {
|
||||||
mShowAllErrors = true;
|
mShowAllErrors = true;
|
||||||
std::cout << ErrorMessage::getXMLHeader();
|
std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName);
|
||||||
cppcheck->getErrorMessages();
|
cppcheck->getErrorMessages();
|
||||||
std::cout << ErrorMessage::getXMLFooter() << std::endl;
|
std::cout << ErrorMessage::getXMLFooter() << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -908,7 +908,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.xml) {
|
if (settings.xml) {
|
||||||
reportErr(ErrorMessage::getXMLHeader());
|
reportErr(ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.buildDir.empty()) {
|
if (!settings.buildDir.empty()) {
|
||||||
|
|
|
@ -368,7 +368,7 @@ bool ErrorMessage::deserialize(const std::string &data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ErrorMessage::getXMLHeader()
|
std::string ErrorMessage::getXMLHeader(const std::string& productName)
|
||||||
{
|
{
|
||||||
tinyxml2::XMLPrinter printer;
|
tinyxml2::XMLPrinter printer;
|
||||||
|
|
||||||
|
@ -380,6 +380,8 @@ std::string ErrorMessage::getXMLHeader()
|
||||||
|
|
||||||
printer.PushAttribute("version", 2);
|
printer.PushAttribute("version", 2);
|
||||||
printer.OpenElement("cppcheck", false);
|
printer.OpenElement("cppcheck", false);
|
||||||
|
if (!productName.empty())
|
||||||
|
printer.PushAttribute("product-name", productName.c_str());
|
||||||
printer.PushAttribute("version", CppCheck::version());
|
printer.PushAttribute("version", CppCheck::version());
|
||||||
printer.CloseElement(false);
|
printer.CloseElement(false);
|
||||||
printer.OpenElement("errors", false);
|
printer.OpenElement("errors", false);
|
||||||
|
|
|
@ -160,7 +160,7 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string toXML() const;
|
std::string toXML() const;
|
||||||
|
|
||||||
static std::string getXMLHeader();
|
static std::string getXMLHeader(const std::string& productName);
|
||||||
static std::string getXMLFooter();
|
static std::string getXMLFooter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -192,7 +192,7 @@ private:
|
||||||
header += " <cppcheck version=\"";
|
header += " <cppcheck version=\"";
|
||||||
header += CppCheck::version();
|
header += CppCheck::version();
|
||||||
header += "\"/>\n <errors>";
|
header += "\"/>\n <errors>";
|
||||||
ASSERT_EQUALS(header, ErrorMessage::getXMLHeader());
|
ASSERT_EQUALS(header, ErrorMessage::getXMLHeader(""));
|
||||||
ASSERT_EQUALS(" </errors>\n</results>", ErrorMessage::getXMLFooter());
|
ASSERT_EQUALS(" </errors>\n</results>", ErrorMessage::getXMLFooter());
|
||||||
std::string message(" <error id=\"errorId\" severity=\"error\"");
|
std::string message(" <error id=\"errorId\" severity=\"error\"");
|
||||||
message += " msg=\"Programming error.\" verbose=\"Verbose error\">\n";
|
message += " msg=\"Programming error.\" verbose=\"Verbose error\">\n";
|
||||||
|
@ -208,7 +208,7 @@ private:
|
||||||
header += " <cppcheck version=\"";
|
header += " <cppcheck version=\"";
|
||||||
header += CppCheck::version();
|
header += CppCheck::version();
|
||||||
header += "\"/>\n <errors>";
|
header += "\"/>\n <errors>";
|
||||||
ASSERT_EQUALS(header, ErrorMessage::getXMLHeader());
|
ASSERT_EQUALS(header, ErrorMessage::getXMLHeader(""));
|
||||||
ASSERT_EQUALS(" </errors>\n</results>", ErrorMessage::getXMLFooter());
|
ASSERT_EQUALS(" </errors>\n</results>", ErrorMessage::getXMLFooter());
|
||||||
std::string message(" <error id=\"errorId\" severity=\"error\"");
|
std::string message(" <error id=\"errorId\" severity=\"error\"");
|
||||||
message += " msg=\"Programming error.\" verbose=\"Verbose error\">\n";
|
message += " msg=\"Programming error.\" verbose=\"Verbose error\">\n";
|
||||||
|
|
Loading…
Reference in New Issue