Cppcheck
printablereport.cpp
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2024 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "printablereport.h"
20 
21 #include "erroritem.h"
22 
23 #include <QDir>
24 #include <QList>
25 
27  Report(QString())
28 {}
29 
31 {
32  return true;
33 }
34 
36 {
37  // No header for printable report
38 }
39 
41 {
42  // No footer for printable report
43 }
44 
46 {
47  const QString file = QDir::toNativeSeparators(error.errorPath.back().file);
48  QString line = QString("%1,%2,").arg(file).arg(error.errorPath.back().line);
49  line += QString("%1,%2").arg(GuiSeverity::toString(error.severity)).arg(error.summary);
50 
51  mFormattedReport += line;
52  mFormattedReport += "\n";
53 }
54 
56 {
57  return mFormattedReport;
58 }
59 
A class containing error data for one error.
Definition: erroritem.h:72
static QString toString(Severity severity)
Definition: erroritem.h:40
void writeFooter() override
Write report footer.
const QString & getFormattedReportText() const
Returns the formatted report.
void writeError(const ErrorItem &error) override
Write error to report.
void writeHeader() override
Write report header.
QString mFormattedReport
Stores the formatted report contents.
bool create() override
Create the report (file).
A base class for reports.
Definition: report.h:34
@ error
Programming error.