removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()` (#4967)
* made `CppCheck::getErrorMessages()` static * removed `CppCheck` dependency from `CppCheckExecutor::parseFromArgs()`
This commit is contained in:
parent
e575a84c8a
commit
9ad26f51e8
|
@ -78,9 +78,8 @@ CppCheckExecutor::~CppCheckExecutor()
|
||||||
delete mErrorOutput;
|
delete mErrorOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
|
bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
Settings& settings = cppcheck->settings();
|
|
||||||
CmdLineParser parser(settings);
|
CmdLineParser parser(settings);
|
||||||
const bool success = parser.parseFromArgs(argc, argv);
|
const bool success = parser.parseFromArgs(argc, argv);
|
||||||
|
|
||||||
|
@ -101,7 +100,7 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
|
||||||
if (parser.getShowErrorMessages()) {
|
if (parser.getShowErrorMessages()) {
|
||||||
mShowAllErrors = true;
|
mShowAllErrors = true;
|
||||||
std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName);
|
std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName);
|
||||||
cppcheck->getErrorMessages();
|
CppCheck::getErrorMessages(*this);
|
||||||
std::cout << ErrorMessage::getXMLFooter() << std::endl;
|
std::cout << ErrorMessage::getXMLFooter() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,23 +198,20 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
CheckUnusedFunctions::clear();
|
CheckUnusedFunctions::clear();
|
||||||
|
|
||||||
CppCheck cppCheck(*this, true, executeCommand);
|
Settings settings;
|
||||||
|
if (!parseFromArgs(settings, argc, argv)) {
|
||||||
const Settings& settings = cppCheck.settings();
|
|
||||||
mSettings = &settings;
|
|
||||||
|
|
||||||
if (!parseFromArgs(&cppCheck, argc, argv)) {
|
|
||||||
mSettings = nullptr;
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (Settings::terminated()) {
|
if (Settings::terminated()) {
|
||||||
mSettings = nullptr;
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
CppCheck cppCheck(*this, true, executeCommand);
|
||||||
|
cppCheck.settings() = settings;
|
||||||
|
mSettings = &settings;
|
||||||
|
|
||||||
if (cppCheck.settings().exceptionHandling)
|
int ret;
|
||||||
|
if (settings.exceptionHandling)
|
||||||
ret = check_wrapper(cppCheck);
|
ret = check_wrapper(cppCheck);
|
||||||
else
|
else
|
||||||
ret = check_internal(cppCheck);
|
ret = check_internal(cppCheck);
|
||||||
|
|
|
@ -115,12 +115,12 @@ protected:
|
||||||
* @brief Parse command line args and get settings and file lists
|
* @brief Parse command line args and get settings and file lists
|
||||||
* from there.
|
* from there.
|
||||||
*
|
*
|
||||||
* @param cppcheck cppcheck instance
|
* @param settings the settings to store into
|
||||||
* @param argc argc from main()
|
* @param argc argc from main()
|
||||||
* @param argv argv from main()
|
* @param argv argv from main()
|
||||||
* @return false when errors are found in the input
|
* @return false when errors are found in the input
|
||||||
*/
|
*/
|
||||||
bool parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[]);
|
bool parseFromArgs(Settings &settings, int argc, const char* const argv[]);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,7 @@ NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
|
||||||
};
|
};
|
||||||
|
|
||||||
QErrorLogger errorLogger;
|
QErrorLogger errorLogger;
|
||||||
CppCheck cppcheck(errorLogger, false, nullptr);
|
CppCheck::getErrorMessages(errorLogger);
|
||||||
cppcheck.getErrorMessages();
|
|
||||||
errorLogger.errorIds.sort();
|
errorLogger.errorIds.sort();
|
||||||
|
|
||||||
mUI->mComboErrorId->addItems(errorLogger.errorIds);
|
mUI->mComboErrorId->addItems(errorLogger.errorIds);
|
||||||
|
|
|
@ -1649,25 +1649,26 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c
|
||||||
mErrorLogger.reportProgress(filename, stage, value);
|
mErrorLogger.reportProgress(filename, stage, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCheck::getErrorMessages()
|
void CppCheck::getErrorMessages(ErrorLogger &errorlogger)
|
||||||
{
|
{
|
||||||
Settings s(mSettings);
|
Settings s;
|
||||||
s.severity.enable(Severity::warning);
|
s.severity.enable(Severity::warning);
|
||||||
s.severity.enable(Severity::style);
|
s.severity.enable(Severity::style);
|
||||||
s.severity.enable(Severity::portability);
|
s.severity.enable(Severity::portability);
|
||||||
s.severity.enable(Severity::performance);
|
s.severity.enable(Severity::performance);
|
||||||
s.severity.enable(Severity::information);
|
s.severity.enable(Severity::information);
|
||||||
|
|
||||||
purgedConfigurationMessage(emptyString,emptyString);
|
CppCheck cppcheck(errorlogger, true, nullptr);
|
||||||
|
cppcheck.purgedConfigurationMessage(emptyString,emptyString);
|
||||||
mTooManyConfigs = true;
|
cppcheck.mTooManyConfigs = true;
|
||||||
tooManyConfigsError(emptyString,0U);
|
cppcheck.tooManyConfigsError(emptyString,0U);
|
||||||
|
// TODO: add functions to get remaining error messages
|
||||||
|
|
||||||
// call all "getErrorMessages" in all registered Check classes
|
// call all "getErrorMessages" in all registered Check classes
|
||||||
for (std::list<Check *>::const_iterator it = Check::instances().cbegin(); it != Check::instances().cend(); ++it)
|
for (std::list<Check *>::const_iterator it = Check::instances().cbegin(); it != Check::instances().cend(); ++it)
|
||||||
(*it)->getErrorMessages(this, &s);
|
(*it)->getErrorMessages(&errorlogger, &s);
|
||||||
|
|
||||||
Preprocessor::getErrorMessages(this, &s);
|
Preprocessor::getErrorMessages(&errorlogger, &s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
|
void CppCheck::analyseClangTidy(const ImportProject::FileSettings &fileSettings)
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
* @brief Call all "getErrorMessages" in all registered Check classes.
|
* @brief Call all "getErrorMessages" in all registered Check classes.
|
||||||
* Also print out XML header and footer.
|
* Also print out XML header and footer.
|
||||||
*/
|
*/
|
||||||
void getErrorMessages();
|
static void getErrorMessages(ErrorLogger &errorlogger);
|
||||||
|
|
||||||
void tooManyConfigsError(const std::string &file, const int numberOfConfigurations);
|
void tooManyConfigsError(const std::string &file, const int numberOfConfigurations);
|
||||||
void purgedConfigurationMessage(const std::string &file, const std::string& configuration);
|
void purgedConfigurationMessage(const std::string &file, const std::string& configuration);
|
||||||
|
|
|
@ -75,8 +75,7 @@ private:
|
||||||
|
|
||||||
void getErrorMessages() const {
|
void getErrorMessages() const {
|
||||||
ErrorLogger2 errorLogger;
|
ErrorLogger2 errorLogger;
|
||||||
CppCheck cppCheck(errorLogger, true, nullptr);
|
CppCheck::getErrorMessages(errorLogger);
|
||||||
cppCheck.getErrorMessages();
|
|
||||||
ASSERT(!errorLogger.id.empty());
|
ASSERT(!errorLogger.id.empty());
|
||||||
|
|
||||||
// Check if there are duplicate error ids in errorLogger.id
|
// Check if there are duplicate error ids in errorLogger.id
|
||||||
|
|
Loading…
Reference in New Issue