36 #include <system_error>
43 :
Executor(files, fileSettings, settings, suppressions, errorLogger)
44 , mExecuteCommand(std::move(executeCommand))
70 void reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal) {
107 fs = &(*mItNextFileSettings);
123 result = fileChecker.
check(*fs);
128 result = fileChecker.
check(*file);
135 std::lock_guard<std::mutex> l(
mFileSync);
143 const std::list<FileWithDetails> &
mFiles;
163 unsigned int result = 0;
165 const std::string *file;
167 std::size_t fileSize;
169 while (data->
next(file, fs, fileSize)) {
180 std::vector<std::future<unsigned int>> threadFutures;
187 threadFutures.emplace_back(std::async(std::launch::async, &
threadProc, &data));
189 catch (
const std::system_error &e) {
190 std::cerr <<
"#### ThreadExecutor::check exception :" << e.what() << std::endl;
195 unsigned int result = std::accumulate(threadFutures.begin(), threadFutures.end(), 0U, [](
unsigned int v, std::future<unsigned int>& f) {
This is the base class which will use other classes to do static code analysis for C and C++ code to ...
static void printTimerResults(SHOWTIME_MODES mode)
Settings & settings()
Get reference to current settings.
std::function< int(std::string, std::vector< std::string >, std::string, std::string &)> ExecuteCmdFn
unsigned int check(const std::string &path)
This starts the actual checking.
void analyseClangTidy(const FileSettings &fileSettings)
Analyze all files using clang-tidy.
This is an interface, which the class responsible of error logging should implement.
virtual void reportErr(const ErrorMessage &msg)=0
Information about found errors and warnings is directed here.
virtual void reportOut(const std::string &outmsg, Color c=Color::Reset)=0
Information about progress is directed here.
Wrapper for error messages, provided by reportErr()
This class will take a list of filenames and settings and check then all files using threads.
bool hasToLog(const ErrorMessage &msg)
Check if message is being suppressed and unique.
const std::list< FileSettings > & mFileSettings
const std::list< FileWithDetails > & mFiles
void reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal)
Information about how many files have been checked.
ErrorLogger & mErrorLogger
const Settings & mSettings
This is just a container for general settings so that we don't need to pass individual values to func...
bool quiet
Is –quiet given?
bool clangTidy
Use clang-tidy.
unsigned int jobs
How many processes/threads should do checking at the same time.
SHOWTIME_MODES showtime
show timing information (–showtime=file|summary|top5)
class for handling suppressions
void reportStatus(std::size_t fileindex, std::size_t filecount, std::size_t sizedone, std::size_t sizetotal)
ErrorLogger & mErrorLogger
void reportOut(const std::string &outmsg, Color c) override
Information about progress is directed here.
void reportErr(const ErrorMessage &msg) override
Information about found errors and warnings is directed here.
SyncLogForwarder(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger)
ThreadExecutor & mThreadExecutor
std::size_t mProcessedSize
std::size_t mTotalFileSize
unsigned int check(ErrorLogger &errorLogger, const std::string *file, const FileSettings *fs) const
ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::list< FileWithDetails > &files, const std::list< FileSettings > &fileSettings, CppCheck::ExecuteCmdFn executeCommand)
bool next(const std::string *&file, const FileSettings *&fs, std::size_t &fileSize)
std::size_t mProcessedFiles
SyncLogForwarder logForwarder
const std::list< FileWithDetails > & mFiles
const std::list< FileSettings > & mFileSettings
CppCheck::ExecuteCmdFn mExecuteCommand
std::list< FileSettings >::const_iterator mItNextFileSettings
const Settings & mSettings
void status(std::size_t fileSize)
std::list< FileWithDetails >::const_iterator mItNextFile
This class will take a list of filenames and settings and check then all files using threads.
unsigned int check() override
CppCheck::ExecuteCmdFn mExecuteCommand
ThreadExecutor(const std::list< FileWithDetails > &files, const std::list< FileSettings > &fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
static unsigned int STDCALL threadProc(ThreadData *data)