-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix #12771: Progress value is not increased #6993
base: main
Are you sure you want to change the base?
Conversation
I have similar code which deals with the language. I guess the basic logic can be re-used/combined from the changes. |
This also needs tests for the cases the progress was not correctly reported. |
Hm, I'm not sure what you mean, do you have a PR for it? |
Not yet - #6978 is in preparation of the change I referred to. But I am not too sure about it - the context-less usages (i.e. no file, no language) which will only lead to issue with specific usage are giving me headaches. Maybe I use your use case to proceed with this. |
@@ -106,7 +108,7 @@ class ThreadData | |||
if (mItNextFileSettings != mFileSettings.end()) { | |||
file = nullptr; | |||
fs = &(*mItNextFileSettings); | |||
fileSize = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make sure we always fetch the filesize we probably should initialize/set it to -1 everywhere and valid that later on. Can be done at a later date though.
FYI when we need to test something related to inputs there is three different cases to consider:
|
Okay, thanks! I'll be focusing on other tickets for a while so I'll pick this up at a later time. |
Don't end up like me... 🙄 |
I would prefer to have the code which gets the filesize in |
I noticed the percentage reported in cppcheck/cli/singleexecutor.cpp Line 67 in 85eadd8
|
No idea - I would need to look at the history. But I wonder why we calculate it based on on the file size anyways. That makes no sense because we are using the size of the actual input file. A file with just a few lines itself might end up with much more code which is being analyzed. So that would only make sense if we used the size of preprocessed code. I think we should just consider the amount of files. |
That makes sense. I'm not sure how the workflow would look for that, should it be it's own ticket? |
Originally it was number of files.. Then at some point we were discussing some project in the chat. I was running Cppcheck on the project. I had checked a number of the files. So the report said "X% done". And in the chat I said something like "I have checked X% already but well there are big files remaining so probably it's going to take longer time." It's still a very rough estimate. As you pointed out it depends a lot on what headers are included. And it can depend a lot on how many branches etc there are. A huge file with trivial code can run quickly. I don't have super strong opinion.. but generally.. based on number of files the guess will be off more imho. A small file would generally go faster to analyse than a large file. |
That is my "best guess".. I can't prove it. :-) |
Would it be possible to base it on the length of the token list? |
nah.. I believe it would be more accurate but that would increase the analysis time. we would need to open all the files and count all the tokens to know the total number of tokens. |
The value is arbitrary and inaccurate either way - so I would go with the simpler implementation i.e. file count only. It would also match the default ('-j1') behavior. |
I guess we actually have both right now, with |
Fair enough. |
Co-authored-by: Oliver Stöneberg <[email protected]>
@@ -245,6 +245,9 @@ bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) | |||
if (mSettings.library.markupFile(fs.filename())) { | |||
fs.file.setLang(Standards::Language::C); | |||
} | |||
std::string error = fs.updateFileSize(); | |||
if (!error.empty()) | |||
mLogger.printError(error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use mLogger.printError
then it feels like we should abort. But I think it's unfortunate to abort if there are missing files. Could we write some proper cppcheck warnings during the analysis instead if a file cannot be opened.
How about just setting filesize to -1 or something:
- when total file size is calculated ignore files that have size -1
- during analysis ensure there is some proper cppcheck message when a file can not be opened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the files can just be removed from the list (after showing a warning)? That way we don't have to care about it when calculating the total file size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that error happens we should bail out - otherwise we would silently (nobody cares about the warnings because they are not visible in a headless system - yet) drop a file from the analysis which might cause issues to slip through or lead to inconsistent results between runs.
This should only happen if there are filesystem issues or somebody is modifying the data. You should avoid that. e.g. in the CLion IDE integration I pass a fixed temporary file to the analysis to avoid that a file which might constantly being changed is being read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If mLogger.printError(error);
is used and Cppcheck just aborts then I see the risk that Cppcheck plugins will silently just fail and the user get no proper information. For instance the vscode plugin does not show the Cppcheck printError
output it just does not recognize its output and aborts. It just says "Failed to execute Cppcheck" or something like that.
nobody cares about the warnings because they are not visible in a headless system - yet
I don't know what you talk about. It would be pointless to run Cppcheck at all if nobody cares about the warnings. I want that we report proper Cppcheck warning output so the plugins have a good chance to show the output.
This should only happen if there are filesystem issues or somebody is modifying the data.
Yeah sure.. but we do run into this sometimes. And it would be nice to be able to scan a project even if some files are autogenerated during build or whatever..
I still think we should drop the file size percentage. Looking at how much time and discussion has already been put into this and it is something a high percentage of the users will probably never see as they use headless systems (i.e. CI/IDE integrations). It seems the time might be better spent on something else than making an arbitrary value arbitrary in a different way... |
I don't want to drop it. |
No description provided.