Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions gui/test/projectfile/testprojectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "settings.h"
#include "suppressions.h"

#include <string>

#include <QFile>
#include <QIODevice>
#include <QList>
Expand All @@ -45,9 +43,6 @@ Platform::Platform() = default;
Library::Library() = default;
Library::~Library() = default;
struct Library::LibraryData {};
bool ImportProject::sourceFileExists(const std::string & /*file*/) {
return true;
}

void TestProjectFile::loadInexisting() const
{
Expand Down
9 changes: 0 additions & 9 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,6 @@ bool ImportProject::importCompileCommands(std::istream &istr)
#endif
else
path = Path::simplifyPath(directory + file);
if (!sourceFileExists(path)) {
printError("'" + path + "' from compilation database does not exist");
return false;
}
FileSettings fs{path, Standards::Language::None, 0}; // file will be identified later on
fsParseCommand(fs, command); // read settings; -D, -I, -U, -std, -m*, -f*
std::map<std::string, std::string, cppcheck::stricmp> variables;
Expand Down Expand Up @@ -1547,8 +1543,3 @@ void ImportProject::printError(const std::string &message)
{
std::cout << "cppcheck: error: " << message << std::endl;
}

bool ImportProject::sourceFileExists(const std::string &file)
{
return Path::isFile(file);
}
1 change: 0 additions & 1 deletion lib/importproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class CPPCHECKLIB WARN_UNUSED ImportProject {
protected:
bool importCompileCommands(std::istream &istr);
bool importCppcheckGuiProject(std::istream &istr, Settings &settings, Suppressions &supprs);
virtual bool sourceFileExists(const std::string &file);

private:
struct SharedItemsProject {
Expand Down
14 changes: 11 additions & 3 deletions test/cli/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ def test_json_entry_file_not_found(tmpdir):
"output": "bug1.o"}
]

expected = "'{}' from compilation database does not exist".format(os.path.join(tmpdir, "bug1.cpp"))
project_file = os.path.join(tmpdir, "file.json")
missing_file = os.path.join(tmpdir, "bug1.cpp")
missing_file_posix = missing_file

if sys.platform == "win32":
expected = expected.replace('\\', '/')
missing_file_posix = missing_file_posix.replace('\\', '/')

__test_project_error(tmpdir, "json", json.dumps(compilation_db), expected)
with open(project_file, 'w') as f:
f.write(json.dumps(compilation_db))

ret, _, stderr = cppcheck(["--project=" + str(project_file)])
assert 0 == ret
assert f"{missing_file}:1:0: error: File is missing: {missing_file_posix} [syntaxError]\n\n^\n" == stderr
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something for later - we should give this its own ID.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this caught me off-guard, but it's beyond the scope of this pr.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the changes related to this behavior have been a bit bandaid-y but there is big picture stuff. Which is why I am on the fence on some of these when they appear to be low-hanging fruits (if they actually were I would have posted fixes). I want to prevent multiple behavior changes for users like we have here that they now need to suppress syntaxError and will have to suppress a different ID in the future - and with the unmatched suppression handling still partially broken, it is a different can of worms (things are quite interconnected)...but I digress.



def test_json_no_arguments(tmpdir):
Expand Down
4 changes: 0 additions & 4 deletions test/testimportproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ class TestImporter : public ImportProject {
using ImportProject::importCppcheckGuiProject;
using ImportProject::importVcxproj;
using ImportProject::SharedItemsProject;

bool sourceFileExists(const std::string & /*file*/) override {
return true;
}
};


Expand Down