Skip to content

Fix #15081 (usability: try to report misuse of exclude options) - #8906

Open
danmar wants to merge 2 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:unused-exclude
Open

danmar wants to merge 2 commits into
cppcheck-opensource:mainfrom
cppchecksolutions:unused-exclude

Conversation

@danmar

@danmar danmar commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 19:57

This comment was marked as outdated.

Copilot AI balanced review requested due to automatic review settings September 30, 2026 20:01

This comment was marked as outdated.

@danmar
danmar marked this pull request as ready for review October 1, 2026 16:30
@danmar
danmar requested a balanced review from Copilot October 1, 2026 16:30

This comment was marked as outdated.

@danmar danmar changed the title Unused exclude Fix #15081 (usability: try to report misuse of exclude options) Oct 1, 2026
@danmar
danmar requested a balanced review from Copilot October 2, 2026 04:29

This comment was marked as outdated.

Comment thread cli/cmdlineparser.cpp
Comment thread lib/pathmatch.cpp
}
}

std::vector<std::string> PathMatch::unmatched() const {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve button

Header excludes can never be "used", because Path::acceptFile() filters out headers before ignored.match() is called. So -iinc/h.h src or -i*.h src now prints:

cppcheck: filename exclusion does not apply to header (.h and .hpp) files.
cppcheck: Please use --suppress for ignoring results from the header files.
cppcheck: error: unused ignore/exclude path 'inc/h.h'. To hide warnings in certain files use suppressions instead.

and exits with code 1. Before, this was only an informational message. If failing is intended for headers, the first two lines could probably be merged into the error, or dropped, so the same thing isn't said twice. If it isn't intended, header patterns could be left out of the unused check.

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.

3 participants