Skip to content

Commit 92b867d

Browse files
committed
Fixed behaviour of --quiet/-q and its description
1 parent acc1566 commit 92b867d

7 files changed

Lines changed: 16 additions & 18 deletions

File tree

cli/cmdlineparser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
331331

332332
// Only print something when there are errors
333333
else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0)
334-
_settings->_errorsOnly = true;
334+
_settings->quiet = true;
335335

336336
// Append userdefined code to checked source code
337337
else if (std::strncmp(argv[i], "--append=", 9) == 0) {
@@ -947,7 +947,7 @@ void CmdLineParser::PrintHelp()
947947
" * native\n"
948948
" Unspecified platform. Type sizes of host system\n"
949949
" are assumed, but no further assumptions.\n"
950-
" -q, --quiet Only print error messages.\n"
950+
" -q, --quiet Do not show progress reports.\n"
951951
" -rp, --relative-paths\n"
952952
" -rp=<paths>, --relative-paths=<paths>\n"
953953
" Use relative paths in output. When given, <paths> are\n"

cli/cppcheckexecutor.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c
115115
if (FileLister::isDirectory(path))
116116
++iter;
117117
else {
118-
// If the include path is not found, warn user (unless --quiet
119-
// was used) and remove the non-existing path from the list.
120-
if (!settings._errorsOnly)
121-
std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl;
118+
// If the include path is not found, warn user and remove the non-existing path from the list.
119+
std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl;
122120
iter = settings._includePaths.erase(iter);
123121
}
124122
}
@@ -790,7 +788,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
790788
|| !_settings->library.processMarkupAfterCode(i->first)) {
791789
returnValue += cppcheck.check(i->first);
792790
processedsize += i->second;
793-
if (!settings._errorsOnly)
791+
if (!settings.quiet)
794792
reportStatus(c + 1, _files.size(), processedsize, totalfilesize);
795793
c++;
796794
}
@@ -802,7 +800,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
802800
if (_settings->library.markupFile(i->first) && _settings->library.processMarkupAfterCode(i->first)) {
803801
returnValue += cppcheck.check(i->first);
804802
processedsize += i->second;
805-
if (!settings._errorsOnly)
803+
if (!settings.quiet)
806804
reportStatus(c + 1, _files.size(), processedsize, totalfilesize);
807805
c++;
808806
}

cli/threadexecutor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ unsigned int ThreadExecutor::check()
259259

260260
_fileCount++;
261261
processedsize += size;
262-
if (!_settings._errorsOnly)
262+
if (!_settings.quiet)
263263
CppCheckExecutor::reportStatus(_fileCount, _files.size(), processedsize, totalfilesize);
264264

265265
close(*rp);
@@ -447,7 +447,7 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args)
447447

448448
threadExecutor->_processedSize += fileSize;
449449
threadExecutor->_processedFiles++;
450-
if (!threadExecutor->_settings._errorsOnly) {
450+
if (!threadExecutor->_settings.quiet) {
451451
EnterCriticalSection(&threadExecutor->_reportSync);
452452
CppCheckExecutor::reportStatus(threadExecutor->_processedFiles, threadExecutor->_totalFiles, threadExecutor->_processedSize, threadExecutor->_totalFileSize);
453453
LeaveCriticalSection(&threadExecutor->_reportSync);

lib/cppcheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
146146
if (_settings.terminated())
147147
return exitcode;
148148

149-
if (_settings._errorsOnly == false) {
149+
if (_settings.quiet == false) {
150150
std::string fixedpath = Path::simplifyPath(filename);
151151
fixedpath = Path::toNativeSeparators(fixedpath);
152152
_errorLogger.reportOut(std::string("Checking ") + fixedpath + std::string("..."));
@@ -213,7 +213,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi
213213
cfg = *it;
214214

215215
// If only errors are printed, print filename after the check
216-
if (_settings._errorsOnly == false && it != configurations.begin()) {
216+
if (_settings.quiet == false && it != configurations.begin()) {
217217
std::string fixedpath = Path::simplifyPath(filename);
218218
fixedpath = Path::toNativeSeparators(fixedpath);
219219
_errorLogger.reportOut("Checking " + fixedpath + ": " + cfg + "...");

lib/settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Settings::Settings()
3434
inconclusive(false),
3535
jointSuppressionReport(false),
3636
experimental(false),
37-
_errorsOnly(false),
37+
quiet(false),
3838
_inlineSuppressions(false),
3939
_verbose(false),
4040
_force(false),

lib/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class CPPCHECKLIB Settings {
8686
bool experimental;
8787

8888
/** @brief Is --quiet given? */
89-
bool _errorsOnly;
89+
bool quiet;
9090

9191
/** @brief Is --inline-suppr given? */
9292
bool _inlineSuppressions;

test/testcmdlineparser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,17 @@ class TestCmdlineParser : public TestFixture {
287287
void quietshort() {
288288
REDIRECT;
289289
const char *argv[] = {"cppcheck", "-q", "file.cpp"};
290-
settings._errorsOnly = false;
290+
settings.quiet = false;
291291
ASSERT(defParser.ParseFromArgs(3, argv));
292-
ASSERT_EQUALS(true, settings._errorsOnly);
292+
ASSERT_EQUALS(true, settings.quiet);
293293
}
294294

295295
void quietlong() {
296296
REDIRECT;
297297
const char *argv[] = {"cppcheck", "--quiet", "file.cpp"};
298-
settings._errorsOnly = false;
298+
settings.quiet = false;
299299
ASSERT(defParser.ParseFromArgs(3, argv));
300-
ASSERT_EQUALS(true, settings._errorsOnly);
300+
ASSERT_EQUALS(true, settings.quiet);
301301
}
302302

303303
void defines_noarg() {

0 commit comments

Comments
 (0)