2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2018 Sergey Morozov
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2018-07-30 21:42:47 +03:00
|
|
|
|
|
|
|
|
#include "cppcheckoptions.h"
|
2023-01-09 18:08:30 +01:00
|
|
|
|
|
|
|
|
#include "cppcheckconstants.h"
|
2018-07-30 21:42:47 +03:00
|
|
|
#include "cppchecktool.h"
|
2023-01-09 18:08:30 +01:00
|
|
|
#include "cppchecktr.h"
|
2018-07-30 21:42:47 +03:00
|
|
|
#include "cppchecktrigger.h"
|
|
|
|
|
|
2022-08-24 14:57:57 +02:00
|
|
|
#include <utils/environment.h>
|
2018-07-30 21:42:47 +03:00
|
|
|
#include <utils/flowlayout.h>
|
|
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
2023-05-15 18:00:42 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2018-07-30 21:42:47 +03:00
|
|
|
#include <utils/qtcassert.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/variablechooser.h>
|
2018-07-30 21:42:47 +03:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
2018-10-19 16:14:29 +02:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
2023-02-09 11:43:49 +01:00
|
|
|
#include <debugger/debuggertr.h>
|
2018-10-19 16:14:29 +02:00
|
|
|
|
2021-09-30 16:58:46 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2023-01-09 18:08:30 +01:00
|
|
|
namespace Cppcheck::Internal {
|
2018-07-30 21:42:47 +03:00
|
|
|
|
2023-05-15 18:00:42 +02:00
|
|
|
CppcheckOptions::CppcheckOptions()
|
2018-07-30 21:42:47 +03:00
|
|
|
{
|
|
|
|
|
setId(Constants::OPTIONS_PAGE_ID);
|
2023-01-09 18:08:30 +01:00
|
|
|
setDisplayName(Tr::tr("Cppcheck"));
|
2018-07-30 21:42:47 +03:00
|
|
|
setCategory("T.Analyzer");
|
2023-02-09 11:43:49 +01:00
|
|
|
setDisplayCategory(::Debugger::Tr::tr("Analyzer"));
|
2020-01-10 09:33:24 +01:00
|
|
|
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
2023-05-15 18:00:42 +02:00
|
|
|
setSettingsGroup("Cppcheck");
|
|
|
|
|
|
|
|
|
|
binary.setSettingsKey("binary");
|
|
|
|
|
binary.setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
binary.setCommandVersionArguments({"--version"});
|
|
|
|
|
binary.setLabelText(Tr::tr("Binary:"));
|
2021-09-30 16:58:46 +02:00
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2023-05-15 18:00:42 +02:00
|
|
|
binary.setDefaultValue("cppcheck");
|
2018-07-30 21:42:47 +03:00
|
|
|
} else {
|
2022-08-24 14:57:57 +02:00
|
|
|
FilePath programFiles = FilePath::fromUserInput(qtcEnvironmentVariable("PROGRAMFILES"));
|
2018-07-30 21:42:47 +03:00
|
|
|
if (programFiles.isEmpty())
|
|
|
|
|
programFiles = "C:/Program Files";
|
2023-05-15 18:00:42 +02:00
|
|
|
binary.setDefaultValue(programFiles.pathAppended("Cppcheck/cppcheck.exe").toString());
|
2018-07-30 21:42:47 +03:00
|
|
|
}
|
|
|
|
|
|
2023-05-15 18:00:42 +02:00
|
|
|
warning.setSettingsKey("warning");
|
|
|
|
|
warning.setDefaultValue(true);
|
|
|
|
|
warning.setLabelText(Tr::tr("Warnings"));
|
|
|
|
|
|
|
|
|
|
style.setSettingsKey("style");
|
|
|
|
|
style.setDefaultValue(true);
|
|
|
|
|
style.setLabelText(Tr::tr("Style"));
|
|
|
|
|
|
|
|
|
|
performance.setSettingsKey("performance");
|
|
|
|
|
performance.setDefaultValue(true);
|
|
|
|
|
performance.setLabelText(Tr::tr("Performance"));
|
|
|
|
|
|
|
|
|
|
portability.setSettingsKey("portability");
|
|
|
|
|
portability.setDefaultValue(true);
|
|
|
|
|
portability.setLabelText(Tr::tr("Portability"));
|
|
|
|
|
|
|
|
|
|
information.setSettingsKey("information");
|
|
|
|
|
information.setDefaultValue(true);
|
|
|
|
|
information.setLabelText(Tr::tr("Information"));
|
|
|
|
|
|
|
|
|
|
unusedFunction.setSettingsKey("unusedFunction");
|
|
|
|
|
unusedFunction.setLabelText(Tr::tr("Unused functions"));
|
|
|
|
|
unusedFunction.setToolTip(Tr::tr("Disables multithreaded check."));
|
|
|
|
|
|
|
|
|
|
missingInclude.setSettingsKey("missingInclude");
|
|
|
|
|
missingInclude.setLabelText(Tr::tr("Missing includes"));
|
|
|
|
|
|
|
|
|
|
inconclusive.setSettingsKey("inconclusive");
|
|
|
|
|
inconclusive.setLabelText(Tr::tr("Inconclusive errors"));
|
|
|
|
|
|
|
|
|
|
forceDefines.setSettingsKey("forceDefines");
|
|
|
|
|
forceDefines.setLabelText(Tr::tr("Check all define combinations"));
|
|
|
|
|
|
|
|
|
|
customArguments.setSettingsKey("customArguments");
|
|
|
|
|
customArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
customArguments.setLabelText(Tr::tr("Custom arguments:"));
|
|
|
|
|
|
|
|
|
|
ignoredPatterns.setSettingsKey("ignoredPatterns");
|
|
|
|
|
ignoredPatterns.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
ignoredPatterns.setLabelText(Tr::tr("Ignored file patterns:"));
|
|
|
|
|
ignoredPatterns.setToolTip(Tr::tr("Comma-separated wildcards of full file paths. "
|
|
|
|
|
"Files still can be checked if others include them."));
|
|
|
|
|
|
|
|
|
|
showOutput.setSettingsKey("showOutput");
|
|
|
|
|
showOutput.setLabelText(Tr::tr("Show raw output"));
|
|
|
|
|
|
|
|
|
|
addIncludePaths.setSettingsKey("addIncludePaths");
|
|
|
|
|
addIncludePaths.setLabelText(Tr::tr("Add include paths"));
|
|
|
|
|
addIncludePaths.setToolTip(Tr::tr("Can find missing includes but makes "
|
|
|
|
|
"checking slower. Use only when needed."));
|
|
|
|
|
|
|
|
|
|
guessArguments.setSettingsKey("guessArguments");
|
|
|
|
|
guessArguments.setDefaultValue(true);
|
|
|
|
|
guessArguments.setLabelText(Tr::tr("Calculate additional arguments"));
|
|
|
|
|
guessArguments.setToolTip(Tr::tr("Like C++ standard and language."));
|
|
|
|
|
|
|
|
|
|
setLayouter(layouter());
|
|
|
|
|
|
2023-05-16 13:06:18 +02:00
|
|
|
readSettings();
|
2018-07-30 21:42:47 +03:00
|
|
|
}
|
|
|
|
|
|
2023-05-31 08:47:33 +02:00
|
|
|
std::function<Layouting::LayoutItem()> CppcheckOptions::layouter()
|
2018-07-30 21:42:47 +03:00
|
|
|
{
|
2023-05-31 08:47:33 +02:00
|
|
|
return [this] {
|
2023-05-15 18:00:42 +02:00
|
|
|
using namespace Layouting;
|
2023-05-31 08:47:33 +02:00
|
|
|
return Form {
|
2023-05-15 18:00:42 +02:00
|
|
|
binary, br,
|
|
|
|
|
Tr::tr("Checks:"), Flow {
|
|
|
|
|
warning,
|
|
|
|
|
style,
|
|
|
|
|
performance,
|
|
|
|
|
portability,
|
|
|
|
|
information,
|
|
|
|
|
unusedFunction,
|
|
|
|
|
missingInclude
|
|
|
|
|
}, br,
|
|
|
|
|
customArguments, br,
|
|
|
|
|
ignoredPatterns, br,
|
|
|
|
|
Flow {
|
|
|
|
|
inconclusive,
|
|
|
|
|
forceDefines,
|
|
|
|
|
showOutput,
|
|
|
|
|
addIncludePaths,
|
|
|
|
|
guessArguments
|
|
|
|
|
}
|
2023-05-31 08:47:33 +02:00
|
|
|
};
|
2023-05-15 18:00:42 +02:00
|
|
|
};
|
2018-07-30 21:42:47 +03:00
|
|
|
}
|
|
|
|
|
|
2023-01-09 18:08:30 +01:00
|
|
|
} // Cppcheck::Internal
|