GUI: Write cppcheck-id in xml report
This commit is contained in:
parent
af0db3cc21
commit
260c53ba6f
|
@ -37,6 +37,7 @@ ErrorItem::ErrorItem()
|
||||||
, incomplete(false)
|
, incomplete(false)
|
||||||
, inconclusive(false)
|
, inconclusive(false)
|
||||||
, cwe(-1)
|
, cwe(-1)
|
||||||
|
, cppcheckId(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ ErrorItem::ErrorItem(const ErrorMessage &errmsg)
|
||||||
, summary(QString::fromStdString(errmsg.shortMessage()))
|
, summary(QString::fromStdString(errmsg.shortMessage()))
|
||||||
, message(QString::fromStdString(errmsg.verboseMessage()))
|
, message(QString::fromStdString(errmsg.verboseMessage()))
|
||||||
, cwe(errmsg.cwe.id)
|
, cwe(errmsg.cwe.id)
|
||||||
|
, cppcheckId(errmsg.cppcheckId)
|
||||||
, symbolNames(QString::fromStdString(errmsg.symbolNames()))
|
, symbolNames(QString::fromStdString(errmsg.symbolNames()))
|
||||||
{
|
{
|
||||||
for (std::list<ErrorMessage::FileLocation>::const_iterator loc = errmsg.callStack.begin();
|
for (std::list<ErrorMessage::FileLocation>::const_iterator loc = errmsg.callStack.begin();
|
||||||
|
@ -70,7 +72,7 @@ QString ErrorItem::tool() const
|
||||||
return "cppcheck";
|
return "cppcheck";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ErrorItem::ToString() const
|
QString ErrorItem::toString() const
|
||||||
{
|
{
|
||||||
QString str = errorPath.back().file + " - " + errorId + " - ";
|
QString str = errorPath.back().file + " - " + errorId + " - ";
|
||||||
if (inconclusive)
|
if (inconclusive)
|
||||||
|
@ -86,7 +88,10 @@ QString ErrorItem::ToString() const
|
||||||
|
|
||||||
bool ErrorItem::sameCID(const ErrorItem &errorItem1, const ErrorItem &errorItem2)
|
bool ErrorItem::sameCID(const ErrorItem &errorItem1, const ErrorItem &errorItem2)
|
||||||
{
|
{
|
||||||
// TODO: Implement some better CID calculation
|
if (errorItem1.cppcheckId || errorItem2.cppcheckId)
|
||||||
|
return errorItem1.cppcheckId == errorItem2.cppcheckId;
|
||||||
|
|
||||||
|
// fallback
|
||||||
return errorItem1.errorId == errorItem2.errorId &&
|
return errorItem1.errorId == errorItem2.errorId &&
|
||||||
errorItem1.errorPath == errorItem2.errorPath &&
|
errorItem1.errorPath == errorItem2.errorPath &&
|
||||||
errorItem1.file0 == errorItem2.file0 &&
|
errorItem1.file0 == errorItem2.file0 &&
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
* @brief Convert error item to string.
|
* @brief Convert error item to string.
|
||||||
* @return Error item as string.
|
* @return Error item as string.
|
||||||
*/
|
*/
|
||||||
QString ToString() const;
|
QString toString() const;
|
||||||
QString tool() const;
|
QString tool() const;
|
||||||
|
|
||||||
QString file0;
|
QString file0;
|
||||||
|
@ -88,6 +88,7 @@ public:
|
||||||
QString summary;
|
QString summary;
|
||||||
QString message;
|
QString message;
|
||||||
int cwe;
|
int cwe;
|
||||||
|
unsigned long long cppcheckId;
|
||||||
QList<QErrorPathItem> errorPath;
|
QList<QErrorPathItem> errorPath;
|
||||||
QString symbolNames;
|
QString symbolNames;
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ public:
|
||||||
QString errorId;
|
QString errorId;
|
||||||
bool incomplete;
|
bool incomplete;
|
||||||
int cwe;
|
int cwe;
|
||||||
|
unsigned long long cppcheckId;
|
||||||
bool inconclusive;
|
bool inconclusive;
|
||||||
Severity::SeverityType severity;
|
Severity::SeverityType severity;
|
||||||
QString summary;
|
QString summary;
|
||||||
|
|
|
@ -168,6 +168,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
line.errorId = item.errorId;
|
line.errorId = item.errorId;
|
||||||
line.incomplete = item.incomplete;
|
line.incomplete = item.incomplete;
|
||||||
line.cwe = item.cwe;
|
line.cwe = item.cwe;
|
||||||
|
line.cppcheckId = item.cppcheckId;
|
||||||
line.inconclusive = item.inconclusive;
|
line.inconclusive = item.inconclusive;
|
||||||
line.summary = item.summary;
|
line.summary = item.summary;
|
||||||
line.message = item.message;
|
line.message = item.message;
|
||||||
|
@ -197,6 +198,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
data["id"] = item.errorId;
|
data["id"] = item.errorId;
|
||||||
data["incomplete"] = item.incomplete;
|
data["incomplete"] = item.incomplete;
|
||||||
data["cwe"] = item.cwe;
|
data["cwe"] = item.cwe;
|
||||||
|
data["cppcheckId"] = item.cppcheckId;
|
||||||
data["inconclusive"] = item.inconclusive;
|
data["inconclusive"] = item.inconclusive;
|
||||||
data["file0"] = stripPath(item.file0, true);
|
data["file0"] = stripPath(item.file0, true);
|
||||||
data["function"] = item.function;
|
data["function"] = item.function;
|
||||||
|
@ -232,6 +234,7 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
|
||||||
child_data["id"] = line.errorId;
|
child_data["id"] = line.errorId;
|
||||||
child_data["incomplete"] = line.incomplete;
|
child_data["incomplete"] = line.incomplete;
|
||||||
child_data["cwe"] = line.cwe;
|
child_data["cwe"] = line.cwe;
|
||||||
|
child_data["cppcheckId"] = line.cppcheckId;
|
||||||
child_data["inconclusive"] = line.inconclusive;
|
child_data["inconclusive"] = line.inconclusive;
|
||||||
child_item->setData(QVariant(child_data));
|
child_item->setData(QVariant(child_data));
|
||||||
}
|
}
|
||||||
|
@ -1221,6 +1224,7 @@ void ResultsTree::readErrorItem(const QStandardItem *error, ErrorItem *item) con
|
||||||
item->errorId = data["id"].toString();
|
item->errorId = data["id"].toString();
|
||||||
item->incomplete = data["incomplete"].toBool();
|
item->incomplete = data["incomplete"].toBool();
|
||||||
item->cwe = data["cwe"].toInt();
|
item->cwe = data["cwe"].toInt();
|
||||||
|
item->cppcheckId = data["cppcheckId"].toULongLong();
|
||||||
item->inconclusive = data["inconclusive"].toBool();
|
item->inconclusive = data["inconclusive"].toBool();
|
||||||
item->file0 = data["file0"].toString();
|
item->file0 = data["file0"].toString();
|
||||||
item->sinceDate = data["sinceDate"].toString();
|
item->sinceDate = data["sinceDate"].toString();
|
||||||
|
|
|
@ -448,7 +448,7 @@ void ResultsView::log(const QString &str)
|
||||||
|
|
||||||
void ResultsView::debugError(const ErrorItem &item)
|
void ResultsView::debugError(const ErrorItem &item)
|
||||||
{
|
{
|
||||||
mUI.mListLog->addItem(item.ToString());
|
mUI.mListLog->addItem(item.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultsView::bughuntingReportLine(const QString& line)
|
void ResultsView::bughuntingReportLine(const QString& line)
|
||||||
|
|
|
@ -34,6 +34,7 @@ static const QString ErrorElementName = "error";
|
||||||
static const QString ErrorsElementName = "errors";
|
static const QString ErrorsElementName = "errors";
|
||||||
static const QString LocationElementName = "location";
|
static const QString LocationElementName = "location";
|
||||||
static const QString CWEAttribute = "cwe";
|
static const QString CWEAttribute = "cwe";
|
||||||
|
static const QString CppcheckIdAttribute = "cppcheck-id";
|
||||||
static const QString SinceDateAttribute = "sinceDate";
|
static const QString SinceDateAttribute = "sinceDate";
|
||||||
static const QString TagsAttribute = "tag";
|
static const QString TagsAttribute = "tag";
|
||||||
static const QString FilenameAttribute = "file";
|
static const QString FilenameAttribute = "file";
|
||||||
|
@ -122,6 +123,8 @@ void XmlReportV2::writeError(const ErrorItem &error)
|
||||||
mXmlWriter->writeAttribute(InconclusiveAttribute, "true");
|
mXmlWriter->writeAttribute(InconclusiveAttribute, "true");
|
||||||
if (error.cwe > 0)
|
if (error.cwe > 0)
|
||||||
mXmlWriter->writeAttribute(CWEAttribute, QString::number(error.cwe));
|
mXmlWriter->writeAttribute(CWEAttribute, QString::number(error.cwe));
|
||||||
|
if (error.cppcheckId > 0)
|
||||||
|
mXmlWriter->writeAttribute(CppcheckIdAttribute, QString::number(error.cppcheckId));
|
||||||
if (!error.sinceDate.isEmpty())
|
if (!error.sinceDate.isEmpty())
|
||||||
mXmlWriter->writeAttribute(SinceDateAttribute, error.sinceDate);
|
mXmlWriter->writeAttribute(SinceDateAttribute, error.sinceDate);
|
||||||
if (!error.tags.isEmpty())
|
if (!error.tags.isEmpty())
|
||||||
|
@ -214,7 +217,9 @@ ErrorItem XmlReportV2::readError(QXmlStreamReader *reader)
|
||||||
if (attribs.hasAttribute(QString(), InconclusiveAttribute))
|
if (attribs.hasAttribute(QString(), InconclusiveAttribute))
|
||||||
item.inconclusive = true;
|
item.inconclusive = true;
|
||||||
if (attribs.hasAttribute(QString(), CWEAttribute))
|
if (attribs.hasAttribute(QString(), CWEAttribute))
|
||||||
item.cwe = attribs.value(QString(), CWEAttribute).toString().toInt();
|
item.cwe = attribs.value(QString(), CWEAttribute).toInt();
|
||||||
|
if (attribs.hasAttribute(QString(), CppcheckIdAttribute))
|
||||||
|
item.cppcheckId = attribs.value(QString(), CWEAttribute).toULongLong();
|
||||||
if (attribs.hasAttribute(QString(), SinceDateAttribute))
|
if (attribs.hasAttribute(QString(), SinceDateAttribute))
|
||||||
item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
|
item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
|
||||||
if (attribs.hasAttribute(QString(), TagsAttribute))
|
if (attribs.hasAttribute(QString(), TagsAttribute))
|
||||||
|
|
Loading…
Reference in New Issue