Load cppcheck.cfg in FILESDIR if that is specified
This commit is contained in:
parent
b2f1a0aaa9
commit
ed4d2c21e6
|
@ -917,7 +917,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mSettings->loadCppcheckCfg(Path::getPathFromFilename(argv[0]) + "cppcheck.cfg");
|
mSettings->loadCppcheckCfg(argv[0]);
|
||||||
|
|
||||||
// Default template format..
|
// Default template format..
|
||||||
if (mSettings->templateFormat.empty()) {
|
if (mSettings->templateFormat.empty()) {
|
||||||
|
|
|
@ -508,9 +508,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar
|
||||||
checkSettings.checkLibrary = checkLibrary;
|
checkSettings.checkLibrary = checkLibrary;
|
||||||
checkSettings.checkConfiguration = checkConfiguration;
|
checkSettings.checkConfiguration = checkConfiguration;
|
||||||
|
|
||||||
const QString applicationFilePath = QCoreApplication::applicationFilePath();
|
checkSettings.loadCppcheckCfg(QCoreApplication::applicationFilePath().toStdString());
|
||||||
const QString appPath = QFileInfo(applicationFilePath).canonicalPath();
|
|
||||||
checkSettings.loadCppcheckCfg(appPath.toStdString() + "/cppcheck.cfg");
|
|
||||||
|
|
||||||
if (mProjectFile)
|
if (mProjectFile)
|
||||||
qDebug() << "Checking project file" << mProjectFile->getFilename();
|
qDebug() << "Checking project file" << mProjectFile->getFilename();
|
||||||
|
|
|
@ -76,9 +76,15 @@ Settings::Settings()
|
||||||
certainty.setEnabled(Certainty::normal, true);
|
certainty.setEnabled(Certainty::normal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::loadCppcheckCfg(const std::string &filename)
|
void Settings::loadCppcheckCfg(const std::string &exename)
|
||||||
{
|
{
|
||||||
std::ifstream fin(filename);
|
std::string fileName = Path::getPathFromFilename(exename) + "cppcheck.cfg";
|
||||||
|
#ifdef FILESDIR
|
||||||
|
if (Path::fileExists(FILESDIR "/cppcheck.cfg"))
|
||||||
|
fileName = FILESDIR "/cppcheck.cfg";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::ifstream fin(fileName);
|
||||||
if (!fin.is_open())
|
if (!fin.is_open())
|
||||||
return;
|
return;
|
||||||
picojson::value json;
|
picojson::value json;
|
||||||
|
@ -90,7 +96,7 @@ void Settings::loadCppcheckCfg(const std::string &filename)
|
||||||
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
|
for (const picojson::value &v : obj["addons"].get<picojson::array>()) {
|
||||||
const std::string &s = v.get<std::string>();
|
const std::string &s = v.get<std::string>();
|
||||||
if (!Path::isAbsolute(s))
|
if (!Path::isAbsolute(s))
|
||||||
addons.push_back(Path::getPathFromFilename(filename) + s);
|
addons.push_back(Path::getPathFromFilename(fileName) + s);
|
||||||
else
|
else
|
||||||
addons.push_back(s);
|
addons.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,7 +95,7 @@ private:
|
||||||
public:
|
public:
|
||||||
Settings();
|
Settings();
|
||||||
|
|
||||||
void loadCppcheckCfg(const std::string &filename);
|
void loadCppcheckCfg(const std::string &exepath);
|
||||||
|
|
||||||
/** @brief addons, either filename of python/json file or json data */
|
/** @brief addons, either filename of python/json file or json data */
|
||||||
std::list<std::string> addons;
|
std::list<std::string> addons;
|
||||||
|
|
Loading…
Reference in New Issue