cppcheck icon indicating copy to clipboard operation
cppcheck copied to clipboard

Fix #11797 crash on missing/renamed files

Open olabetskyi opened this issue 1 year ago • 7 comments

olabetskyi avatar Jan 29 '24 14:01 olabetskyi

As usual - please add a unit test for this.

This looks related to #5411 which I still need to finish up.

Also didn't we already add such code? I remember having a discussion with @danmar about something similar (with me having quite some opinion on this).

firewave avatar Jan 29 '24 15:01 firewave

As usual - please add a unit test for this.

This looks related to #5411 which I still need to finish up.

Also didn't we already add such code? I remember having a discussion with @danmar about something similar (with me having quite some opinion on this).

It's not finished yet. Should have marked it as draft

olabetskyi avatar Jan 29 '24 15:01 olabetskyi

Also didn't we already add such code? I remember having a discussion with @danmar about something similar (with me having quite some opinion on this).

I don't know.. I had a vague feeling we added something like this. But we do reproduce crashes with latest git head.

danmar avatar Jan 30 '24 06:01 danmar

with me having quite some opinion on this

@firewave sorry but I don't have the discussion in my head.. please feel free to comment on this.

  • This approach will mean that "fileNotFound" errors are written in the gui + xml report which is desired behavior imho.
  • If the file is deleted/renamed for some reason after the project is imported then cppcheck will not crash but show the error report

danmar avatar Jan 30 '24 10:01 danmar

This is okay as a catch-all to avoid the crashes (which is the most important in the short-term) but I still think it should be caught earlier.

This needs a release notes entry.

We also need Python tests for each project input which is lacking a file. I do not feel like adding tests later on which should have been there in the first place - again.

firewave avatar Jan 31 '24 11:01 firewave

firewave has made an effort to make sure tests can be executed from different folders. As your test is written I fear it must be executed from inside test/cli folder.

danmar avatar Jan 31 '24 16:01 danmar

@firewave

but I still think it should be caught earlier.

Overall I think that it is a good strategy to fail immediately/early... But we should probably think more carefully about how we report problems. If we just report it directly in plain text on stdout/stderr then it is likely that cppcheck plugins will not accept it as expected output - the user might not get any information about what goes wrong. We also need to ensure that the problem is properly logged in the GUI.

danmar avatar Jan 31 '24 19:01 danmar