Menu

Non existing source files are silenctly ignored

2026-08-04
4 days ago
  • Torsten Rupp

    Torsten Rupp - 2026-08-04

    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.

     
  • Aaron Danen

    Aaron Danen - 4 days ago

    in cli/filelister.cpp:addFiles2 there is

        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.

     

Log in to post a comment.