This commit is contained in:
parent
6017c254dd
commit
74ad7243ce
|
@ -191,13 +191,7 @@ void ComplianceReportDialog::save()
|
|||
"--project-version=" + projectVersion,
|
||||
"--output-file=" + outFile};
|
||||
|
||||
if (std.startsWith("misra-c-")) {
|
||||
args << "--misra-c"
|
||||
<< "--compliant=misra-c2012-1.1"
|
||||
<< "--compliant=misra-c2012-1.2";
|
||||
} else {
|
||||
args << ("--" + std);
|
||||
}
|
||||
args << ("--" + std);
|
||||
|
||||
if (files)
|
||||
args << "--files=" + tempFiles.fileName();
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<widget class="QComboBox" name="mCodingStandard">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Misra C 2023</string>
|
||||
<string>Misra C</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -1020,11 +1020,10 @@ Settings MainWindow::getCppcheckSettings()
|
|||
premiumArgs += " --bughunting";
|
||||
if (mProjectFile->getCertIntPrecision() > 0)
|
||||
premiumArgs += " --cert-c-int-precision=" + QString::number(mProjectFile->getCertIntPrecision());
|
||||
if (mProjectFile->getAddons().contains("misra"))
|
||||
premiumArgs += " --misra-c-2012";
|
||||
for (const QString& c: mProjectFile->getCodingStandards()) {
|
||||
for (const QString& c: mProjectFile->getCodingStandards())
|
||||
premiumArgs += " --" + c;
|
||||
}
|
||||
if (!premiumArgs.contains("misra") && mProjectFile->getAddons().contains("misra"))
|
||||
premiumArgs += " --misra-c-2012";
|
||||
result.premiumArgs = premiumArgs.mid(1).toStdString();
|
||||
}
|
||||
}
|
||||
|
@ -1495,16 +1494,24 @@ void MainWindow::save()
|
|||
|
||||
void MainWindow::complianceReport()
|
||||
{
|
||||
if (isCppcheckPremium() && mProjectFile && mProjectFile->getAddons().contains("misra")) {
|
||||
QTemporaryFile tempResults;
|
||||
tempResults.open();
|
||||
tempResults.close();
|
||||
|
||||
mUI->mResults->save(tempResults.fileName(), Report::XMLV2);
|
||||
|
||||
ComplianceReportDialog dlg(mProjectFile, tempResults.fileName());
|
||||
dlg.exec();
|
||||
if (!mUI->mResults->isSuccess()) {
|
||||
QMessageBox m(QMessageBox::Critical,
|
||||
"Cppcheck",
|
||||
tr("Cannot generate a compliance report right now, an analysis must finish successfully. Try to reanalyze the code and ensure there are no critical errors."),
|
||||
QMessageBox::Ok,
|
||||
this);
|
||||
m.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
QTemporaryFile tempResults;
|
||||
tempResults.open();
|
||||
tempResults.close();
|
||||
|
||||
mUI->mResults->save(tempResults.fileName(), Report::XMLV2);
|
||||
|
||||
ComplianceReportDialog dlg(mProjectFile, tempResults.fileName());
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void MainWindow::resultsAdded()
|
||||
|
@ -1574,6 +1581,7 @@ void MainWindow::aboutToShowViewMenu()
|
|||
void MainWindow::stopAnalysis()
|
||||
{
|
||||
mThread->stop();
|
||||
mUI->mResults->stopAnalysis();
|
||||
mUI->mResults->disableProgressbar();
|
||||
const QString &lastResults = getLastResults();
|
||||
if (!lastResults.isEmpty()) {
|
||||
|
|
|
@ -90,6 +90,7 @@ void ResultsView::initialize(QSettings *settings, ApplicationList *list, ThreadH
|
|||
{
|
||||
mUI->mProgress->setMinimum(0);
|
||||
mUI->mProgress->setVisible(false);
|
||||
mUI->mLabelCriticalErrors->setVisible(false);
|
||||
|
||||
CodeEditorStyle theStyle(CodeEditorStyle::loadSettings(settings));
|
||||
mUI->mCode->setStyle(theStyle);
|
||||
|
@ -120,6 +121,10 @@ void ResultsView::clear(bool results)
|
|||
mUI->mProgress->setMaximum(PROGRESS_MAX);
|
||||
mUI->mProgress->setValue(0);
|
||||
mUI->mProgress->setFormat("%p%");
|
||||
|
||||
mUI->mLabelCriticalErrors->setVisible(false);
|
||||
|
||||
mSuccess = false;
|
||||
}
|
||||
|
||||
void ResultsView::clear(const QString &filename)
|
||||
|
@ -145,6 +150,8 @@ void ResultsView::progress(int value, const QString& description)
|
|||
|
||||
void ResultsView::error(const ErrorItem &item)
|
||||
{
|
||||
handleCriticalError(item);
|
||||
|
||||
if (mUI->mTree->addErrorItem(item)) {
|
||||
emit gotResults();
|
||||
mStatistics->addItem(item.tool(), ShowTypes::SeverityToShowType(item.severity));
|
||||
|
@ -277,6 +284,7 @@ QString ResultsView::getCheckDirectory()
|
|||
|
||||
void ResultsView::checkingStarted(int count)
|
||||
{
|
||||
mSuccess = true;
|
||||
mUI->mProgress->setVisible(true);
|
||||
mUI->mProgress->setMaximum(PROGRESS_MAX);
|
||||
mUI->mProgress->setValue(0);
|
||||
|
@ -349,6 +357,8 @@ void ResultsView::disableProgressbar()
|
|||
|
||||
void ResultsView::readErrorsXml(const QString &filename)
|
||||
{
|
||||
mSuccess = false; // Don't know if results come from an aborted analysis
|
||||
|
||||
const int version = XmlReport::determineVersion(filename);
|
||||
if (version == 0) {
|
||||
QMessageBox msgBox;
|
||||
|
@ -377,6 +387,7 @@ void ResultsView::readErrorsXml(const QString &filename)
|
|||
}
|
||||
|
||||
for (const ErrorItem& item : errors) {
|
||||
handleCriticalError(item);
|
||||
mUI->mTree->addErrorItem(item);
|
||||
}
|
||||
|
||||
|
@ -506,3 +517,38 @@ void ResultsView::on_mListLog_customContextMenuRequested(const QPoint &pos)
|
|||
|
||||
contextMenu.exec(globalPos);
|
||||
}
|
||||
|
||||
void ResultsView::stopAnalysis()
|
||||
{
|
||||
mSuccess = false;
|
||||
mUI->mLabelCriticalErrors->setText(tr("Analysis was stopped"));
|
||||
mUI->mLabelCriticalErrors->setVisible(true);
|
||||
}
|
||||
|
||||
void ResultsView::handleCriticalError(const ErrorItem &item)
|
||||
{
|
||||
const QSet<QString> criticalErrors{
|
||||
"cppcheckError",
|
||||
"cppcheckLimit",
|
||||
"internalAstError",
|
||||
"instantiationError",
|
||||
"internalError",
|
||||
"preprocessorErrorDirective",
|
||||
"syntaxError",
|
||||
"unknownMacro"
|
||||
};
|
||||
|
||||
if (criticalErrors.contains(item.errorId)) {
|
||||
QString msg = tr("There was a critical error with id '%1'").arg(item.errorId);
|
||||
if (!item.file0.isEmpty())
|
||||
msg += ", " + tr("when checking %1").arg(item.file0);
|
||||
msg += ". " + tr("Analysis was aborted.");
|
||||
mUI->mLabelCriticalErrors->setText(msg);
|
||||
mUI->mLabelCriticalErrors->setVisible(true);
|
||||
mSuccess = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ResultsView::isSuccess() const {
|
||||
return mSuccess;
|
||||
}
|
||||
|
|
|
@ -176,6 +176,17 @@ public:
|
|||
*/
|
||||
void translate();
|
||||
|
||||
/**
|
||||
* @brief This function should be called when analysis is stopped
|
||||
*/
|
||||
void stopAnalysis();
|
||||
|
||||
/**
|
||||
* @brief Are there successful results?
|
||||
* @return true if analysis finished without critical errors etc
|
||||
*/
|
||||
bool isSuccess() const;
|
||||
|
||||
void disableProgressbar();
|
||||
|
||||
/**
|
||||
|
@ -340,7 +351,14 @@ public slots:
|
|||
*/
|
||||
void logCopyComplete();
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
/**
|
||||
* If provided ErrorItem is a critical error then display warning message
|
||||
* in the resultsview
|
||||
*/
|
||||
void handleCriticalError(const ErrorItem& item);
|
||||
|
||||
/**
|
||||
* @brief Should we show a "No errors found dialog" every time no errors were found?
|
||||
*/
|
||||
|
@ -350,6 +368,11 @@ protected:
|
|||
|
||||
CheckStatistics *mStatistics;
|
||||
|
||||
/**
|
||||
* Set to true when checking finish successfully. Set to false whenever analysis starts.
|
||||
*/
|
||||
bool mSuccess = false;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Custom context menu for Analysis Log
|
||||
|
|
|
@ -51,6 +51,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mLabelCriticalErrors">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Critical errors</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="mVerticalSplitter">
|
||||
<property name="orientation">
|
||||
|
|
Loading…
Reference in New Issue