Refactoring information messages.
Currently the information severity messages are outputted as error messages with Severity::Information. This causes constant confusion as people think it as mildest error severity (and rightfully so). When it was meant to be for printing messages about the checking procedure itself (like missing header files etc). So I'm adding a new function for the ErrorLogger for printing these informative messages. This makes clear the distinction of errors found from the code and messages related to the checking itself. It also makes it easier for clients to handle these separately.
This commit is contained in:
parent
14591b3211
commit
68c52ddd69
|
@ -207,7 +207,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
|
|||
"--check-config.",
|
||||
"missingInclude",
|
||||
false);
|
||||
reportErr(msg);
|
||||
reportInfo(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,6 +265,11 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
|
|||
}
|
||||
}
|
||||
|
||||
void CppCheckExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||
{
|
||||
reportOut(msg.toXML(false, _settings._xml_version));
|
||||
}
|
||||
|
||||
void CppCheckExecutor::reportStatus(size_t fileindex, size_t filecount, size_t sizedone, size_t sizetotal)
|
||||
{
|
||||
if (filecount > 1) {
|
||||
|
|
|
@ -72,6 +72,11 @@ public:
|
|||
|
||||
void reportProgress(const std::string &filename, const char stage[], const unsigned int value);
|
||||
|
||||
/**
|
||||
* Output information messages.
|
||||
*/
|
||||
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
|
||||
|
||||
/**
|
||||
* Information about how many files have been checked
|
||||
*
|
||||
|
|
|
@ -290,6 +290,11 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
|
|||
writeToPipe(REPORT_ERROR, msg.serialize());
|
||||
}
|
||||
|
||||
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||
{
|
||||
writeToPipe(REPORT_OUT, msg.serialize());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void ThreadExecutor::addFileContent(const std::string &/*path*/, const std::string &/*content*/)
|
||||
|
@ -311,4 +316,9 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &/*msg*/)
|
|||
|
||||
}
|
||||
|
||||
void ThreadExecutor::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
unsigned int check();
|
||||
virtual void reportOut(const std::string &outmsg);
|
||||
virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
|
||||
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
|
||||
|
||||
/**
|
||||
* @brief Add content to a file, to be used in unit testing.
|
||||
|
|
|
@ -209,8 +209,7 @@ unsigned int CppCheck::processFile(const std::string& filename)
|
|||
"toomanyconfigs",
|
||||
false);
|
||||
|
||||
reportErr(errmsg);
|
||||
|
||||
reportInfo(errmsg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -512,6 +511,11 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c
|
|||
_errorLogger.reportProgress(filename, stage, value);
|
||||
}
|
||||
|
||||
void CppCheck::reportInfo(const ErrorLogger::ErrorMessage &msg)
|
||||
{
|
||||
_errorLogger.reportInfo(msg);
|
||||
}
|
||||
|
||||
void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, size_t /*sizedone*/, size_t /*sizetotal*/)
|
||||
{
|
||||
|
||||
|
|
|
@ -175,6 +175,11 @@ private:
|
|||
|
||||
void reportProgress(const std::string &filename, const char stage[], const unsigned int value);
|
||||
|
||||
/**
|
||||
* Output information messages.
|
||||
*/
|
||||
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg);
|
||||
|
||||
CheckUnusedFunctions _checkUnusedFunctions;
|
||||
ErrorLogger &_errorLogger;
|
||||
|
||||
|
|
|
@ -266,8 +266,7 @@ public:
|
|||
* Information about found errors and warnings is directed
|
||||
* here. Override this to receive the errormessages.
|
||||
*
|
||||
* @param msg Location and other information about the found.
|
||||
* error
|
||||
* @param msg Location and other information about the found error.
|
||||
*/
|
||||
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;
|
||||
|
||||
|
@ -283,6 +282,12 @@ public:
|
|||
(void)value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output information messages.
|
||||
* @param msg Location and other information about the found error.
|
||||
*/
|
||||
virtual void reportInfo(const ErrorLogger::ErrorMessage &msg) = 0;
|
||||
|
||||
/**
|
||||
* Report list of unmatched suppressions
|
||||
* @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)
|
||||
|
|
|
@ -2100,7 +2100,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
|
|||
const std::string id = userheader ? "missingInclude" : "debug";
|
||||
ErrorLogger::ErrorMessage errmsg(locationList, severity, "Include file: \"" + header + "\" not found.", id, false);
|
||||
errmsg.file0 = file0;
|
||||
_errorLogger->reportErr(errmsg);
|
||||
errorLogger->reportInfo(errmsg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue