MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / readError

Method readError

gui/xmlreportv2.cpp:213–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213ErrorItem XmlReportV2::readError(const QXmlStreamReader *reader)
214{
215 /*
216 Error example from the core program in xml
217 <error id="mismatchAllocDealloc" severity="error" msg="Mismatching allocation and deallocation: k"
218 verbose="Mismatching allocation and deallocation: k">
219 <location file="..\..\test\test.cxx" line="16"/>
220 <location file="..\..\test\test.cxx" line="32"/>
221 </error>
222 */
223
224 ErrorItem item;
225
226 // Read error element from inside errors element
227 if (mXmlReader->name() == ErrorElementName) {
228 QXmlStreamAttributes attribs = reader->attributes();
229 item.errorId = attribs.value(QString(), IdAttribute).toString();
230 item.severity = GuiSeverity::fromString(attribs.value(QString(), SeverityAttribute).toString());
231 const QString summary = attribs.value(QString(), MsgAttribute).toString();
232 item.summary = XmlReport::unquoteMessage(summary);
233 const QString message = attribs.value(QString(), VerboseAttribute).toString();
234 item.message = XmlReport::unquoteMessage(message);
235 if (attribs.hasAttribute(QString(), InconclusiveAttribute))
236 item.inconclusive = true;
237 if (attribs.hasAttribute(QString(), RemarkAttribute))
238 item.remark = attribs.value(QString(), RemarkAttribute).toString();
239 if (attribs.hasAttribute(QString(), CWEAttribute))
240 item.cwe = attribs.value(QString(), CWEAttribute).toInt();
241 if (attribs.hasAttribute(QString(), HashAttribute))
242 item.hash = attribs.value(QString(), HashAttribute).toULongLong();
243 if (attribs.hasAttribute(QString(), IncludedFromFilenameAttribute))
244 item.file0 = attribs.value(QString(), IncludedFromFilenameAttribute).toString();
245 if (attribs.hasAttribute(QString(), SinceDateAttribute))
246 item.sinceDate = attribs.value(QString(), SinceDateAttribute).toString();
247 if (attribs.hasAttribute(QString(), TagsAttribute))
248 item.tags = attribs.value(QString(), TagsAttribute).toString();
249 }
250
251 bool errorRead = false;
252 while (!errorRead && !mXmlReader->atEnd()) {
253 switch (mXmlReader->readNext()) {
254 case QXmlStreamReader::StartElement:
255
256 // Read location element from inside error element
257 if (mXmlReader->name() == LocationElementName) {
258 QXmlStreamAttributes attribs = mXmlReader->attributes();
259 QString file0 = attribs.value(QString(), IncludedFromFilenameAttribute).toString();
260 if (!file0.isEmpty())
261 item.file0 = XmlReport::unquoteMessage(file0);
262 QErrorPathItem loc;
263 loc.file = XmlReport::unquoteMessage(attribs.value(QString(), FilenameAttribute).toString());
264 loc.line = attribs.value(QString(), LineAttribute).toString().toUInt();
265 if (attribs.hasAttribute(QString(), ColumnAttribute))
266 loc.column = attribs.value(QString(), ColumnAttribute).toString().toInt();
267 if (attribs.hasAttribute(QString(), InfoAttribute))
268 loc.info = XmlReport::unquoteMessage(attribs.value(QString(), InfoAttribute).toString());
269 item.errorPath.push_front(loc);
270 }

Callers

nothing calls this directly

Calls 6

isEmptyMethod · 0.80
QStringClass · 0.70
nameMethod · 0.45
toStringMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected