forked from qt-creator/qt-creator
Cppcheck: Fix handling of settings
We need to distinguish between the global settings and the settings used for a manual analyzer run. Fixes: QTCREATORBUG-28951 Fixes: QTCREATORBUG-30615 Change-Id: Ic2dabd14e4d06d77bebcedd9e653f54a4d179c82 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -52,7 +52,9 @@ ManualRunDialog::ManualRunDialog(const ProjectExplorer::Project *project)
|
|||||||
analyzeButton->setEnabled(m_model->hasCheckedFiles());
|
analyzeButton->setEnabled(m_model->hasCheckedFiles());
|
||||||
});
|
});
|
||||||
|
|
||||||
auto optionsWidget = settings().layouter()().emerge();
|
m_manualRunSettings.readSettings();
|
||||||
|
m_manualRunSettings.setAutoApply(true);
|
||||||
|
auto optionsWidget = m_manualRunSettings.layouter()().emerge();
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(this);
|
auto layout = new QVBoxLayout(this);
|
||||||
layout->addWidget(optionsWidget);
|
layout->addWidget(optionsWidget);
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "cppchecksettings.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
@@ -25,8 +27,10 @@ public:
|
|||||||
Utils::FilePaths filePaths() const;
|
Utils::FilePaths filePaths() const;
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
const CppcheckSettings &manualRunSettings() const { return m_manualRunSettings; }
|
||||||
private:
|
private:
|
||||||
ProjectExplorer::SelectableFilesFromDirModel *m_model;
|
ProjectExplorer::SelectableFilesFromDirModel *m_model;
|
||||||
|
CppcheckSettings m_manualRunSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Cppcheck::Internal
|
} // Cppcheck::Internal
|
||||||
|
@@ -56,9 +56,9 @@ public:
|
|||||||
|
|
||||||
CppcheckPluginPrivate::CppcheckPluginPrivate()
|
CppcheckPluginPrivate::CppcheckPluginPrivate()
|
||||||
{
|
{
|
||||||
tool.updateOptions();
|
tool.updateOptions(settings());
|
||||||
connect(&settings(), &AspectContainer::changed, this, [this] {
|
connect(&settings(), &AspectContainer::changed, this, [this] {
|
||||||
tool.updateOptions();
|
tool.updateOptions(settings());
|
||||||
trigger.recheck();
|
trigger.recheck();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -112,8 +112,6 @@ void CppcheckPluginPrivate::startManualRun()
|
|||||||
if (!project)
|
if (!project)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
manualRunTool.updateOptions();
|
|
||||||
|
|
||||||
ManualRunDialog dialog(project);
|
ManualRunDialog dialog(project);
|
||||||
if (dialog.exec() == ManualRunDialog::Rejected)
|
if (dialog.exec() == ManualRunDialog::Rejected)
|
||||||
return;
|
return;
|
||||||
@@ -125,7 +123,7 @@ void CppcheckPluginPrivate::startManualRun()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
manualRunTool.setProject(project);
|
manualRunTool.setProject(project);
|
||||||
manualRunTool.updateOptions();
|
manualRunTool.updateOptions(dialog.manualRunSettings());
|
||||||
manualRunTool.check(files);
|
manualRunTool.check(files);
|
||||||
perspective.select();
|
perspective.select();
|
||||||
}
|
}
|
||||||
|
@@ -39,10 +39,10 @@ CppcheckTool::CppcheckTool(CppcheckDiagnosticManager &manager, const Id &progres
|
|||||||
|
|
||||||
CppcheckTool::~CppcheckTool() = default;
|
CppcheckTool::~CppcheckTool() = default;
|
||||||
|
|
||||||
void CppcheckTool::updateOptions()
|
void CppcheckTool::updateOptions(const CppcheckSettings &settings)
|
||||||
{
|
{
|
||||||
m_filters.clear();
|
m_filters.clear();
|
||||||
for (const QString &pattern : settings().ignoredPatterns().split(',')) {
|
for (const QString &pattern : settings.ignoredPatterns().split(',')) {
|
||||||
const QString trimmedPattern = pattern.trimmed();
|
const QString trimmedPattern = pattern.trimmed();
|
||||||
if (trimmedPattern.isEmpty())
|
if (trimmedPattern.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
@@ -52,56 +52,54 @@ void CppcheckTool::updateOptions()
|
|||||||
m_filters.push_back(re);
|
m_filters.push_back(re);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateArguments();
|
updateArguments(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckTool::setProject(ProjectExplorer::Project *project)
|
void CppcheckTool::setProject(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
m_project = project;
|
m_project = project;
|
||||||
updateArguments();
|
updateArguments(settings());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppcheckTool::updateArguments()
|
void CppcheckTool::updateArguments(const CppcheckSettings &settings)
|
||||||
{
|
{
|
||||||
if (!m_project)
|
if (!m_project)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_cachedAdditionalArguments.clear();
|
m_cachedAdditionalArguments.clear();
|
||||||
|
|
||||||
CppcheckSettings &s = settings();
|
|
||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
if (!s.customArguments().isEmpty()) {
|
if (!settings.customArguments().isEmpty()) {
|
||||||
Utils::MacroExpander *expander = Utils::globalMacroExpander();
|
Utils::MacroExpander *expander = Utils::globalMacroExpander();
|
||||||
const QString expanded = expander->expand(s.customArguments());
|
const QString expanded = expander->expand(settings.customArguments());
|
||||||
arguments.push_back(expanded);
|
arguments.push_back(expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.warning())
|
if (settings.warning())
|
||||||
arguments.push_back("--enable=warning");
|
arguments.push_back("--enable=warning");
|
||||||
if (s.style())
|
if (settings.style())
|
||||||
arguments.push_back("--enable=style");
|
arguments.push_back("--enable=style");
|
||||||
if (s.performance())
|
if (settings.performance())
|
||||||
arguments.push_back("--enable=performance");
|
arguments.push_back("--enable=performance");
|
||||||
if (s.portability())
|
if (settings.portability())
|
||||||
arguments.push_back("--enable=portability");
|
arguments.push_back("--enable=portability");
|
||||||
if (s.information())
|
if (settings.information())
|
||||||
arguments.push_back("--enable=information");
|
arguments.push_back("--enable=information");
|
||||||
if (s.unusedFunction())
|
if (settings.unusedFunction())
|
||||||
arguments.push_back("--enable=unusedFunction");
|
arguments.push_back("--enable=unusedFunction");
|
||||||
if (s.missingInclude())
|
if (settings.missingInclude())
|
||||||
arguments.push_back("--enable=missingInclude");
|
arguments.push_back("--enable=missingInclude");
|
||||||
if (s.inconclusive())
|
if (settings.inconclusive())
|
||||||
arguments.push_back("--inconclusive");
|
arguments.push_back("--inconclusive");
|
||||||
if (s.forceDefines())
|
if (settings.forceDefines())
|
||||||
arguments.push_back("--force");
|
arguments.push_back("--force");
|
||||||
|
|
||||||
if (!s.unusedFunction() && !s.customArguments().contains("-j "))
|
if (!settings.unusedFunction() && !settings.customArguments().contains("-j "))
|
||||||
arguments.push_back("-j " + QString::number(QThread::idealThreadCount()));
|
arguments.push_back("-j " + QString::number(QThread::idealThreadCount()));
|
||||||
|
|
||||||
arguments.push_back("--template=\"{file},{line},{severity},{id},{message}\"");
|
arguments.push_back("--template=\"{file},{line},{severity},{id},{message}\"");
|
||||||
|
|
||||||
m_runner->reconfigure(s.binary.effectiveBinary(), arguments.join(' '));
|
m_runner->reconfigure(settings.binary.effectiveBinary(), arguments.join(' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CppcheckTool::additionalArguments(const CppEditor::ProjectPart &part) const
|
QStringList CppcheckTool::additionalArguments(const CppEditor::ProjectPart &part) const
|
||||||
|
@@ -24,6 +24,7 @@ namespace Cppcheck::Internal {
|
|||||||
|
|
||||||
class CppcheckRunner;
|
class CppcheckRunner;
|
||||||
class CppcheckDiagnosticManager;
|
class CppcheckDiagnosticManager;
|
||||||
|
class CppcheckSettings;
|
||||||
|
|
||||||
class CppcheckTool final : public QObject
|
class CppcheckTool final : public QObject
|
||||||
{
|
{
|
||||||
@@ -33,7 +34,7 @@ public:
|
|||||||
CppcheckTool(CppcheckDiagnosticManager &manager, const Utils::Id &progressId);
|
CppcheckTool(CppcheckDiagnosticManager &manager, const Utils::Id &progressId);
|
||||||
~CppcheckTool() override;
|
~CppcheckTool() override;
|
||||||
|
|
||||||
void updateOptions();
|
void updateOptions(const CppcheckSettings &settings);
|
||||||
void setProject(ProjectExplorer::Project *project);
|
void setProject(ProjectExplorer::Project *project);
|
||||||
void check(const Utils::FilePaths &files);
|
void check(const Utils::FilePaths &files);
|
||||||
void stop(const Utils::FilePaths &files);
|
void stop(const Utils::FilePaths &files);
|
||||||
@@ -45,7 +46,7 @@ public:
|
|||||||
void finishWithFail(const QString &exitMessage);
|
void finishWithFail(const QString &exitMessage);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateArguments();
|
void updateArguments(const CppcheckSettings &settings);
|
||||||
void addToQueue(const Utils::FilePaths &files, const CppEditor::ProjectPart &part);
|
void addToQueue(const Utils::FilePaths &files, const CppEditor::ProjectPart &part);
|
||||||
QStringList additionalArguments(const CppEditor::ProjectPart &part) const;
|
QStringList additionalArguments(const CppEditor::ProjectPart &part) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user