| 1028 | } |
| 1029 | |
| 1030 | QString MainWindow::loadAddon(Settings &settings, const QString &filesDir, const QString &pythonCmd, const QString& addon) |
| 1031 | { |
| 1032 | const QString addonFilePath = fromNativePath(ProjectFile::getAddonFilePath(filesDir, addon)); |
| 1033 | |
| 1034 | if (addonFilePath.isEmpty()) |
| 1035 | return tr("File not found: '%1'").arg(addon); |
| 1036 | |
| 1037 | picojson::object obj; |
| 1038 | obj["script"] = picojson::value(addonFilePath.toStdString()); |
| 1039 | if (!pythonCmd.isEmpty()) |
| 1040 | obj["python"] = picojson::value(pythonCmd.toStdString()); |
| 1041 | |
| 1042 | if (!isCppcheckPremium() && addon == "misra") { |
| 1043 | const QString misraFile = fromNativePath(mSettings->value(SETTINGS_MISRA_FILE).toString()); |
| 1044 | if (!misraFile.isEmpty()) { |
| 1045 | QString arg; |
| 1046 | picojson::array arr; |
| 1047 | arg = "--rule-texts=" + misraFile; |
| 1048 | arr.emplace_back(arg.toStdString()); |
| 1049 | obj["args"] = picojson::value(arr); |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | const std::string& json_str = picojson::value(obj).serialize(); |
| 1054 | |
| 1055 | AddonInfo addonInfo; |
| 1056 | const std::string errmsg = addonInfo.getAddonInfo(json_str, settings.exename); |
| 1057 | if (!errmsg.empty()) |
| 1058 | return tr("Failed to load/setup addon %1: %2").arg(addon, QString::fromStdString(errmsg)); |
| 1059 | settings.addonInfos.emplace_back(std::move(addonInfo)); |
| 1060 | |
| 1061 | settings.addons.emplace(json_str); |
| 1062 | |
| 1063 | return ""; |
| 1064 | } |
| 1065 | |
| 1066 | bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs) |
| 1067 | { |
nothing calls this directly
no test coverage detected