From 2c53b73e1b01b730834eaf7667146147902e2e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 3 Nov 2022 18:20:13 +0100 Subject: [PATCH] GUI: only run misra addon in premium version. remove misra rule texts configuration that is not needed in premium. --- gui/common.h | 1 - gui/mainwindow.cpp | 14 +++------- gui/projectfile.ui | 38 +++++++------------------ gui/projectfiledialog.cpp | 58 +++++++++++++-------------------------- gui/projectfiledialog.h | 5 ---- gui/settings.ui | 34 ----------------------- gui/settingsdialog.cpp | 14 ---------- gui/settingsdialog.h | 5 ---- 8 files changed, 33 insertions(+), 136 deletions(-) diff --git a/gui/common.h b/gui/common.h index 8d42648e6..6f98ac2ac 100644 --- a/gui/common.h +++ b/gui/common.h @@ -80,7 +80,6 @@ #define SETTINGS_LANGUAGE "Application language" #define SETTINGS_GLOBAL_INCLUDE_PATHS "Global include paths" #define SETTINGS_PYTHON_PATH "Python path" -#define SETTINGS_MISRA_FILE "MISRA C 2012 file" #define SETTINGS_CLANG_PATH "Clang path" #define SETTINGS_VS_INCLUDE_PATHS "VS include paths" #define SETTINGS_INLINE_SUPPRESSIONS "Inline suppressions" diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index ca52cdde7..97b6da44a 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -971,15 +971,6 @@ Settings MainWindow::getCppcheckSettings() json += "{ \"script\":\"" + addonFilePath + "\""; if (!pythonCmd.isEmpty()) json += ", \"python\":\"" + pythonCmd + "\""; - QString misraFile = fromNativePath(mSettings->value(SETTINGS_MISRA_FILE).toString()); - if (addon == "misra" && !misraFile.isEmpty()) { - QString arg; - if (misraFile.endsWith(".pdf", Qt::CaseInsensitive)) - arg = "--misra-pdf=" + misraFile; - else - arg = "--rule-texts=" + misraFile; - json += ", \"args\":[\"" + arg + "\"]"; - } json += " }"; result.addons.emplace(json.toStdString()); } @@ -1923,8 +1914,11 @@ static int getVersion(const QString& nameWithVersion) { for (const auto c: nameWithVersion) { if (c == '\n' || c == '\r') break; - else if (c == ' ') + else if (c == ' ') { + if (ret > 0 && dot == 1 && nameWithVersion.endsWith(" dev")) + return ret * 1000000 + v * 1000 + 500; dot = ret = v = 0; + } else if (c == '.') { ++dot; ret = ret * 1000 + v; diff --git a/gui/projectfile.ui b/gui/projectfile.ui index 96384385b..26ca08a45 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -779,7 +779,7 @@ - Coding standards + Coding standards (Premium) @@ -790,32 +790,14 @@ - - - - - MISRA rule texts - - - - - - - <html><head/><body><p>Copy/paste the text from Appendix A &quot;Summary of guidelines&quot; from the MISRA C 2012 pdf to a text file.</p></body></html> - - - - - - - ... - - - - + + + Misra C++ 2008 + + - + Cert C @@ -836,9 +818,9 @@ - + - Misra C++ 2008 + Cert C++ @@ -855,7 +837,7 @@ - Bug hunting + Bug hunting (Premium) diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index c0b6f1ef5..0979840ca 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -43,6 +43,7 @@ static const char ADDON_MISRA[] = "misra"; static const char CODING_STANDARD_MISRA_CPP_2008[] = "misra-cpp-2008"; static const char CODING_STANDARD_CERT_C[] = "cert-c-2016"; +static const char CODING_STANDARD_CERT_CPP[] = "cert-cpp-2016"; static const char CODING_STANDARD_AUTOSAR[] = "autosar"; class QModelIndex; @@ -224,7 +225,6 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi connect(mUI->mBtnAddSuppression, &QPushButton::clicked, this, &ProjectFileDialog::addSuppression); connect(mUI->mBtnRemoveSuppression, &QPushButton::clicked, this, &ProjectFileDialog::removeSuppression); connect(mUI->mListSuppressions, &QListWidget::doubleClicked, this, &ProjectFileDialog::editSuppression); - connect(mUI->mBtnBrowseMisraFile, &QPushButton::clicked, this, &ProjectFileDialog::browseMisraFile); connect(mUI->mChkAllVsConfigs, &QCheckBox::clicked, this, &ProjectFileDialog::checkAllVSConfigs); loadFromProjectFile(projectFile); } @@ -349,35 +349,30 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile) const QString dataDir = getDataDir(); updateAddonCheckBox(mUI->mAddonThreadSafety, projectFile, dataDir, "threadsafety"); updateAddonCheckBox(mUI->mAddonY2038, projectFile, dataDir, "y2038"); - updateAddonCheckBox(mUI->mMisraC2012, projectFile, dataDir, ADDON_MISRA); - const QString &misraFile = settings.value(SETTINGS_MISRA_FILE, QString()).toString(); - mUI->mEditMisraFile->setText(misraFile); - if (mPremium) { - mUI->mLabelMisraFile->setVisible(false); - mUI->mEditMisraFile->setVisible(false); - mUI->mBtnBrowseMisraFile->setVisible(false); - } else if (!mUI->mMisraC2012->isEnabled()) { - mUI->mEditMisraFile->setEnabled(false); - mUI->mBtnBrowseMisraFile->setEnabled(false); - } - - mUI->mPremiumCertC->setChecked(projectFile->getCodingStandards().contains(CODING_STANDARD_CERT_C)); - mUI->mMisraCpp2008->setChecked(projectFile->getCodingStandards().contains(CODING_STANDARD_MISRA_CPP_2008)); - mUI->mAutosar->setChecked(projectFile->getCodingStandards().contains(CODING_STANDARD_AUTOSAR)); + if (mPremium) + updateAddonCheckBox(mUI->mMisraC2012, projectFile, dataDir, ADDON_MISRA); + else + mUI->mMisraC2012->setChecked(false); + mUI->mCertC2016->setChecked(mPremium && projectFile->getCodingStandards().contains(CODING_STANDARD_CERT_C)); + mUI->mCertCpp2016->setChecked(mPremium && projectFile->getCodingStandards().contains(CODING_STANDARD_CERT_CPP)); + mUI->mMisraCpp2008->setChecked(mPremium && projectFile->getCodingStandards().contains(CODING_STANDARD_MISRA_CPP_2008)); + mUI->mAutosar->setChecked(mPremium && projectFile->getCodingStandards().contains(CODING_STANDARD_AUTOSAR)); if (projectFile->getCertIntPrecision() <= 0) mUI->mEditCertIntPrecision->setText(QString()); else mUI->mEditCertIntPrecision->setText(QString::number(projectFile->getCertIntPrecision())); - mUI->mPremiumCertC->setVisible(mPremium); - mUI->mMisraCpp2008->setVisible(mPremium); - mUI->mAutosar->setVisible(mPremium); + mUI->mMisraC2012->setEnabled(mPremium); + mUI->mMisraCpp2008->setEnabled(mPremium); + mUI->mCertC2016->setEnabled(mPremium); + mUI->mCertCpp2016->setEnabled(mPremium); + mUI->mAutosar->setEnabled(mPremium); mUI->mLabelCertIntPrecision->setVisible(mPremium); mUI->mEditCertIntPrecision->setVisible(mPremium); - mUI->mBughunting->setChecked(projectFile->getBughunting()); - mUI->mGroupboxBughunting->setVisible(mPremium); + mUI->mBughunting->setChecked(mPremium && projectFile->getBughunting()); + mUI->mBughunting->setEnabled(mPremium); mUI->mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer()); mUI->mToolClangTidy->setChecked(projectFile->getClangTidy()); @@ -444,8 +439,10 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const addons << ADDON_MISRA; projectFile->setAddons(addons); QStringList codingStandards; - if (mUI->mPremiumCertC->isChecked()) + if (mUI->mCertC2016->isChecked()) codingStandards << CODING_STANDARD_CERT_C; + if (mUI->mCertCpp2016->isChecked()) + codingStandards << CODING_STANDARD_CERT_CPP; if (mUI->mMisraCpp2008->isChecked()) codingStandards << CODING_STANDARD_MISRA_CPP_2008; if (mUI->mAutosar->isChecked()) @@ -902,20 +899,3 @@ int ProjectFileDialog::getSuppressionIndex(const QString &shortText) const } return -1; } - -void ProjectFileDialog::browseMisraFile() -{ - const QString fileName = QFileDialog::getOpenFileName(this, - tr("Select MISRA rule texts file"), - QDir::homePath(), - tr("MISRA rule texts file (%1)").arg("*.txt")); - if (!fileName.isEmpty()) { - QSettings settings; - mUI->mEditMisraFile->setText(fileName); - settings.setValue(SETTINGS_MISRA_FILE, fileName); - - mUI->mMisraC2012->setText("MISRA C 2012"); - mUI->mMisraC2012->setEnabled(true); - updateAddonCheckBox(mUI->mMisraC2012, nullptr, getDataDir(), ADDON_MISRA); - } -} diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index d7f803e8a..9f5a00bc6 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -267,11 +267,6 @@ protected slots: */ void editSuppression(const QModelIndex &index); - /** - * @brief Browse for misra file - */ - void browseMisraFile(); - /** * @brief Check for all VS configurations */ diff --git a/gui/settings.ui b/gui/settings.ui index d2a08907b..58a20da08 100644 --- a/gui/settings.ui +++ b/gui/settings.ui @@ -324,40 +324,6 @@ - - - - MISRA addon - - - - - - - - MISRA rule texts file - - - - - - - <html><head/><body><p>Copy/paste the text from Appendix A &quot;Summary of guidelines&quot; from the MISRA C 2012 pdf to a text file.</p></body></html> - - - - - - - ... - - - - - - - - diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index f7d09cb31..be04a0a54 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -65,11 +65,6 @@ SettingsDialog::SettingsDialog(ApplicationList *list, mUI->mCheckForUpdates->setCheckState(boolToCheckState(settings.value(SETTINGS_CHECK_FOR_UPDATES, false).toBool())); mUI->mEditPythonPath->setText(settings.value(SETTINGS_PYTHON_PATH, QString()).toString()); validateEditPythonPath(); - if (premium) - mUI->mEditMisraFile->setVisible(false); - else - mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString()); - mUI->mEditMisraFile->setText(settings.value(SETTINGS_MISRA_FILE, QString()).toString()); #ifdef Q_OS_WIN //mUI->mTabClang->setVisible(true); @@ -99,7 +94,6 @@ SettingsDialog::SettingsDialog(ApplicationList *list, this, SLOT(editApplication())); connect(mUI->mBtnBrowsePythonPath, &QPushButton::clicked, this, &SettingsDialog::browsePythonPath); - connect(mUI->mBtnBrowseMisraFile, &QPushButton::clicked, this, &SettingsDialog::browseMisraFile); connect(mUI->mBtnEditTheme, SIGNAL(clicked()), this, SLOT(editCodeEditorStyle())); connect(mUI->mThemeSystem, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault())); connect(mUI->mThemeDark, SIGNAL(released()), this, SLOT(setCodeEditorStyleDefault())); @@ -191,7 +185,6 @@ void SettingsDialog::saveSettingValues() const saveCheckboxValue(&settings, mUI->mShowErrorId, SETTINGS_SHOW_ERROR_ID); saveCheckboxValue(&settings, mUI->mCheckForUpdates, SETTINGS_CHECK_FOR_UPDATES); settings.setValue(SETTINGS_PYTHON_PATH, mUI->mEditPythonPath->text()); - settings.setValue(SETTINGS_MISRA_FILE, mUI->mEditMisraFile->text()); #ifdef Q_OS_WIN settings.setValue(SETTINGS_CLANG_PATH, mUI->mEditClangPath->text()); @@ -357,13 +350,6 @@ void SettingsDialog::browsePythonPath() mUI->mEditPythonPath->setText(fileName); } -void SettingsDialog::browseMisraFile() -{ - const QString fileName = QFileDialog::getOpenFileName(this, tr("Select MISRA File"), QDir::homePath(), "Misra File (*.pdf *.txt)"); - if (!fileName.isEmpty()) - mUI->mEditMisraFile->setText(fileName); -} - // Slot to set default light style void SettingsDialog::setCodeEditorStyleDefault() { diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index d1caab630..2c4e30cd8 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -141,11 +141,6 @@ protected slots: /** @brief Slot for browsing for the clang binary */ void browseClangPath(); - /** - * @brief Browse for MISRA file - */ - void browseMisraFile(); - /** * @brief Set Code Editor Style to Default */