From b08e2ec1fcdc09187cf09aeacc873afb42bd4fbf Mon Sep 17 00:00:00 2001 From: firewave Date: Thu, 20 Apr 2023 01:26:52 +0200 Subject: [PATCH] removed `ErrorLogger::reportProgress()` and command-line option `--report-progress` --- cli/cmdlineparser.cpp | 6 ------ cli/cppcheckexecutor.cpp | 28 +--------------------------- cli/cppcheckexecutor.h | 7 ------- democlient/democlient.cpp | 9 +-------- lib/cppcheck.cpp | 5 ----- lib/cppcheck.h | 2 -- lib/errorlogger.h | 12 ------------ lib/settings.cpp | 1 - lib/settings.h | 3 --- lib/symboldatabase.cpp | 5 ----- lib/templatesimplifier.cpp | 4 ---- lib/tokenize.cpp | 6 ------ man/cppcheck.1.xml | 11 ----------- releasenotes.txt | 1 + test/testcmdlineparser.cpp | 10 ---------- 15 files changed, 3 insertions(+), 107 deletions(-) diff --git a/cli/cmdlineparser.cpp b/cli/cmdlineparser.cpp index 0848f483cd7..cc775ea35e8 100644 --- a/cli/cmdlineparser.cpp +++ b/cli/cmdlineparser.cpp @@ -760,11 +760,6 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[]) } } - // Report progress - else if (std::strcmp(argv[i], "--report-progress") == 0) { - mSettings.reportProgress = true; - } - #ifdef HAVE_RULES // Rule given at command line else if (std::strncmp(argv[i], "--rule=", 7) == 0) { @@ -1295,7 +1290,6 @@ void CmdLineParser::printHelp() " using e.g. ~ for home folder does not work. It is\n" " currently only possible to apply the base paths to\n" " files that are on a lower level in the directory tree.\n" - " --report-progress Report progress messages while checking a file.\n" #ifdef HAVE_RULES " --rule= Match regular expression.\n" " --rule-file= Use given rule file. For more information, see:\n" diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index cb07f3f356e..d4e69d15d62 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -70,7 +70,7 @@ /*static*/ FILE* CppCheckExecutor::mExceptionOutput = stdout; CppCheckExecutor::CppCheckExecutor() - : mSettings(nullptr), mLatestProgressOutputTime(0), mErrorOutput(nullptr), mShowAllErrors(false) + : mSettings(nullptr), mErrorOutput(nullptr), mShowAllErrors(false) {} CppCheckExecutor::~CppCheckExecutor() @@ -262,9 +262,6 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck) { Settings& settings = cppcheck.settings(); - if (settings.reportProgress) - mLatestProgressOutputTime = std::time(nullptr); - if (!settings.outputFile.empty()) { mErrorOutput = new std::ofstream(settings.outputFile); } @@ -394,29 +391,6 @@ void CppCheckExecutor::reportOut(const std::string &outmsg, Color c) std::cout << c << ansiToOEM(outmsg, true) << Color::Reset << std::endl; } -void CppCheckExecutor::reportProgress(const std::string &filename, const char stage[], const std::size_t value) -{ - (void)filename; - - if (!mLatestProgressOutputTime) - return; - - // Report progress messages every 10 seconds - const std::time_t currentTime = std::time(nullptr); - if (currentTime >= (mLatestProgressOutputTime + 10)) { - mLatestProgressOutputTime = currentTime; - - // format a progress message - std::ostringstream ostr; - ostr << "progress: " - << stage - << ' ' << value << '%'; - - // Report progress message - reportOut(ostr.str()); - } -} - void CppCheckExecutor::reportErr(const ErrorMessage &msg) { if (mShowAllErrors) { diff --git a/cli/cppcheckexecutor.h b/cli/cppcheckexecutor.h index 1e94aa58d22..7730398da58 100644 --- a/cli/cppcheckexecutor.h +++ b/cli/cppcheckexecutor.h @@ -79,8 +79,6 @@ class CppCheckExecutor : public ErrorLogger { /** xml output of errors */ void reportErr(const ErrorMessage &msg) override; - void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; - /** * @param exceptionOutput Output file */ @@ -166,11 +164,6 @@ class CppCheckExecutor : public ErrorLogger { */ std::map mFiles; - /** - * Report progress time - */ - std::time_t mLatestProgressOutputTime; - /** * Output file name for exception handler */ diff --git a/democlient/democlient.cpp b/democlient/democlient.cpp index c904ff7872f..6b8efc1ff0c 100644 --- a/democlient/democlient.cpp +++ b/democlient/democlient.cpp @@ -72,14 +72,7 @@ class CppcheckExecutor : public ErrorLogger { std::fprintf(logfile, "%s\n", s.c_str()); } - void reportProgress(const std::string& /*filename*/, - const char /*stage*/[], - const std::size_t /*value*/) override { - if (std::time(nullptr) >= stoptime) { - std::cout << "Time to analyse the code exceeded 2 seconds. Terminating.\n\n"; - Settings::terminate(); - } - } + // TODO: we want it to run a maximum amount of 2 seconds - provide a (reliable) way t o bail out }; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9be785315b0..27cd61e3a9f 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1626,11 +1626,6 @@ void CppCheck::reportOut(const std::string &outmsg, Color c) mErrorLogger.reportOut(outmsg, c); } -void CppCheck::reportProgress(const std::string &filename, const char stage[], const std::size_t value) -{ - mErrorLogger.reportProgress(filename, stage, value); -} - void CppCheck::getErrorMessages(ErrorLogger &errorlogger) { Settings s; diff --git a/lib/cppcheck.h b/lib/cppcheck.h index d9b63f02fd7..1c4ce076220 100644 --- a/lib/cppcheck.h +++ b/lib/cppcheck.h @@ -210,8 +210,6 @@ class CPPCHECKLIB CppCheck : ErrorLogger { std::list mErrorList; Settings mSettings; - void reportProgress(const std::string &filename, const char stage[], const std::size_t value) override; - ErrorLogger &mErrorLogger; /** @brief Current preprocessor configuration */ diff --git a/lib/errorlogger.h b/lib/errorlogger.h index ef8d8a71937..023d2ccfb8f 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -238,18 +238,6 @@ class CPPCHECKLIB ErrorLogger { */ virtual void reportErr(const ErrorMessage &msg) = 0; - /** - * Report progress to client - * @param filename main file that is checked - * @param stage for example preprocess / tokenize / simplify / check - * @param value progress value (0-100) - */ - virtual void reportProgress(const std::string &filename, const char stage[], const std::size_t value) { - (void)filename; - (void)stage; - (void)value; - } - /** * Report unmatched suppressions * @param unmatched list of unmatched suppressions (from Settings::Suppressions::getUnmatched(Local|Global)Suppressions) diff --git a/lib/settings.cpp b/lib/settings.cpp index c49ca23561e..795488c50ca 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -67,7 +67,6 @@ Settings::Settings() preprocessOnly(false), quiet(false), relativePaths(false), - reportProgress(false), showtime(SHOWTIME_MODES::SHOWTIME_NONE), templateMaxTime(0), typedefMaxTime(0), diff --git a/lib/settings.h b/lib/settings.h index c77ad2392cc..f16198aebf5 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -266,9 +266,6 @@ class CPPCHECKLIB Settings { /** @brief Use relative paths in output. */ bool relativePaths; - /** @brief --report-progress */ - bool reportProgress; - /** Rule */ class CPPCHECKLIB Rule { public: diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 14e7ece42ad..de9f5c83097 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -156,11 +156,6 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes() // find all scopes for (const Token *tok = mTokenizer.tokens(); tok; tok = tok ? tok->next() : nullptr) { - // #5593 suggested to add here: - if (mErrorLogger) - mErrorLogger->reportProgress(mTokenizer.list.getSourceFilePath(), - "SymbolDatabase", - tok->progressValue()); // Locate next class if ((mTokenizer.isCPP() && tok->isKeyword() && ((Token::Match(tok, "class|struct|union|namespace ::| %name% final| {|:|::|<") && diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 3ff539ae067..e69c7d05463 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -3159,8 +3159,6 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( continue; Token * const tok2 = instantiation.token(); - if (mErrorLogger && !mTokenList.getFiles().empty()) - mErrorLogger->reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue()); if (maxtime > 0 && std::time(nullptr) > maxtime) { if (mSettings.debugwarnings) { @@ -3230,8 +3228,6 @@ bool TemplateSimplifier::simplifyTemplateInstantiations( // TODO: remove the specialized check and handle all uninstantiated templates someday. if (!instantiated && specialized) { Token * tok2 = const_cast(templateDeclaration.nameToken()); - if (mErrorLogger && !mTokenList.getFiles().empty()) - mErrorLogger->reportProgress(mTokenList.getFiles()[0], "TemplateSimplifier::simplifyTemplateInstantiations()", tok2->progressValue()); if (maxtime > 0 && std::time(nullptr) > maxtime) { if (mSettings.debugwarnings) { diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 302c202316c..3eba424a7fd 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1127,9 +1127,6 @@ void Tokenizer::simplifyTypedefCpp() const std::time_t maxTime = mSettings->typedefMaxTime > 0 ? std::time(nullptr) + mSettings->typedefMaxTime: 0; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (mErrorLogger && !list.getFiles().empty()) - mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (typedef)", tok->progressValue()); - if (Settings::terminated()) return; @@ -2832,9 +2829,6 @@ bool Tokenizer::simplifyUsing() std::list usingList; for (Token *tok = list.front(); tok; tok = tok->next()) { - if (mErrorLogger && !list.getFiles().empty()) - mErrorLogger->reportProgress(list.getFiles()[0], "Tokenize (using)", tok->progressValue()); - if (Settings::terminated()) return substitute; diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index dd968ed2694..5d9bb994061 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -180,9 +180,6 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ - - - @@ -519,14 +516,6 @@ There are false positives with this option. Each result must be carefully invest Use relative paths in output. When given, <paths> are used as base. You can separate multiple paths by ';'. Otherwise path where source files are searched is used. E.g. if given value is test, when checking test/test.cpp, the path in output will be test.cpp instead of test/test.cpp. The feature uses string comparison to create relative paths, so using e.g. ~ for home folder does not work. It is currently only possible to apply the base paths to files that are on a lower level in the directory tree. - - - - - - Report progress when checking a file. - - diff --git a/releasenotes.txt b/releasenotes.txt index 225e5b67917..30e2a7f1dd3 100644 --- a/releasenotes.txt +++ b/releasenotes.txt @@ -9,3 +9,4 @@ GUI: Changed interface: Other: +- removed command-line option "--report-progress" as it didn't provide much of a progress diff --git a/test/testcmdlineparser.cpp b/test/testcmdlineparser.cpp index fffa19f5ff7..2d94f694550 100644 --- a/test/testcmdlineparser.cpp +++ b/test/testcmdlineparser.cpp @@ -132,7 +132,6 @@ class TestCmdlineParser : public TestFixture { TEST_CASE(maxConfigsMissingCount); TEST_CASE(maxConfigsInvalid); TEST_CASE(maxConfigsTooSmall); - TEST_CASE(reportProgressTest); // "Test" suffix to avoid hiding the parent's reportProgress TEST_CASE(stdc99); TEST_CASE(stdcpp11); TEST_CASE(stdunknown); @@ -1024,15 +1023,6 @@ class TestCmdlineParser : public TestFixture { ASSERT_EQUALS("cppcheck: error: argument to '--max-configs=' must be greater than 0.\n", GET_REDIRECT_OUTPUT); } - void reportProgressTest() { - REDIRECT; - const char * const argv[] = {"cppcheck", "--report-progress", "file.cpp"}; - settings.reportProgress = false; - ASSERT(defParser.parseFromArgs(3, argv)); - ASSERT(settings.reportProgress); - ASSERT_EQUALS("", GET_REDIRECT_OUTPUT); - } - void stdc99() { REDIRECT; const char * const argv[] = {"cppcheck", "--std=c99", "file.cpp"};