Remove ErrorLogger::reportStatus() method.

The ErrorLogger::reportStatus() is not lib code interface. The CLI
code does the looping through file list and gives one file at a
time for the core code. Hence lib has no any idea about the
progress and it can't provide such information.

Also the recent commit (6d858b6) caused a GUI build failure by
adding CLI code dependency to GUI. Which is big no-no.

This is admittedly a hack. But it allow us to build all modules
again.
This commit is contained in:
Kimmo Varis 2011-04-27 23:27:02 +03:00
parent a1e6382247
commit c7d99fe9a7
12 changed files with 22 additions and 41 deletions

View File

@ -133,7 +133,7 @@ cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)
all: cppcheck testrunner all: cppcheck testrunner
testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)
test: all test: all
./testrunner ./testrunner
@ -247,7 +247,7 @@ cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h
cli/pathmatch.o: cli/pathmatch.cpp cli/pathmatch.h cli/pathmatch.o: cli/pathmatch.cpp cli/pathmatch.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/pathmatch.o cli/pathmatch.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/pathmatch.o cli/pathmatch.cpp
cli/threadexecutor.o: cli/threadexecutor.cpp cli/threadexecutor.h lib/settings.h lib/errorlogger.h lib/cppcheck.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h cli/threadexecutor.o: cli/threadexecutor.cpp cli/cppcheckexecutor.h lib/errorlogger.h lib/settings.h cli/threadexecutor.h lib/cppcheck.h lib/checkunusedfunctions.h lib/check.h lib/token.h lib/tokenize.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/threadexecutor.o cli/threadexecutor.cpp $(CXX) $(CPPFLAGS) $(CXXFLAGS) ${INCLUDE_FOR_CLI} -c -o cli/threadexecutor.o cli/threadexecutor.cpp
test/options.o: test/options.cpp test/options.h test/options.o: test/options.cpp test/options.h

View File

@ -165,7 +165,8 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
{ {
processedsize += _filesizes[_filenames[c]]; processedsize += _filesizes[_filenames[c]];
} }
reportStatus(c + 1, _filenames.size(), processedsize, totalfilesize); if (!_settings._errorsOnly)
reportStatus(c + 1, _filenames.size(), processedsize, totalfilesize);
} }
} }
else if (!ThreadExecutor::isEnabled()) else if (!ThreadExecutor::isEnabled())
@ -234,7 +235,7 @@ void CppCheckExecutor::reportProgress(const std::string &filename, const char st
void CppCheckExecutor::reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal) void CppCheckExecutor::reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal)
{ {
if (filecount > 1 && !_settings._errorsOnly) if (filecount > 1)
{ {
std::ostringstream oss; std::ostringstream oss;
oss << fileindex << "/" << filecount oss << fileindex << "/" << filecount

View File

@ -72,7 +72,15 @@ public:
void reportProgress(const std::string &filename, const char stage[], const unsigned int value); void reportProgress(const std::string &filename, const char stage[], const unsigned int value);
virtual void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal); /**
* Information about how many files have been checked
*
* @param fileindex This many files have been checked.
* @param filecount This many files there are in total.
* @param sizedone The sum of sizes of the files checked.
* @param sizetotal The total sizes of the files.
*/
static void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal);
protected: protected:

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "cppcheckexecutor.h"
#include "threadexecutor.h" #include "threadexecutor.h"
#include "cppcheck.h" #include "cppcheck.h"
#include <iostream> #include <iostream>
@ -243,7 +244,8 @@ unsigned int ThreadExecutor::check()
_fileCount++; _fileCount++;
processedsize += size; processedsize += size;
_errorLogger.reportStatus(_fileCount, _filenames.size(), processedsize, totalfilesize); if (!_settings._errorsOnly)
CppCheckExecutor::reportStatus(_fileCount, _filenames.size(), processedsize, totalfilesize);
close(*rp); close(*rp);
rp = rpipes.erase(rp); rp = rpipes.erase(rp);
@ -323,11 +325,6 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &msg)
writeToPipe('2', msg.serialize()); writeToPipe('2', msg.serialize());
} }
void ThreadExecutor::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, long /*sizedone*/, long /*sizetotal*/)
{
// Not used
}
#else #else
unsigned int ThreadExecutor::check() unsigned int ThreadExecutor::check()
{ {
@ -343,8 +340,4 @@ void ThreadExecutor::reportErr(const ErrorLogger::ErrorMessage &/*msg*/)
} }
void ThreadExecutor::reportStatus(unsigned int /*fileindex*/, unsigned int /*filecount*/, long /*sizedone*/, long /*sizetotal*/)
{
}
#endif #endif

View File

@ -44,7 +44,7 @@ public:
unsigned int check(); unsigned int check();
virtual void reportOut(const std::string &outmsg); virtual void reportOut(const std::string &outmsg);
virtual void reportErr(const ErrorLogger::ErrorMessage &msg); virtual void reportErr(const ErrorLogger::ErrorMessage &msg);
virtual void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal);
/** /**
* @brief Add content to a file, to be used in unit testing. * @brief Add content to a file, to be used in unit testing.
* *

View File

@ -91,15 +91,6 @@ QString ThreadResult::GetNextFile()
return mFiles.takeFirst(); return mFiles.takeFirst();
} }
void ThreadResult::reportStatus(unsigned int fileindex, unsigned int filecount, FileLister::filesize_t sizedone, FileLister::filesize_t sizetotal)
{
Q_UNUSED(fileindex);
Q_UNUSED(filecount);
Q_UNUSED(sizedone);
Q_UNUSED(sizetotal);
}
void ThreadResult::SetFiles(const QStringList &files) void ThreadResult::SetFiles(const QStringList &files)
{ {
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);

View File

@ -71,7 +71,7 @@ public:
*/ */
void reportOut(const std::string &outmsg); void reportOut(const std::string &outmsg);
void reportErr(const ErrorLogger::ErrorMessage &msg); void reportErr(const ErrorLogger::ErrorMessage &msg);
void reportStatus(unsigned int fileindex, unsigned int filecount, FileLister::filesize_t sizedone, FileLister::filesize_t sizetotal);
public slots: public slots:
/** /**

View File

@ -272,16 +272,6 @@ public:
*/ */
virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0; virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;
/**
* Information about how many files have been checked
*
* @param fileindex This many files have been checked.
* @param filecount This many files there are in total.
* @param sizedone The sum of sizes of the files checked.
* @param sizetotal The total sizes of the files.
*/
virtual void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal) = 0;
/** /**
* Report progress to client * Report progress to client
* @param filename main file that is checked * @param filename main file that is checked

View File

@ -179,10 +179,6 @@ private:
if (!msg._callStack.empty() && !_settings.nomsg.isSuppressed(msg._id, msg._callStack.begin()->getfile(), msg._callStack.begin()->line)) if (!msg._callStack.empty() && !_settings.nomsg.isSuppressed(msg._id, msg._callStack.begin()->getfile(), msg._callStack.begin()->line))
_next->reportErr(msg); _next->reportErr(msg);
} }
virtual void reportStatus(unsigned int fileindex, unsigned int filecount, long sizedone, long sizetotal)
{
_next->reportStatus(fileindex, filecount, sizedone, sizetotal);
}
private: private:
Settings &_settings; Settings &_settings;
ErrorLogger *_next; ErrorLogger *_next;

View File

@ -19,6 +19,7 @@
#include "cppcheck.h" #include "cppcheck.h"
#include "settings.h" #include "settings.h"
#include "testsuite.h" #include "testsuite.h"
#include "cppcheckexecutor.h"
#include "threadexecutor.h" #include "threadexecutor.h"
#include <sstream> #include <sstream>

View File

@ -24,6 +24,7 @@
#include "cppcheck.h" #include "cppcheck.h"
#include "testsuite.h" #include "testsuite.h"
#include "threadexecutor.h" #include "threadexecutor.h"
#include "cppcheckexecutor.h"
#include <algorithm> #include <algorithm>
#include <map> #include <map>

View File

@ -289,7 +289,7 @@ int main(int argc, char **argv)
fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) $(LDFLAGS)\n\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o cppcheck $(CLIOBJ) $(LIBOBJ) $(EXTOBJ) $(LDFLAGS)\n\n";
fout << "all:\tcppcheck testrunner\n\n"; fout << "all:\tcppcheck testrunner\n\n";
fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o\n"; fout << "testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/pathmatch.o\n";
fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)\n\n"; fout << "\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cppcheckexecutor.o cli/cmdlineparser.o cli/filelister.o cli/pathmatch.o $(LDFLAGS)\n\n";
fout << "test:\tall\n"; fout << "test:\tall\n";
fout << "\t./testrunner\n\n"; fout << "\t./testrunner\n\n";
fout << "check:\tall\n"; fout << "check:\tall\n";