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

Method writeError

gui/txtreport.cpp:51–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void TxtReport::writeError(const ErrorItem &error)
52{
53 /*
54 Error example from the core program in text
55 [gui/test.cpp:23] -> [gui/test.cpp:14]: (error) Mismatching allocation and deallocation: k
56 */
57
58 QString line;
59
60 for (int i = 0; i < error.errorPath.size(); i++) {
61 const QString file = QDir::toNativeSeparators(error.errorPath[i].file);
62 line += QString("[%1:%2]").arg(file).arg(error.errorPath[i].line);
63 if (i < error.errorPath.size() - 1) {
64 line += " -> ";
65 }
66
67 if (i == error.errorPath.size() - 1) {
68 line += ": ";
69 }
70 }
71 QString temp = "(%1";
72 if (error.inconclusive) {
73 temp += ", ";
74 temp += tr("inconclusive");
75 }
76 temp += ") ";
77 line += temp.arg(GuiSeverity::toString(error.severity));
78 line += error.summary;
79
80 mTxtWriter << line << Qt::endl;
81}

Callers 1

saveErrorsMethod · 0.45

Calls 3

QStringClass · 0.70
toStringFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected