Skip to content

Commit

Permalink
Fix #12747 (GUI: when compliance report is generated the checkers-rep…
Browse files Browse the repository at this point in the history
…ort should be provided.) (#6419)
  • Loading branch information
danmar authored May 22, 2024
1 parent ccfbc0c commit 8156978
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
17 changes: 13 additions & 4 deletions gui/compliancereportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ static std::vector<std::string> toStdStringList(const QStringList& from) {
return ret;
}

ComplianceReportDialog::ComplianceReportDialog(ProjectFile* projectFile, QString resultsFile) :
QDialog(nullptr),
ComplianceReportDialog::ComplianceReportDialog(ProjectFile* projectFile, QString resultsFile, QString checkersReport)
: QDialog(nullptr),
mUI(new Ui::ComplianceReportDialog),
mProjectFile(projectFile),
mResultsFile(std::move(resultsFile))
mResultsFile(std::move(resultsFile)),
mCheckersReport(std::move(checkersReport))
{
mUI->setupUi(this);
mUI->mEditProjectName->setText(projectFile->getProjectName());
Expand Down Expand Up @@ -146,6 +147,13 @@ void ComplianceReportDialog::save()
mProjectFile->write();
}

QTemporaryFile tempCheckersReport;
if (tempCheckersReport.open()) {
QTextStream out(&tempCheckersReport);
out << mCheckersReport << "\n";
tempCheckersReport.close();
}

QTemporaryFile tempFiles;
if (files && tempFiles.open()) {
QTextStream out(&tempFiles);
Expand Down Expand Up @@ -205,7 +213,8 @@ void ComplianceReportDialog::save()

QStringList args{"--project-name=" + projectName,
"--project-version=" + projectVersion,
"--output-file=" + outFile};
"--output-file=" + outFile,
"--checkers-report=" + tempCheckersReport.fileName()};
if (!suppressions.isEmpty())
args << "--suppressions=" + suppressions.join(",");

Expand Down
5 changes: 3 additions & 2 deletions gui/compliancereportdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ComplianceReportDialog final : public QDialog
Q_OBJECT

public:
explicit ComplianceReportDialog(ProjectFile* projectFile, QString resultsFile);
explicit ComplianceReportDialog(ProjectFile* projectFile, QString resultsFile, QString checkersReport);
~ComplianceReportDialog() final;

private slots:
Expand All @@ -46,7 +46,8 @@ private slots:

Ui::ComplianceReportDialog *mUI;
ProjectFile* mProjectFile;
QString mResultsFile;
const QString mResultsFile;
const QString mCheckersReport;
};

#endif // COMPLIANCEREPORTDIALOG_H
3 changes: 2 additions & 1 deletion gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "applicationlist.h"
#include "aboutdialog.h"
#include "analyzerinfo.h"
#include "checkstatistics.h"
#include "checkthread.h"
#include "common.h"
#include "cppcheck.h"
Expand Down Expand Up @@ -1593,7 +1594,7 @@ void MainWindow::complianceReport()

mUI->mResults->save(tempResults.fileName(), Report::XMLV2, mCppcheckCfgProductName);

ComplianceReportDialog dlg(mProjectFile, tempResults.fileName());
ComplianceReportDialog dlg(mProjectFile, tempResults.fileName(), mUI->mResults->getStatistics()->getCheckersReport());
dlg.exec();
}

Expand Down

0 comments on commit 8156978

Please sign in to comment.