Skip to content

Commit

Permalink
renamed PathWithDetails to FileWithDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Apr 16, 2024
1 parent 51721b8 commit 56145a6
Show file tree
Hide file tree
Showing 27 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
}

if (!pathnamesRef.empty()) {
std::list<PathWithDetails> filesResolved;
std::list<FileWithDetails> filesResolved;
// TODO: this needs to be inlined into PathMatch as it depends on the underlying filesystem
#if defined(_WIN32)
// For Windows we want case-insensitive path matching
Expand Down Expand Up @@ -273,7 +273,7 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
}
}

std::list<PathWithDetails> files;
std::list<FileWithDetails> files;
if (!mSettings.fileFilters.empty()) {
std::copy_if(filesResolved.cbegin(), filesResolved.cend(), std::inserter(files, files.end()), [&](const decltype(filesResolved)::value_type& entry) {
return matchglobs(mSettings.fileFilters, entry.path());
Expand Down
4 changes: 2 additions & 2 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CmdLineParser {
/**
* Return the files user gave to command line.
*/
const std::list<PathWithDetails>& getFiles() const {
const std::list<FileWithDetails>& getFiles() const {
return mFiles;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ class CmdLineParser {
CmdLineLogger &mLogger;

std::vector<std::string> mPathNames;
std::list<PathWithDetails> mFiles;
std::list<FileWithDetails> mFiles;
std::list<FileSettings> mFileSettings;
std::vector<std::string> mIgnoredPaths;
Settings &mSettings;
Expand Down
6 changes: 3 additions & 3 deletions cli/cppcheckexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ int CppCheckExecutor::check_wrapper(const Settings& settings)
return check_internal(settings);
}

bool CppCheckExecutor::reportSuppressions(const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
bool CppCheckExecutor::reportSuppressions(const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger) {
const auto& suppr = suppressions.getSuppressions();
if (std::any_of(suppr.begin(), suppr.end(), [](const SuppressionList::Suppression& s) {
return s.errorId == "unmatchedSuppression" && s.fileName.empty() && s.lineNumber == SuppressionList::Suppression::NO_LINE;
Expand All @@ -230,7 +230,7 @@ bool CppCheckExecutor::reportSuppressions(const Settings &settings, const Suppre
// the two inputs may only be used exclusively
assert(!(!files.empty() && !fileSettings.empty()));

for (std::list<PathWithDetails>::const_iterator i = files.cbegin(); i != files.cend(); ++i) {
for (std::list<FileWithDetails>::const_iterator i = files.cbegin(); i != files.cend(); ++i) {
err |= SuppressionList::reportUnmatchedSuppressions(
suppressions.getUnmatchedLocalSuppressions(i->path(), unusedFunctionCheckEnabled), errorLogger);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ int CppCheckExecutor::check_internal(const Settings& settings) const

if (!settings.buildDir.empty()) {
std::list<std::string> fileNames;
for (std::list<PathWithDetails>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i)
for (std::list<FileWithDetails>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i)
fileNames.emplace_back(i->path());
AnalyzerInformation::writeFilesTxt(settings.buildDir, fileNames, settings.userDefines, mFileSettings);
}
Expand Down
6 changes: 3 additions & 3 deletions cli/cppcheckexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class Settings;
class ErrorLogger;
class SuppressionList;
class PathWithDetails;
class FileWithDetails;

/**
* This class works as an example of how CppCheck can be used in external
Expand Down Expand Up @@ -82,7 +82,7 @@ class CppCheckExecutor {

protected:

static bool reportSuppressions(const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger);
static bool reportSuppressions(const Settings &settings, const SuppressionList& suppressions, bool unusedFunctionCheckEnabled, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, ErrorLogger& errorLogger);

/**
* Wrapper around check_internal
Expand All @@ -107,7 +107,7 @@ class CppCheckExecutor {
/**
* Filename associated with size of file
*/
std::list<PathWithDetails> mFiles;
std::list<FileWithDetails> mFiles;

std::list<FileSettings> mFileSettings;

Expand Down
2 changes: 1 addition & 1 deletion cli/executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

struct FileSettings;

Executor::Executor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger)
Executor::Executor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger)
: mFiles(files), mFileSettings(fileSettings), mSettings(settings), mSuppressions(suppressions), mErrorLogger(errorLogger)
{
// the two inputs may only be used exclusively
Expand Down
6 changes: 3 additions & 3 deletions cli/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ErrorLogger;
class ErrorMessage;
class SuppressionList;
struct FileSettings;
class PathWithDetails;
class FileWithDetails;

/// @addtogroup CLI
/// @{
Expand All @@ -42,7 +42,7 @@ class PathWithDetails;
*/
class Executor {
public:
Executor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger);
Executor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger);
virtual ~Executor() = default;

Executor(const Executor &) = delete;
Expand All @@ -68,7 +68,7 @@ class Executor {
*/
bool hasToLog(const ErrorMessage &msg);

const std::list<PathWithDetails> &mFiles;
const std::list<FileWithDetails> &mFiles;
const std::list<FileSettings>& mFileSettings;
const Settings &mSettings;
SuppressionList &mSuppressions;
Expand Down
14 changes: 7 additions & 7 deletions cli/filelister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
// When compiling Unicode targets WinAPI automatically uses *W Unicode versions
// of called functions. Thus, we explicitly call *A versions of the functions.

std::string FileLister::recursiveAddFiles(std::list<PathWithDetails>&files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored)
std::string FileLister::recursiveAddFiles(std::list<FileWithDetails>&files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored)
{
return addFiles(files, path, extra, true, ignored);
}

std::string FileLister::addFiles(std::list<PathWithDetails>&files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored)
std::string FileLister::addFiles(std::list<FileWithDetails>&files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored)
{
if (path.empty())
return "no path specified";
Expand Down Expand Up @@ -123,7 +123,7 @@ std::string FileLister::addFiles(std::list<PathWithDetails>&files, const std::st
// Directory
if (recursive) {
if (!ignored.match(fname)) {
std::list<PathWithDetails> filesSorted;
std::list<FileWithDetails> filesSorted;

std::string err = FileLister::recursiveAddFiles(filesSorted, fname, extra, ignored);
if (!err.empty())
Expand Down Expand Up @@ -166,7 +166,7 @@ std::string FileLister::addFiles(std::list<PathWithDetails>&files, const std::st
#include <sys/stat.h>
#include <cerrno>

static std::string addFiles2(std::list<PathWithDetails> &files,
static std::string addFiles2(std::list<FileWithDetails> &files,
const std::string &path,
const std::set<std::string> &extra,
bool recursive,
Expand All @@ -189,7 +189,7 @@ static std::string addFiles2(std::list<PathWithDetails> &files,
std::string new_path = path;
new_path += '/';

std::list<PathWithDetails> filesSorted;
std::list<FileWithDetails> filesSorted;

while (const dirent* dir_result = readdir(dir)) {
if ((std::strcmp(dir_result->d_name, ".") == 0) ||
Expand Down Expand Up @@ -236,12 +236,12 @@ static std::string addFiles2(std::list<PathWithDetails> &files,
return "";
}

std::string FileLister::recursiveAddFiles(std::list<PathWithDetails> &files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored)
std::string FileLister::recursiveAddFiles(std::list<FileWithDetails> &files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored)
{
return addFiles(files, path, extra, true, ignored);
}

std::string FileLister::addFiles(std::list<PathWithDetails> &files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored)
std::string FileLister::addFiles(std::list<FileWithDetails> &files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored)
{
if (path.empty())
return "no path specified";
Expand Down
8 changes: 4 additions & 4 deletions cli/filelister.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <utility>

class PathMatch;
class PathWithDetails;
class FileWithDetails;

/// @addtogroup CLI
/// @{
Expand All @@ -44,7 +44,7 @@ class FileLister {
* @param ignored ignored paths
* @return On success, an empty string is returned. On error, a error message is returned.
*/
static std::string recursiveAddFiles(std::list<PathWithDetails> &files, const std::string &path, const PathMatch& ignored) {
static std::string recursiveAddFiles(std::list<FileWithDetails> &files, const std::string &path, const PathMatch& ignored) {
const std::set<std::string> extra;
return recursiveAddFiles(files, path, extra, ignored);
}
Expand All @@ -60,7 +60,7 @@ class FileLister {
* @param ignored ignored paths
* @return On success, an empty string is returned. On error, a error message is returned.
*/
static std::string recursiveAddFiles(std::list<PathWithDetails> &files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored);
static std::string recursiveAddFiles(std::list<FileWithDetails> &files, const std::string &path, const std::set<std::string> &extra, const PathMatch& ignored);

/**
* @brief (Recursively) add source files to a map.
Expand All @@ -74,7 +74,7 @@ class FileLister {
* @param ignored ignored paths
* @return On success, an empty string is returned. On error, a error message is returned.
*/
static std::string addFiles(std::list<PathWithDetails> &files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored);
static std::string addFiles(std::list<FileWithDetails> &files, const std::string &path, const std::set<std::string> &extra, bool recursive, const PathMatch& ignored);
};

/// @}
Expand Down
8 changes: 4 additions & 4 deletions cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum class Color;
using std::memset;


ProcessExecutor::ProcessExecutor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
ProcessExecutor::ProcessExecutor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
: Executor(files, fileSettings, settings, suppressions, errorLogger)
, mExecuteCommand(std::move(executeCommand))
{
Expand Down Expand Up @@ -233,15 +233,15 @@ unsigned int ProcessExecutor::check()
unsigned int fileCount = 0;
unsigned int result = 0;

const std::size_t totalfilesize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const PathWithDetails& p) {
const std::size_t totalfilesize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const FileWithDetails& p) {
return v + p.size();
});

std::list<int> rpipes;
std::map<pid_t, std::string> childFile;
std::map<int, std::string> pipeFile;
std::size_t processedsize = 0;
std::list<PathWithDetails>::const_iterator iFile = mFiles.cbegin();
std::list<FileWithDetails>::const_iterator iFile = mFiles.cbegin();
std::list<FileSettings>::const_iterator iFileSettings = mFileSettings.cbegin();
for (;;) {
// Start a new child
Expand Down Expand Up @@ -330,7 +330,7 @@ unsigned int ProcessExecutor::check()
std::size_t size = 0;
if (p != pipeFile.end()) {
pipeFile.erase(p);
const auto fs = std::find_if(mFiles.cbegin(), mFiles.cend(), [&name](const PathWithDetails& entry) {
const auto fs = std::find_if(mFiles.cbegin(), mFiles.cend(), [&name](const FileWithDetails& entry) {
return entry.path() == name;
});
if (fs != mFiles.end()) {
Expand Down
4 changes: 2 additions & 2 deletions cli/processexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Settings;
class ErrorLogger;
class SuppressionList;
struct FileSettings;
class PathWithDetails;
class FileWithDetails;

/// @addtogroup CLI
/// @{
Expand All @@ -42,7 +42,7 @@ class PathWithDetails;
*/
class ProcessExecutor : public Executor {
public:
ProcessExecutor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand);
ProcessExecutor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand);
ProcessExecutor(const ProcessExecutor &) = delete;
ProcessExecutor& operator=(const ProcessExecutor &) = delete;

Expand Down
6 changes: 3 additions & 3 deletions cli/singleexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class ErrorLogger;

SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger)
SingleExecutor::SingleExecutor(CppCheck &cppcheck, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger)
: Executor(files, fileSettings, settings, suppressions, errorLogger)
, mCppcheck(cppcheck)
{
Expand All @@ -42,14 +42,14 @@ unsigned int SingleExecutor::check()
{
unsigned int result = 0;

const std::size_t totalfilesize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const PathWithDetails& f) {
const std::size_t totalfilesize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const FileWithDetails& f) {
return v + f.size();
});

std::size_t processedsize = 0;
unsigned int c = 0;

for (std::list<PathWithDetails>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i) {
for (std::list<FileWithDetails>::const_iterator i = mFiles.cbegin(); i != mFiles.cend(); ++i) {
result += mCppcheck.check(i->path());
processedsize += i->size();
++c;
Expand Down
4 changes: 2 additions & 2 deletions cli/singleexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ class Settings;
class CppCheck;
class SuppressionList;
struct FileSettings;
class PathWithDetails;
class FileWithDetails;

class SingleExecutor : public Executor
{
public:
SingleExecutor(CppCheck &cppcheck, const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger);
SingleExecutor(CppCheck &cppcheck, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger);
SingleExecutor(const SingleExecutor &) = delete;
SingleExecutor& operator=(const SingleExecutor &) = delete;

Expand Down
10 changes: 5 additions & 5 deletions cli/threadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

enum class Color;

ThreadExecutor::ThreadExecutor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
ThreadExecutor::ThreadExecutor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand)
: Executor(files, fileSettings, settings, suppressions, errorLogger)
, mExecuteCommand(std::move(executeCommand))
{
Expand Down Expand Up @@ -81,14 +81,14 @@ class SyncLogForwarder : public ErrorLogger
class ThreadData
{
public:
ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::list<PathWithDetails> &files, const std::list<FileSettings> &fileSettings, CppCheck::ExecuteCmdFn executeCommand)
ThreadData(ThreadExecutor &threadExecutor, ErrorLogger &errorLogger, const Settings &settings, const std::list<FileWithDetails> &files, const std::list<FileSettings> &fileSettings, CppCheck::ExecuteCmdFn executeCommand)
: mFiles(files), mFileSettings(fileSettings), mSettings(settings), mExecuteCommand(std::move(executeCommand)), logForwarder(threadExecutor, errorLogger)
{
mItNextFile = mFiles.begin();
mItNextFileSettings = mFileSettings.begin();

mTotalFiles = mFiles.size() + mFileSettings.size();
mTotalFileSize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const PathWithDetails& p) {
mTotalFileSize = std::accumulate(mFiles.cbegin(), mFiles.cend(), std::size_t(0), [](std::size_t v, const FileWithDetails& p) {
return v + p.size();
});
}
Expand Down Expand Up @@ -140,8 +140,8 @@ class ThreadData
}

private:
const std::list<PathWithDetails> &mFiles;
std::list<PathWithDetails>::const_iterator mItNextFile;
const std::list<FileWithDetails> &mFiles;
std::list<FileWithDetails>::const_iterator mItNextFile;
const std::list<FileSettings> &mFileSettings;
std::list<FileSettings>::const_iterator mItNextFileSettings;

Expand Down
4 changes: 2 additions & 2 deletions cli/threadexecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Settings;
class ErrorLogger;
class SuppressionList;
struct FileSettings;
class PathWithDetails;
class FileWithDetails;

/// @addtogroup CLI
/// @{
Expand All @@ -44,7 +44,7 @@ class ThreadExecutor : public Executor {
friend class SyncLogForwarder;

public:
ThreadExecutor(const std::list<PathWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand);
ThreadExecutor(const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const Settings &settings, SuppressionList &suppressions, ErrorLogger &errorLogger, CppCheck::ExecuteCmdFn executeCommand);
ThreadExecutor(const ThreadExecutor &) = delete;
ThreadExecutor& operator=(const ThreadExecutor &) = delete;

Expand Down
4 changes: 2 additions & 2 deletions gui/checkthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ void CheckThread::run()
if (!mFiles.isEmpty() || mAnalyseWholeProgram) {
mAnalyseWholeProgram = false;
qDebug() << "Whole program analysis";
std::list<PathWithDetails> files2;
std::list<FileWithDetails> files2;
std::transform(mFiles.cbegin(), mFiles.cend(), std::back_inserter(files2), [&](const QString& file) {
return PathWithDetails{file.toStdString(), 0};
return FileWithDetails{file.toStdString(), 0};
});
mCppcheck.analyseWholeProgram(mCppcheck.settings().buildDir, files2, {});
mFiles.clear();
Expand Down
Loading

0 comments on commit 56145a6

Please sign in to comment.