Skip to content

Commit 3547499

Browse files
authored
removed need for friend declaration of test class in CmdLineParser / cleanups (#7896)
1 parent c4b988b commit 3547499

File tree

3 files changed

+98
-103
lines changed

3 files changed

+98
-103
lines changed

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: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Library;
4747
* class internal options.
4848
*/
4949
class CmdLineParser {
50-
friend class TestCmdlineParser;
5150
public:
5251
/**
5352
* The constructor.
@@ -80,19 +79,6 @@ class CmdLineParser {
8079
static std::list<FileWithDetails> filterFiles(const std::vector<std::string>& fileFilters,
8180
const std::list<FileWithDetails>& filesResolved);
8281

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-
9682
/**
9783
* Return the files user gave to command line.
9884
*/
@@ -107,26 +93,24 @@ class CmdLineParser {
10793
return mFileSettings;
10894
}
10995

96+
protected:
11097
/**
111-
* Return a list of paths user wants to ignore.
98+
* Parse given command line.
99+
* @return true if command line was ok, false if there was an error.
112100
*/
113-
const std::vector<std::string>& getIgnoredPaths() const {
114-
return mIgnoredPaths;
115-
}
101+
Result parseFromArgs(int argc, const char* const argv[]);
116102

117103
/**
118104
* Get Cppcheck version
119105
*/
120106
std::string getVersion() const;
121107

122-
protected:
123-
108+
private:
124109
/**
125110
* Print help text to the console.
126111
*/
127112
void printHelp() const;
128113

129-
private:
130114
bool isCppcheckPremium() const;
131115

132116
template<typename T>
@@ -168,19 +152,21 @@ class CmdLineParser {
168152

169153
bool loadCppcheckCfg();
170154

155+
void outputFormatOptionMixingError() const;
156+
171157
CmdLineLogger &mLogger;
172158

159+
Settings &mSettings;
160+
Suppressions &mSuppressions;
161+
162+
protected:
173163
std::vector<std::string> mPathNames;
174164
std::list<FileWithDetails> mFiles;
175165
std::list<FileSettings> mFileSettings;
176166
std::vector<std::string> mIgnoredPaths;
177-
Settings &mSettings;
178-
Suppressions &mSuppressions;
179167
bool mAnalyzeAllVsConfigsSetOnCmdLine = false;
180168
/** @brief Name of the language that is enforced. Empty per default. */
181169
Standards::Language mEnforcedLang{Standards::Language::None};
182-
183-
void outputFormatOptionMixingError() const;
184170
};
185171

186172
/// @}

0 commit comments

Comments
 (0)