@@ -112,19 +112,21 @@ class CmdLineLoggerStd : public CmdLineLogger
112112class CppCheckExecutor ::StdLogger : public ErrorLogger
113113{
114114public:
115- explicit StdLogger (const Settings* settings) {
116- // cppcheck-suppress-begin danglingLifetime - this is intentional. the lifetime of the object exceeds its usage
117- mSettings = settings;
118- if (!mSettings -> outputFile .empty ()) {
119- mErrorOutput = new std::ofstream (settings-> outputFile );
115+ explicit StdLogger (const Settings& settings)
116+ : mSettings(settings)
117+ {
118+ if (!mSettings . outputFile .empty ()) {
119+ mErrorOutput = new std::ofstream (settings. outputFile );
120120 }
121- // cppcheck-suppress-end danglingLifetime
122121 }
123122
124123 ~StdLogger () override {
125124 delete mErrorOutput ;
126125 }
127126
127+ StdLogger (const StdLogger&) = delete ;
128+ StdLogger& operator =(const SingleExecutor &) = delete ;
129+
128130 void resetLatestProgressOutputTime () {
129131 mLatestProgressOutputTime = std::time (nullptr );
130132 }
@@ -157,7 +159,7 @@ class CppCheckExecutor::StdLogger : public ErrorLogger
157159 /* *
158160 * Pointer to current settings; set while check() is running for reportError().
159161 */
160- const Settings* mSettings {} ;
162+ const Settings& mSettings ;
161163
162164 /* *
163165 * Used to filter out duplicate error messages.
@@ -358,7 +360,7 @@ int CppCheckExecutor::check(int argc, const char* const argv[])
358360 return EXIT_SUCCESS;
359361 }
360362
361- mStdLogger = new StdLogger (& settings);
363+ mStdLogger = new StdLogger (settings);
362364 CppCheck cppCheck (*mStdLogger , true , executeCommand);
363365 cppCheck.settings () = settings;
364366
@@ -464,23 +466,23 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck)
464466
465467void CppCheckExecutor::StdLogger::writeCheckersReport () const
466468{
467- CheckersReport checkersReport (* mSettings , mActiveCheckers );
469+ CheckersReport checkersReport (mSettings , mActiveCheckers );
468470
469- if (!mSettings -> quiet ) {
471+ if (!mSettings . quiet ) {
470472 const int activeCheckers = checkersReport.getActiveCheckersCount ();
471473 const int totalCheckers = checkersReport.getAllCheckersCount ();
472474
473- const std::string extra = mSettings -> verbose ? " (use --checkers-report=<filename> to see details)" : " " ;
475+ const std::string extra = mSettings . verbose ? " (use --checkers-report=<filename> to see details)" : " " ;
474476 if (mCriticalErrors .empty ())
475477 std::cout << " Active checkers: " << activeCheckers << " /" << totalCheckers << extra << std::endl;
476478 else
477479 std::cout << " Active checkers: There was critical errors" << extra << std::endl;
478480 }
479481
480- if (mSettings -> checkersReportFilename .empty ())
482+ if (mSettings . checkersReportFilename .empty ())
481483 return ;
482484
483- std::ofstream fout (mSettings -> checkersReportFilename );
485+ std::ofstream fout (mSettings . checkersReportFilename );
484486 if (fout.is_open ())
485487 fout << checkersReport.getReport (mCriticalErrors );
486488
@@ -580,7 +582,7 @@ void CppCheckExecutor::StdLogger::reportProgress(const std::string &filename, co
580582
581583 // Report progress messages every x seconds
582584 const std::time_t currentTime = std::time (nullptr );
583- if (currentTime >= (mLatestProgressOutputTime + mSettings -> reportProgress ))
585+ if (currentTime >= (mLatestProgressOutputTime + mSettings . reportProgress ))
584586 {
585587 mLatestProgressOutputTime = currentTime;
586588
@@ -597,16 +599,14 @@ void CppCheckExecutor::StdLogger::reportProgress(const std::string &filename, co
597599
598600void CppCheckExecutor::StdLogger::reportErr (const ErrorMessage &msg)
599601{
600- assert (mSettings != nullptr );
601-
602602 if (msg.severity == Severity::none && (msg.id == " logChecker" || endsWith (msg.id , " -logChecker" ))) {
603603 const std::string& checker = msg.shortMessage ();
604604 mActiveCheckers .emplace (checker);
605605 return ;
606606 }
607607
608608 // Alert only about unique errors
609- if (!mShownErrors .insert (msg.toString (mSettings -> verbose )).second )
609+ if (!mShownErrors .insert (msg.toString (mSettings . verbose )).second )
610610 return ;
611611
612612 if (ErrorLogger::isCriticalErrorId (msg.id ) && mCriticalErrors .find (msg.id ) == std::string::npos) {
@@ -615,10 +615,10 @@ void CppCheckExecutor::StdLogger::reportErr(const ErrorMessage &msg)
615615 mCriticalErrors += msg.id ;
616616 }
617617
618- if (mSettings -> xml )
618+ if (mSettings . xml )
619619 reportErr (msg.toXML ());
620620 else
621- reportErr (msg.toString (mSettings -> verbose , mSettings -> templateFormat , mSettings -> templateLocation ));
621+ reportErr (msg.toString (mSettings . verbose , mSettings . templateFormat , mSettings . templateLocation ));
622622}
623623
624624#if defined(USE_WINDOWS_SEH) || defined(USE_UNIX_SIGNAL_HANDLING)
0 commit comments