Fixed behaviour of --quiet/-q and its description

This commit is contained in:
PKEuS 2015-07-25 17:39:44 +02:00
parent acc1566f64
commit 92b867dd2c
7 changed files with 16 additions and 18 deletions

View File

@ -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=<paths>, --relative-paths=<paths>\n"
" Use relative paths in output. When given, <paths> are\n"

View File

@ -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++;
}

View File

@ -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);

View File

@ -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 + "...");

View File

@ -34,7 +34,7 @@ Settings::Settings()
inconclusive(false),
jointSuppressionReport(false),
experimental(false),
_errorsOnly(false),
quiet(false),
_inlineSuppressions(false),
_verbose(false),
_force(false),

View File

@ -86,7 +86,7 @@ public:
bool experimental;
/** @brief Is --quiet given? */
bool _errorsOnly;
bool quiet;
/** @brief Is --inline-suppr given? */
bool _inlineSuppressions;

View File

@ -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() {