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

Method addBacktraceFiles

gui/resultstree.cpp:293–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293ResultItem *ResultsTree::addBacktraceFiles(ResultItem *parent,
294 const QSharedPointer<ErrorItem>& errorItem,
295 const bool hide,
296 const QString &icon,
297 ResultItem::Type type,
298 int errorPathIndex)
299{
300 if (!parent)
301 return nullptr;
302
303 //TODO message has parameter names so we'll need changes to the core
304 //cppcheck so we can get proper translations
305
306 const bool childOfMessage = (type == ResultItem::Type::note);
307 const QString itemSeverity = childOfMessage ? tr("note") : severityToTranslatedString(errorItem->severity);
308
309 const auto& loc = errorItem->errorPath[errorPathIndex];
310
311 // Check for duplicate rows and don't add them if found
312 for (int i = 0; i < errorPathIndex; i++) {
313 // The first column is the file name and is always the same
314 const auto& e = errorItem->errorPath[i];
315 if (loc.line == e.line && loc.info == e.info)
316 return nullptr;
317 }
318
319 const QString text = childOfMessage ? loc.info : errorItem->summary;
320
321 const int numberOfColumns = getLabels().size();
322 QList<ResultItem*> columns(numberOfColumns);
323 columns[COLUMN_FILE] = createFilenameItem(errorItem, type, errorPathIndex);
324 columns[COLUMN_FILE]->setIconFileName(icon);
325 columns[COLUMN_LINE] = createLineNumberItem(loc.line, errorItem, type, errorPathIndex);
326 columns[COLUMN_SEVERITY] = createNormalItem(itemSeverity, errorItem, type, errorPathIndex);
327 columns[COLUMN_SUMMARY] = createNormalItem(text, errorItem, type, errorPathIndex);
328 if (type == ResultItem::Type::message) {
329 columns[COLUMN_CERT_LEVEL] = createNormalItem(errorItem->classification, errorItem, type, errorPathIndex);
330 columns[COLUMN_CERT_RULE] = createNormalItem(errorItem->guideline, errorItem, type, errorPathIndex);
331 columns[COLUMN_CWE] = createNormalItem(errorItem->cwe > 0 ? QString::number(errorItem->cwe) : QString(), errorItem, type, errorPathIndex);
332 columns[COLUMN_ID] = createNormalItem(errorItem->errorId, errorItem, type, errorPathIndex);
333 columns[COLUMN_INCONCLUSIVE] = createCheckboxItem(errorItem->inconclusive, errorItem, type, errorPathIndex);
334 columns[COLUMN_MISRA_CLASSIFICATION] = createNormalItem(errorItem->classification, errorItem, type, errorPathIndex);
335 columns[COLUMN_MISRA_GUIDELINE] = createNormalItem(errorItem->guideline, errorItem, type, errorPathIndex);
336 columns[COLUMN_SINCE_DATE] = createNormalItem(errorItem->sinceDate, errorItem, type, errorPathIndex);
337 columns[COLUMN_TAGS] = createNormalItem(errorItem->tags, errorItem, type, errorPathIndex);
338 }
339
340 QList<QStandardItem*> list;
341 for (int i = 0; i < numberOfColumns; ++i)
342 list << (columns[i] ? columns[i] : createNormalItem(QString(), errorItem, type, errorPathIndex));
343
344 parent->appendRow(list);
345
346 setRowHidden(parent->rowCount() - 1, parent->index(), hide);
347
348 return columns[COLUMN_FILE];
349}
350

Callers

nothing calls this directly

Calls 5

getLabelsFunction · 0.85
setIconFileNameMethod · 0.80
rowCountMethod · 0.80
QStringClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected