diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index dce52fdefa6b..15970b6b491d 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -674,19 +674,16 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (mSettings.relativePaths) file = Path::getRelativePath(file, mSettings.basePaths); - const ErrorMessage::FileLocation loc1(file, output.location.line, output.location.col); - std::list callstack(1, loc1); - - ErrorMessage errmsg(callstack, - "", - Severity::error, - output.msg, - "syntaxError", - Certainty::normal); if(output.type == simplecpp::Output::Type::FILE_NOT_FOUND){ const std::string fixedpath = Path::toNativeSeparators(file); const std::string errorMsg("File " + fixedpath + " does not exists. Skipping file."); - fileNotFoundError(file, errorMsg); + + reportErr(ErrorMessage(std::list (), + emptyString, + Severity::error, + errorMsg, + "fileNotFound", + Certainty::normal)); } else{ reportErr(makeError(file, output.location.line, output.location.col, output.msg, "syntaxError")); @@ -1059,11 +1056,6 @@ void CppCheck::internalError(const std::string &filename, const std::string &msg mErrorLogger.reportErr(makeError(filename, 0, 0U, "Bailing out from analysis:" + msg, "internalError")); } -void CppCheck::fileNotFoundError(const std::string &filename, const std::string &msg) -{ - mErrorLogger.reportErr(makeError(filename, 0, 0U, msg, "fileNotFound")); -} - //--------------------------------------------------------------------------- // CppCheck - A function that checks a raw token list //--------------------------------------------------------------------------- diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 00f9d73059e1..a2d1ccd88339 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -643,4 +643,4 @@ def test_project_missing_files(): filename = os.path.join('invalid-project', 'main.c') ret, _, stderr = cppcheck(['--template=cppcheck1', '--project=' + os.path.join('invalid-project', 'invalid-project.vcxproj')]) assert ret == 0 - assert stderr == '[{}:0]: (error) File {} does not exists. Skipping file.\n'.format(filename, filename) \ No newline at end of file + assert stderr == ': (error) File {} does not exists. Skipping file.\n'.format(filename) \ No newline at end of file diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index 5ea671a2da65..cc267c93e48d 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -113,10 +113,11 @@ class TestCppcheck : public TestFixture { { ErrorLogger2 errorLogger; CppCheck cppcheck(errorLogger, false, {}); - ASSERT_EQUALS(0, cppcheck.check("NotAFile")); + ASSERT_EQUALS(1, cppcheck.check("NotAFile")); ASSERT_EQUALS(1, errorLogger.ids.size()); ASSERT_EQUALS("fileNotFound", *errorLogger.ids.cbegin()); + ASSERT_EQUALS("File NotAFile does not exists. Skipping file.", errorLogger.errmsgs.cbegin()->shortMessage()); } void checkWithFS() const