Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial fix for #11797: If sourcefile in imported project is missing then report critical error fileNotFound #5498

Closed
wants to merge 3 commits into from

Conversation

danmar
Copy link
Owner

@danmar danmar commented Sep 29, 2023

No description provided.

"File not found",
"fileNotFound",
Certainty::normal));
mExitCode = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should not arbitrary set the exitcode. Severrity::error will already do this based on --error-exitcode. This will cause the analysis to fail even if the user suppresses this without any indication why.

unsigned int CppCheck::check(const ImportProject::FileSettings &fs)
{
if (!Path::isFile(fs.filename)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Other projects perform these checks with importproject.cpp so this duplicates logic. Having an controllable logic might be better though. But we should implement and this properly this properly for all projects. We should not introduce more half-baked or inconsistent behavior. We still trying to get rid of such things from years and years ago.

I also think this might be the wrong location to do this. I think this should be reported closer to the actual import but I think we might be lacking common code to place this in.

Copy link
Owner Author

@danmar danmar Sep 29, 2023

Choose a reason for hiding this comment

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

We can put it in importproject also. But I wanted to achieve that the analysis will continue on other files that are found. I saw that if a file is missing when compile_commands.json is loaded then all analysis is aborted and that might be unfortunate. And putting this check here means that if the file has been removed after the project was loaded then we still detect this problem and bails out with an error message. Still.. maybe we can tune this and report it if simplecpp fails to read the source file instead.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understood the intention. I just want it to be consistent in implementation and test.

We should do in in the import step as we do with Path::acceptFile() so we know this as early as possible and not bail out on the first error. Similar to the changes I did for library and addon loading.

The problem is that we are not able to collect errors there - yet. That's what I added CmdLineLogger for. I want to collect all errors and report them with a proper ID after all options have been processed. But I need a few more things merged and changed first.

So this change is fine for now as we cannot solve it in a better way yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I will post a draft PR soon after my pending stuff has been merged and I finished up most of the executor stuff. If things go well that should be as soon as next week.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I just want it to be consistent in implementation and test.

hmm yes

I will post a draft PR soon after my pending stuff has been merged and I finished up most of the executor stuff.

ok sure.

If things go well that should be as soon as next week.

I would like to have this in next major release 2.13 so well it's not a hurry yet.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I just want it to be consistent in implementation and test.

hmm yes

Simply adding tests with missing files for all projects would be sufficient.

filename,
Severity::error,
"File not found",
"fileNotFound",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error might be too generic. Something more specific would be better since there might be more errors like this coming soon.

filename,
Severity::error,
"File not found",
"fileNotFound",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The error might be too generic. Something more specific would be better since there might be more errors like this coming soon.

def test_vs_project_missing_file():
with open('proj2/proj2.vcxproj', 'rt') as fin:
s = fin.read()
with open('proj2/test.vcxproj', 'wt') as fout:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use tmpdir if we are generating new files but none of the tests here currently do that.

@danmar
Copy link
Owner Author

danmar commented Sep 29, 2023

thanks @firewave I think these are good review comments.

@firewave
Copy link
Collaborator

thanks @firewave I think these are good review comments.

As usual I think I sounded a bit harsh but that comes with my condition not being able to think straight and trying to get my point over. 🫤 Sorry about that.

@danmar danmar closed this Oct 5, 2023
@danmar danmar deleted the 11797-bpr branch October 5, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants