gui/mainwindow.cpp: use picojson to generate JSON / updated picojson to latest dev version (#5710)

The lastest release of picojson does not support creation of JSONs, so
we need to switch to the current dev version.
This commit is contained in:
Oliver Stöneberg 2023-12-05 19:02:18 +01:00 committed by GitHub
parent 70745b527a
commit 347b188726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 1088 additions and 891 deletions

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@ CheckOptions:
else()
target_include_directories(cppcheck-gui SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS})
endif()
target_include_directories(cppcheck-gui PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/)
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
target_precompile_headers(cppcheck-gui PRIVATE precompiled.h)
endif()

View File

@ -94,6 +94,8 @@
#include <QVariant>
#include <Qt>
#include "json.h"
static const QString compile_commands_json("compile_commands.json");
static QString fromNativePath(const QString& p) {
@ -1005,25 +1007,31 @@ Settings MainWindow::getCppcheckSettings() {
addonFilePath.replace(QChar('\\'), QChar('/'));
// TODO: use picojson to generate the JSON
QString json;
json += "{ \"script\":\"" + addonFilePath + "\"";
picojson::object obj;
obj["script"] = picojson::value(addonFilePath.toStdString());
if (!pythonCmd.isEmpty())
json += ", \"python\":\"" + pythonCmd + "\"";
const QString misraFile = fromNativePath(mSettings->value(SETTINGS_MISRA_FILE).toString());
if (!isCppcheckPremium() && addon == "misra" && !misraFile.isEmpty()) {
QString arg;
if (misraFile.endsWith(".pdf", Qt::CaseInsensitive))
arg = "--misra-pdf=" + misraFile;
else
arg = "--rule-texts=" + misraFile;
json += ", \"args\":[\"" + arg + "\"]";
obj["python"] = picojson::value(pythonCmd.toStdString());
if (!isCppcheckPremium() && addon == "misra") {
const QString misraFile = fromNativePath(mSettings->value(SETTINGS_MISRA_FILE).toString());
if (!misraFile.isEmpty()) {
QString arg;
if (misraFile.endsWith(".pdf", Qt::CaseInsensitive))
arg = "--misra-pdf=" + misraFile;
else
arg = "--rule-texts=" + misraFile;
obj["args"] = picojson::value(arg.toStdString());
}
}
json += " }";
result.addons.emplace(json.toStdString());
picojson::value json;
json.set(std::move(obj));
std::string json_str = json.serialize();
AddonInfo addonInfo;
addonInfo.getAddonInfo(json.toStdString(), result.exename);
addonInfo.getAddonInfo(json_str, result.exename);
result.addonInfos.emplace_back(std::move(addonInfo));
result.addons.emplace(std::move(json_str));
}
if (isCppcheckPremium()) {

View File

@ -23,7 +23,6 @@
SUPPRESS_WARNING_PUSH("-Wfloat-equal")
SUPPRESS_WARNING_CLANG_PUSH("-Wtautological-type-limit-compare")
SUPPRESS_WARNING_GCC_PUSH("-Wparentheses")
SUPPRESS_WARNING_CLANG_PUSH("-Wextra-semi-stmt")
SUPPRESS_WARNING_CLANG_PUSH("-Wzero-as-null-pointer-constant")
@ -32,7 +31,6 @@ SUPPRESS_WARNING_CLANG_PUSH("-Wzero-as-null-pointer-constant")
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_GCC_POP
SUPPRESS_WARNING_CLANG_POP
SUPPRESS_WARNING_POP