Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
}

// Output a warning for the user if he tries to exclude headers
const std::vector<std::string>& ignored = getIgnoredPaths();
const std::vector<std::string>& ignored = mIgnoredPaths;
const bool warn = std::any_of(ignored.cbegin(), ignored.cend(), [](const std::string& i) {
return Path::isHeader(i);
});
Expand All @@ -200,8 +200,8 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
mLogger.printMessage("Please use --suppress for ignoring results from the header files.");
}

const std::vector<std::string>& pathnamesRef = getPathNames();
const std::list<FileSettings>& fileSettingsRef = getFileSettings();
const std::vector<std::string>& pathnamesRef = mPathNames;
const std::list<FileSettings>& fileSettingsRef = mFileSettings;

// the inputs can only be used exclusively - CmdLineParser should already handle this
assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty()));
Expand Down
36 changes: 11 additions & 25 deletions cli/cmdlineparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Library;
* class internal options.
*/
class CmdLineParser {
friend class TestCmdlineParser;
public:
/**
* The constructor.
Expand Down Expand Up @@ -80,19 +79,6 @@ class CmdLineParser {
static std::list<FileWithDetails> filterFiles(const std::vector<std::string>& fileFilters,
const std::list<FileWithDetails>& filesResolved);

/**
* Parse given command line.
* @return true if command line was ok, false if there was an error.
*/
Result parseFromArgs(int argc, const char* const argv[]);

/**
* Return the path names user gave to command line.
*/
const std::vector<std::string>& getPathNames() const {
return mPathNames;
}

/**
* Return the files user gave to command line.
*/
Expand All @@ -107,26 +93,24 @@ class CmdLineParser {
return mFileSettings;
}

protected:
/**
* Return a list of paths user wants to ignore.
* Parse given command line.
* @return true if command line was ok, false if there was an error.
*/
const std::vector<std::string>& getIgnoredPaths() const {
return mIgnoredPaths;
}
Result parseFromArgs(int argc, const char* const argv[]);

/**
* Get Cppcheck version
*/
std::string getVersion() const;

protected:

private:
/**
* Print help text to the console.
*/
void printHelp() const;

private:
bool isCppcheckPremium() const;

template<typename T>
Expand Down Expand Up @@ -168,19 +152,21 @@ class CmdLineParser {

bool loadCppcheckCfg();

void outputFormatOptionMixingError() const;

CmdLineLogger &mLogger;

Settings &mSettings;
Suppressions &mSuppressions;

protected:
std::vector<std::string> mPathNames;
std::list<FileWithDetails> mFiles;
std::list<FileSettings> mFileSettings;
std::vector<std::string> mIgnoredPaths;
Settings &mSettings;
Suppressions &mSuppressions;
bool mAnalyzeAllVsConfigsSetOnCmdLine = false;
/** @brief Name of the language that is enforced. Empty per default. */
Standards::Language mEnforcedLang{Standards::Language::None};

void outputFormatOptionMixingError() const;
};

/// @}
Expand Down
Loading