Skip to content

Commit ee5e0f3

Browse files
committed
removed CppCheck dependency from CppCheckExecutor::parseFromArgs()
1 parent ad18ca2 commit ee5e0f3

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

cli/cppcheckexecutor.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ CppCheckExecutor::~CppCheckExecutor()
7878
delete mErrorOutput;
7979
}
8080

81-
bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[])
81+
bool CppCheckExecutor::parseFromArgs(Settings &settings, int argc, const char* const argv[])
8282
{
83-
Settings& settings = cppcheck->settings();
8483
CmdLineParser parser(settings);
8584
const bool success = parser.parseFromArgs(argc, argv);
8685

@@ -199,23 +198,20 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
199198
{
200199
CheckUnusedFunctions::clear();
201200

202-
CppCheck cppCheck(*this, true, executeCommand);
203-
204-
const Settings& settings = cppCheck.settings();
205-
mSettings = &settings;
206-
207-
if (!parseFromArgs(&cppCheck, argc, argv)) {
208-
mSettings = nullptr;
201+
Settings settings;
202+
if (!parseFromArgs(settings, argc, argv)) {
209203
return EXIT_FAILURE;
210204
}
211205
if (Settings::terminated()) {
212-
mSettings = nullptr;
213206
return EXIT_SUCCESS;
214207
}
215208

216-
int ret;
209+
CppCheck cppCheck(*this, true, executeCommand);
210+
cppCheck.settings() = settings;
211+
mSettings = &settings;
217212

218-
if (cppCheck.settings().exceptionHandling)
213+
int ret;
214+
if (settings.exceptionHandling)
219215
ret = check_wrapper(cppCheck);
220216
else
221217
ret = check_internal(cppCheck);

cli/cppcheckexecutor.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ class CppCheckExecutor : public ErrorLogger {
115115
* @brief Parse command line args and get settings and file lists
116116
* from there.
117117
*
118-
* @param cppcheck cppcheck instance
118+
* @param settings the settings to store into
119119
* @param argc argc from main()
120120
* @param argv argv from main()
121121
* @return false when errors are found in the input
122122
*/
123-
bool parseFromArgs(CppCheck *cppcheck, int argc, const char* const argv[]);
123+
bool parseFromArgs(Settings &settings, int argc, const char* const argv[]);
124124

125125
private:
126126

0 commit comments

Comments
 (0)