struct stat file_stat;
if (stat(path.c_str(), &file_stat) == -1)
return ""; // TODO: return error?
if we returned an error here we could help users who are in this situation. I don't know what situation there would be for a user to specify the analysis of a nonexistent file. The most common thing would probably be people mistyping the name of a file or something similar, in which case proceeding as usual is probably an annoying behavior.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It seems non existing files are silently ignored if a least one source file is found.
Reproduce:
touch a.cpp
cppcheck a.cpp missing.cpp
echo $?
Result: 0
Expected behavior: some error message like
cppcheck: error: could not find 'missing.cpp'
However this produce an error message as expected:
cppcheck missing.cpp
cppcheck: error: could not find or open any of the paths given.
Thus if at least one source file is found all not existing other source files are silently ignored.
in cli/filelister.cpp:addFiles2 there is
if we returned an error here we could help users who are in this situation. I don't know what situation there would be for a user to specify the analysis of a nonexistent file. The most common thing would probably be people mistyping the name of a file or something similar, in which case proceeding as usual is probably an annoying behavior.