removed unused `ErrorLogger::reportInfo()` / small `*Executor` cleanup (#4852)

This commit is contained in:
Oliver Stöneberg 2023-03-04 17:29:34 +01:00 committed by GitHub
parent 340baf10cd
commit ad6c5d80ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 82 deletions

View File

@ -450,11 +450,6 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
}
}
void CppCheckExecutor::reportInfo(const ErrorMessage &msg)
{
reportErr(msg);
}
void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal)
{
if (filecount > 1) {

View File

@ -81,11 +81,6 @@ public:
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
/**
* Output information messages.
*/
void reportInfo(const ErrorMessage &msg) override;
/**
* Information about how many files have been checked
*

View File

@ -68,7 +68,7 @@ ProcessExecutor::~ProcessExecutor()
class PipeWriter : public ErrorLogger {
public:
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_INFO='3', REPORT_VERIFICATION='4', CHILD_END='5'};
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_VERIFICATION='4', CHILD_END='5'};
explicit PipeWriter(int pipe) : mWpipe(pipe) {}
@ -77,11 +77,7 @@ public:
}
void reportErr(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_ERROR);
}
void reportInfo(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_INFO);
writeToPipe(REPORT_ERROR, msg.serialize());
}
void writeEnd(const std::string& str) const {
@ -89,22 +85,6 @@ public:
}
private:
enum class MessageType {REPORT_ERROR, REPORT_INFO};
void report(const ErrorMessage &msg, MessageType msgType) const {
PipeSignal pipeSignal;
switch (msgType) {
case MessageType::REPORT_ERROR:
pipeSignal = REPORT_ERROR;
break;
case MessageType::REPORT_INFO:
pipeSignal = REPORT_INFO;
break;
}
writeToPipe(pipeSignal, msg.serialize());
}
void writeToPipe(PipeSignal type, const std::string &data) const
{
unsigned int len = static_cast<unsigned int>(data.length() + 1);
@ -137,7 +117,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
return -1;
}
if (type != PipeWriter::REPORT_OUT && type != PipeWriter::REPORT_ERROR && type != PipeWriter::REPORT_INFO && type != PipeWriter::CHILD_END) {
if (type != PipeWriter::REPORT_OUT && type != PipeWriter::REPORT_ERROR && type != PipeWriter::CHILD_END) {
std::cerr << "#### ThreadExecutor::handleRead error, type was:" << type << std::endl;
std::exit(EXIT_FAILURE);
}
@ -160,7 +140,7 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
if (type == PipeWriter::REPORT_OUT) {
mErrorLogger.reportOut(buf);
} else if (type == PipeWriter::REPORT_ERROR || type == PipeWriter::REPORT_INFO) {
} else if (type == PipeWriter::REPORT_ERROR) {
ErrorMessage msg;
try {
msg.deserialize(buf);
@ -169,12 +149,8 @@ int ProcessExecutor::handleRead(int rpipe, unsigned int &result)
std::exit(EXIT_FAILURE);
}
if (hasToLog(msg)) {
if (type == PipeWriter::REPORT_ERROR)
mErrorLogger.reportErr(msg);
else
mErrorLogger.reportInfo(msg);
}
if (hasToLog(msg))
mErrorLogger.reportErr(msg);
} else if (type == PipeWriter::CHILD_END) {
std::istringstream iss(buf);
unsigned int fileResult = 0;

View File

@ -113,35 +113,16 @@ public:
}
void reportErr(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_ERROR);
}
if (!mThreadExecutor.hasToLog(msg))
return;
void reportInfo(const ErrorMessage &msg) override {
report(msg, MessageType::REPORT_INFO);
std::lock_guard<std::mutex> lg(mReportSync);
mErrorLogger.reportErr(msg);
}
std::mutex mReportSync;
private:
enum class MessageType {REPORT_ERROR, REPORT_INFO};
void report(const ErrorMessage &msg, MessageType msgType)
{
if (!mThreadExecutor.hasToLog(msg))
return;
std::lock_guard<std::mutex> lg(mReportSync);
switch (msgType) {
case MessageType::REPORT_ERROR:
mErrorLogger.reportErr(msg);
break;
case MessageType::REPORT_INFO:
mErrorLogger.reportInfo(msg);
break;
}
}
ThreadExecutor &mThreadExecutor;
ErrorLogger &mErrorLogger;
};

View File

@ -1652,12 +1652,6 @@ void CppCheck::reportProgress(const std::string &filename, const char stage[], c
mErrorLogger.reportProgress(filename, stage, value);
}
void CppCheck::reportInfo(const ErrorMessage &msg)
{
if (!mSettings.nomsg.isSuppressed(msg))
mErrorLogger.reportInfo(msg);
}
void CppCheck::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, std::size_t /*sizedone*/, std::size_t /*sizetotal*/)
{}

View File

@ -214,11 +214,6 @@ private:
void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override;
/**
* Output information messages.
*/
void reportInfo(const ErrorMessage &msg) override;
ErrorLogger &mErrorLogger;
/** @brief Current preprocessor configuration */

View File

@ -250,14 +250,6 @@ public:
(void)value;
}
/**
* Output information messages.
* @param msg Location and other information about the found error.
*/
virtual void reportInfo(const ErrorMessage &msg) {
reportErr(msg);
}
/**
* Report unmatched suppressions
* @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions)