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

Method addErrorItem

gui/resultstree.cpp:241–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241bool ResultsTree::addErrorItem(const ErrorItem& errorItem)
242{
243 if (errorItem.errorPath.isEmpty())
244 return false;
245
246 const QString s = errorItem.toString();
247 if (mErrorList.contains(s))
248 return false;
249 mErrorList.append(s);
250
251 QSharedPointer<ErrorItem> errorItemPtr{new ErrorItem(errorItem)};
252
253 if (mReportType != ReportType::normal) {
254 errorItemPtr->guideline = getGuideline(mReportType, mGuideline, errorItemPtr->errorId, errorItemPtr->severity);
255 errorItemPtr->classification = getClassification(mReportType, errorItemPtr->guideline);
256 }
257
258 const bool showItem = !isErrorItemHidden(errorItemPtr);
259
260 // if there is at least one error that is not hidden, we have a visible error
261 mVisibleErrors |= showItem;
262
263 if (const ProjectFile *activeProject = ProjectFile::getActiveProject())
264 errorItemPtr->tags = activeProject->getWarningTags(errorItemPtr->hash);
265 //Create the base item for the error and ensure it has a proper
266 //file item as a parent
267 ResultItem* fileItem = ensureFileItem(errorItemPtr, !showItem);
268 ResultItem* stditem = addBacktraceFiles(fileItem,
269 errorItemPtr,
270 !showItem,
271 severityToIcon(getSeverity(mReportType, *errorItemPtr)),
272 ResultItem::Type::message,
273 errorItemPtr->getMainLocIndex());
274
275 if (!stditem)
276 return false;
277
278 //Add backtrace files as children
279 if (errorItemPtr->errorPath.size() > 1) {
280 for (int i = 0; i < errorItemPtr->errorPath.size(); i++) {
281 addBacktraceFiles(stditem,
282 errorItemPtr,
283 false,
284 ":images/go-down.png",
285 ResultItem::Type::note,
286 i);
287 }
288 }
289
290 return true;
291}
292
293ResultItem *ResultsTree::addBacktraceFiles(ResultItem *parent,
294 const QSharedPointer<ErrorItem>& errorItem,

Callers 10

errorMethod · 0.80
readErrorsXmlMethod · 0.80
test1Method · 0.80
duplicateResultsMethod · 0.80
multiLineResultMethod · 0.80
resultsInSameFileMethod · 0.80
testReportTypeMethod · 0.80
testReportTypeIconMethod · 0.80
testGetGuidelineErrorMethod · 0.80

Calls 9

getSeverityFunction · 0.85
isEmptyMethod · 0.80
getMainLocIndexMethod · 0.80
getGuidelineFunction · 0.70
getClassificationFunction · 0.70
toStringMethod · 0.45
containsMethod · 0.45
getWarningTagsMethod · 0.45
sizeMethod · 0.45

Tested by 8

test1Method · 0.64
duplicateResultsMethod · 0.64
multiLineResultMethod · 0.64
resultsInSameFileMethod · 0.64
testReportTypeMethod · 0.64
testReportTypeIconMethod · 0.64
testGetGuidelineErrorMethod · 0.64