cli import cppcheck project with premium options

This commit is contained in:
Daniel Marjamäki 2022-08-23 20:13:03 +02:00
parent 4be7f689d7
commit a2454ecbca
3 changed files with 18 additions and 1 deletions

View File

@ -205,7 +205,7 @@ bool ProjectFile::read(const QString &filename)
if (xmlReader.name() == QString(CppcheckXml::BughuntingElementName)) if (xmlReader.name() == QString(CppcheckXml::BughuntingElementName))
mBughunting = true; mBughunting = true;
if (xmlReader.name() == QString(CppcheckXml::CodingStandardsElementName)) if (xmlReader.name() == QString(CppcheckXml::CodingStandardsElementName))
readStringList(mAddons, xmlReader, CppcheckXml::CodingStandardElementName); readStringList(mCodingStandards, xmlReader, CppcheckXml::CodingStandardElementName);
if (xmlReader.name() == QString(CppcheckXml::CertIntPrecisionElementName)) if (xmlReader.name() == QString(CppcheckXml::CertIntPrecisionElementName))
mCertIntPrecision = readInt(xmlReader, 0); mCertIntPrecision = readInt(xmlReader, 0);

View File

@ -452,6 +452,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
codingStandards << CODING_STANDARD_AUTOSAR; codingStandards << CODING_STANDARD_AUTOSAR;
projectFile->setCodingStandards(codingStandards); projectFile->setCodingStandards(codingStandards);
projectFile->setCertIntPrecision(mUI->mEditCertIntPrecision->text().toInt()); projectFile->setCertIntPrecision(mUI->mEditCertIntPrecision->text().toInt());
projectFile->setBughunting(mUI->mBughunting->isChecked());
projectFile->setClangAnalyzer(mUI->mToolClangAnalyzer->isChecked()); projectFile->setClangAnalyzer(mUI->mToolClangAnalyzer->isChecked());
projectFile->setClangTidy(mUI->mToolClangTidy->isChecked()); projectFile->setClangTidy(mUI->mToolClangTidy->isChecked());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))

View File

@ -1225,6 +1225,17 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
} }
} else if (strcmp(node->Name(), CppcheckXml::TagWarningsElementName) == 0) } else if (strcmp(node->Name(), CppcheckXml::TagWarningsElementName) == 0)
; // TODO ; // 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 else
return false; return false;
} }
@ -1238,6 +1249,11 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
settings->clang = temp.clang; settings->clang = temp.clang;
settings->clangTidy = temp.clangTidy; 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) for (const std::string &p : paths)
guiProject.pathNames.push_back(p); guiProject.pathNames.push_back(p);
for (const Suppressions::Suppression &supp : suppressions) for (const Suppressions::Suppression &supp : suppressions)