Skip to content

Commit 5d2da7a

Browse files
committed
CmdLineParser: small interface cleanup
1 parent 84a74c1 commit 5d2da7a

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[])
191191
}
192192

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

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

206206
// the inputs can only be used exclusively - CmdLineParser should already handle this
207207
assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty()));

cli/cmdlineparser.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,6 @@ class CmdLineParser {
8080
static std::list<FileWithDetails> filterFiles(const std::vector<std::string>& fileFilters,
8181
const std::list<FileWithDetails>& filesResolved);
8282

83-
/**
84-
* Parse given command line.
85-
* @return true if command line was ok, false if there was an error.
86-
*/
87-
Result parseFromArgs(int argc, const char* const argv[]);
88-
89-
/**
90-
* Return the path names user gave to command line.
91-
*/
92-
const std::vector<std::string>& getPathNames() const {
93-
return mPathNames;
94-
}
95-
9683
/**
9784
* Return the files user gave to command line.
9885
*/
@@ -107,6 +94,14 @@ class CmdLineParser {
10794
return mFileSettings;
10895
}
10996

97+
private:
98+
/**
99+
* Return the path names user gave to command line.
100+
*/
101+
const std::vector<std::string>& getPathNames() const {
102+
return mPathNames;
103+
}
104+
110105
/**
111106
* Return a list of paths user wants to ignore.
112107
*/
@@ -119,14 +114,17 @@ class CmdLineParser {
119114
*/
120115
std::string getVersion() const;
121116

122-
protected:
123-
124117
/**
125118
* Print help text to the console.
126119
*/
127120
void printHelp() const;
128121

129-
private:
122+
/**
123+
* Parse given command line.
124+
* @return true if command line was ok, false if there was an error.
125+
*/
126+
Result parseFromArgs(int argc, const char* const argv[]);
127+
130128
bool isCppcheckPremium() const;
131129

132130
template<typename T>

0 commit comments

Comments
 (0)