From 92b867dd2c890b4ffef5d013ba713b0d139b51c5 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sat, 25 Jul 2015 17:39:44 +0200 Subject: [PATCH] Fixed behaviour of --quiet/-q and its description --- cli/cmdlineparser.cpp | 4 ++-- cli/cppcheckexecutor.cpp | 10 ++++------ cli/threadexecutor.cpp | 4 ++-- lib/cppcheck.cpp | 4 ++-- lib/settings.cpp | 2 +- lib/settings.h | 2 +- test/testcmdlineparser.cpp | 8 ++++---- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index a3b0ccb71..dd750199e 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -331,7 +331,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[]) // Only print something when there are errors else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0) - _settings->_errorsOnly = true; + _settings->quiet = true; // Append userdefined code to checked source code else if (std::strncmp(argv[i], "--append=", 9) == 0) { @@ -947,7 +947,7 @@ void CmdLineParser::PrintHelp() " * native\n" " Unspecified platform. Type sizes of host system\n" " are assumed, but no further assumptions.\n" - " -q, --quiet Only print error messages.\n" + " -q, --quiet Do not show progress reports.\n" " -rp, --relative-paths\n" " -rp=, --relative-paths=\n" " Use relative paths in output. When given, are\n" diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 9cf698530..7af5102c5 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -115,10 +115,8 @@ bool CppCheckExecutor::parseFromArgs(CppCheck *cppcheck, int argc, const char* c if (FileLister::isDirectory(path)) ++iter; else { - // If the include path is not found, warn user (unless --quiet - // was used) and remove the non-existing path from the list. - if (!settings._errorsOnly) - std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl; + // If the include path is not found, warn user and remove the non-existing path from the list. + std::cout << "cppcheck: warning: Couldn't find path given by -I '" << path << '\'' << std::endl; iter = settings._includePaths.erase(iter); } } @@ -790,7 +788,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha || !_settings->library.processMarkupAfterCode(i->first)) { returnValue += cppcheck.check(i->first); processedsize += i->second; - if (!settings._errorsOnly) + if (!settings.quiet) reportStatus(c + 1, _files.size(), processedsize, totalfilesize); c++; } @@ -802,7 +800,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha if (_settings->library.markupFile(i->first) && _settings->library.processMarkupAfterCode(i->first)) { returnValue += cppcheck.check(i->first); processedsize += i->second; - if (!settings._errorsOnly) + if (!settings.quiet) reportStatus(c + 1, _files.size(), processedsize, totalfilesize); c++; } diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 832643d81..45e30bfb8 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -259,7 +259,7 @@ unsigned int ThreadExecutor::check() _fileCount++; processedsize += size; - if (!_settings._errorsOnly) + if (!_settings.quiet) CppCheckExecutor::reportStatus(_fileCount, _files.size(), processedsize, totalfilesize); close(*rp); @@ -447,7 +447,7 @@ unsigned int __stdcall ThreadExecutor::threadProc(void *args) threadExecutor->_processedSize += fileSize; threadExecutor->_processedFiles++; - if (!threadExecutor->_settings._errorsOnly) { + if (!threadExecutor->_settings.quiet) { EnterCriticalSection(&threadExecutor->_reportSync); CppCheckExecutor::reportStatus(threadExecutor->_processedFiles, threadExecutor->_totalFiles, threadExecutor->_processedSize, threadExecutor->_totalFileSize); LeaveCriticalSection(&threadExecutor->_reportSync); diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index ab2639971..9353cde79 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -146,7 +146,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi if (_settings.terminated()) return exitcode; - if (_settings._errorsOnly == false) { + if (_settings.quiet == false) { std::string fixedpath = Path::simplifyPath(filename); fixedpath = Path::toNativeSeparators(fixedpath); _errorLogger.reportOut(std::string("Checking ") + fixedpath + std::string("...")); @@ -213,7 +213,7 @@ unsigned int CppCheck::processFile(const std::string& filename, std::istream& fi cfg = *it; // If only errors are printed, print filename after the check - if (_settings._errorsOnly == false && it != configurations.begin()) { + if (_settings.quiet == false && it != configurations.begin()) { std::string fixedpath = Path::simplifyPath(filename); fixedpath = Path::toNativeSeparators(fixedpath); _errorLogger.reportOut("Checking " + fixedpath + ": " + cfg + "..."); diff --git a/lib/settings.cpp b/lib/settings.cpp index 5675c02cd..e728685a9 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -34,7 +34,7 @@ Settings::Settings() inconclusive(false), jointSuppressionReport(false), experimental(false), - _errorsOnly(false), + quiet(false), _inlineSuppressions(false), _verbose(false), _force(false), diff --git a/lib/settings.h b/lib/settings.h index 9d47e58e7..214d62244 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -86,7 +86,7 @@ public: bool experimental; /** @brief Is --quiet given? */ - bool _errorsOnly; + bool quiet; /** @brief Is --inline-suppr given? */ bool _inlineSuppressions; diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index 61630d3e9..2c5d0bead 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -287,17 +287,17 @@ private: void quietshort() { REDIRECT; const char *argv[] = {"cppcheck", "-q", "file.cpp"}; - settings._errorsOnly = false; + settings.quiet = false; ASSERT(defParser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(true, settings._errorsOnly); + ASSERT_EQUALS(true, settings.quiet); } void quietlong() { REDIRECT; const char *argv[] = {"cppcheck", "--quiet", "file.cpp"}; - settings._errorsOnly = false; + settings.quiet = false; ASSERT(defParser.ParseFromArgs(3, argv)); - ASSERT_EQUALS(true, settings._errorsOnly); + ASSERT_EQUALS(true, settings.quiet); } void defines_noarg() {