Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #12747 (GUI: when compliance report is generated the checkers-report should be provided.) #6419

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading