From a2454ecbcadc199582ca1cf39b6cbdce634e0ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 23 Aug 2022 20:13:03 +0200 Subject: [PATCH] cli import cppcheck project with premium options --- gui/projectfile.cpp | 2 +- gui/projectfiledialog.cpp | 1 + lib/importproject.cpp | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index cb7d2e41b..2889ba7ee 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -205,7 +205,7 @@ bool ProjectFile::read(const QString &filename) if (xmlReader.name() == QString(CppcheckXml::BughuntingElementName)) mBughunting = true; if (xmlReader.name() == QString(CppcheckXml::CodingStandardsElementName)) - readStringList(mAddons, xmlReader, CppcheckXml::CodingStandardElementName); + readStringList(mCodingStandards, xmlReader, CppcheckXml::CodingStandardElementName); if (xmlReader.name() == QString(CppcheckXml::CertIntPrecisionElementName)) mCertIntPrecision = readInt(xmlReader, 0); diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index d3d242460..835233aeb 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -452,6 +452,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const codingStandards << CODING_STANDARD_AUTOSAR; projectFile->setCodingStandards(codingStandards); projectFile->setCertIntPrecision(mUI->mEditCertIntPrecision->text().toInt()); + projectFile->setBughunting(mUI->mBughunting->isChecked()); projectFile->setClangAnalyzer(mUI->mToolClangAnalyzer->isChecked()); projectFile->setClangTidy(mUI->mToolClangTidy->isChecked()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) diff --git a/lib/importproject.cpp b/lib/importproject.cpp index c403b2e42..4922f014b 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1225,6 +1225,17 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti } } else if (strcmp(node->Name(), CppcheckXml::TagWarningsElementName) == 0) ; // TODO + // Cppcheck Premium features + else if (strcmp(node->Name(), CppcheckXml::BughuntingElementName) == 0) + temp.premiumArgs += " --bughunting"; + else if (strcmp(node->Name(), CppcheckXml::CertIntPrecisionElementName) == 0) + temp.premiumArgs += std::string(" --cert-c-int-precision=") + (node->GetText() ? node->GetText() : "0"); + else if (strcmp(node->Name(), CppcheckXml::CodingStandardsElementName) == 0) { + for (const tinyxml2::XMLElement *child = node->FirstChildElement(); child; child = child->NextSiblingElement()) { + if (strcmp(child->Name(), CppcheckXml::CodingStandardElementName) == 0 && child->GetText()) + temp.premiumArgs += std::string(" --") + child->GetText(); + } + } else return false; } @@ -1238,6 +1249,11 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti settings->clang = temp.clang; settings->clangTidy = temp.clangTidy; + if (!settings->premiumArgs.empty()) + settings->premiumArgs += temp.premiumArgs; + else if (!temp.premiumArgs.empty()) + settings->premiumArgs = temp.premiumArgs.substr(1); + for (const std::string &p : paths) guiProject.pathNames.push_back(p); for (const Suppressions::Suppression &supp : suppressions)