diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 1d64c1751e4..3fec328d3f9 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -580,13 +580,9 @@ unsigned int CppCheck::check(const FileWithDetails &file, const std::string &con unsigned int CppCheck::check(const FileSettings &fs) { -<<<<<<< HEAD -<<<<<<< HEAD // TODO: move to constructor when CppCheck no longer owns the settings if (mSettings.checks.isEnabled(Checks::unusedFunction) && !mUnusedFunctionsCheck) mUnusedFunctionsCheck.reset(new CheckUnusedFunctions()); - -======= if (!Path::isFile(fs.filename)) { std::string fixedpath = Path::simplifyPath(fs.filename); fixedpath = Path::toNativeSeparators(fixedpath); @@ -594,9 +590,6 @@ unsigned int CppCheck::check(const FileSettings &fs) fileNotFoundError(fs.filename, errorMsg); return 0; } ->>>>>>> 8f585fe73 (Fix) -======= ->>>>>>> 74a6847dd (Remodel) CppCheck temp(mErrorLogger, mUseGlobalSuppressions, mExecuteCommand); temp.mSettings = mSettings; if (!temp.mSettings.userDefines.empty()) @@ -714,19 +707,16 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string std::string locfile = Path::fromNativeSeparators(output.location.file()); if (mSettings.relativePaths) locfile = Path::getRelativePath(locfile, mSettings.basePaths); - - ErrorMessage::FileLocation loc1(locfile, output.location.line, output.location.col); - - ErrorMessage errmsg({std::move(loc1)}, - "", // TODO: is this correct? - 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")); @@ -1057,7 +1047,6 @@ unsigned int CppCheck::checkFile(const FileWithDetails& file, const std::string return mExitCode; } -<<<<<<< HEAD static ErrorMessage makeError(const std::string &filename, const std::string &msg, const std::string &id) { const std::string fullmsg("Bailing out from analysis: " + msg); @@ -1073,19 +1062,12 @@ static ErrorMessage makeError(const std::string &filename, const std::string &ms Certainty::normal); } -======= ->>>>>>> 74a6847dd (Remodel) // TODO: replace with ErrorMessage::fromInternalError() 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 normal token list //--------------------------------------------------------------------------- diff --git a/test/cli/more-projects_test.py b/test/cli/more-projects_test.py index 4b10a224e70..6599f052328 100644 --- a/test/cli/more-projects_test.py +++ b/test/cli/more-projects_test.py @@ -870,4 +870,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) + assert stderr == ': (error) File {} does not exists. Skipping file.\n'.format(filename) diff --git a/test/testcppcheck.cpp b/test/testcppcheck.cpp index b7e0048850f..19497fd9fc2 100644 --- a/test/testcppcheck.cpp +++ b/test/testcppcheck.cpp @@ -117,10 +117,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