Skip to content

Commit a2454ec

Browse files
committed
cli import cppcheck project with premium options
1 parent 4be7f68 commit a2454ec

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

gui/projectfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ bool ProjectFile::read(const QString &filename)
205205
if (xmlReader.name() == QString(CppcheckXml::BughuntingElementName))
206206
mBughunting = true;
207207
if (xmlReader.name() == QString(CppcheckXml::CodingStandardsElementName))
208-
readStringList(mAddons, xmlReader, CppcheckXml::CodingStandardElementName);
208+
readStringList(mCodingStandards, xmlReader, CppcheckXml::CodingStandardElementName);
209209
if (xmlReader.name() == QString(CppcheckXml::CertIntPrecisionElementName))
210210
mCertIntPrecision = readInt(xmlReader, 0);
211211

gui/projectfiledialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ void ProjectFileDialog::saveToProjectFile(ProjectFile *projectFile) const
452452
codingStandards << CODING_STANDARD_AUTOSAR;
453453
projectFile->setCodingStandards(codingStandards);
454454
projectFile->setCertIntPrecision(mUI->mEditCertIntPrecision->text().toInt());
455+
projectFile->setBughunting(mUI->mBughunting->isChecked());
455456
projectFile->setClangAnalyzer(mUI->mToolClangAnalyzer->isChecked());
456457
projectFile->setClangTidy(mUI->mToolClangTidy->isChecked());
457458
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))

lib/importproject.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,17 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
12251225
}
12261226
} else if (strcmp(node->Name(), CppcheckXml::TagWarningsElementName) == 0)
12271227
; // TODO
1228+
// Cppcheck Premium features
1229+
else if (strcmp(node->Name(), CppcheckXml::BughuntingElementName) == 0)
1230+
temp.premiumArgs += " --bughunting";
1231+
else if (strcmp(node->Name(), CppcheckXml::CertIntPrecisionElementName) == 0)
1232+
temp.premiumArgs += std::string(" --cert-c-int-precision=") + (node->GetText() ? node->GetText() : "0");
1233+
else if (strcmp(node->Name(), CppcheckXml::CodingStandardsElementName) == 0) {
1234+
for (const tinyxml2::XMLElement *child = node->FirstChildElement(); child; child = child->NextSiblingElement()) {
1235+
if (strcmp(child->Name(), CppcheckXml::CodingStandardElementName) == 0 && child->GetText())
1236+
temp.premiumArgs += std::string(" --") + child->GetText();
1237+
}
1238+
}
12281239
else
12291240
return false;
12301241
}
@@ -1238,6 +1249,11 @@ bool ImportProject::importCppcheckGuiProject(std::istream &istr, Settings *setti
12381249
settings->clang = temp.clang;
12391250
settings->clangTidy = temp.clangTidy;
12401251

1252+
if (!settings->premiumArgs.empty())
1253+
settings->premiumArgs += temp.premiumArgs;
1254+
else if (!temp.premiumArgs.empty())
1255+
settings->premiumArgs = temp.premiumArgs.substr(1);
1256+
12411257
for (const std::string &p : paths)
12421258
guiProject.pathNames.push_back(p);
12431259
for (const Suppressions::Suppression &supp : suppressions)

0 commit comments

Comments
 (0)