Skip to content

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

Open
danmar wants to merge 1 commit into
cppcheck-opensource:mainfrom
cppchecksolutions:unused-exclude
Open

danmar wants to merge 1 commit 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Overlapping patterns are misreported, some build paths no longer compile, and GUI project analysis omits validation.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 2 Low severity

Open (5)
What changed in this PR

Adds detection and reporting for unused ignore/exclude patterns across CLI and GUI analysis flows.

Changes:

  • Tracks matched patterns in PathMatch.
  • Reports unused exclusions during CLI and GUI analysis.
  • Adds coverage for matching and reporting behavior.
File Description
lib/​pathmatch.h Adds match tracking API and state.
lib/​pathmatch.cpp Records matched patterns.
lib/​importproject.h Returns unmatched project exclusions.
lib/​importproject.cpp Collects unmatched project exclusions.
cli/​filelister.h Makes matcher parameters mutable.
cli/​filelister.cpp Propagates mutable matchers.
cli/​cmdlineparser.cpp Rejects unused exclusions.
gui/​filelist.h Exposes unmatched exclusions.
gui/​filelist.cpp Computes unmatched exclusions.
gui/​mainwindow.cpp Displays unused-exclusion warnings.
gui/​test/​filelist/​testfilelist.h Declares new GUI tests.
gui/​test/​filelist/​testfilelist.cpp Tests unmatched GUI exclusions.
test/​testpathmatch.cpp Tests pattern tracking.
test/​testfilelister.cpp Updates matcher usage.
test/​testcmdlineparser.cpp Tests CLI validation.
test/​helpers.cpp Updates helper matcher usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/filelister.h
Comment thread lib/importproject.cpp
Comment thread lib/pathmatch.cpp Outdated
Comment thread cli/cmdlineparser.cpp
Comment thread gui/mainwindow.cpp
Copilot AI balanced review requested due to automatic review settings September 30, 2026 20:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Windows compilation is broken, and several paths can incorrectly or inconsistently report unused exclusions.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 2 Low severity

Open (5)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Validate project excludes against the complete file set

gui/​mainwindow.cpp:694

This check evaluates project-wide excludes only against the current files argument. checkProject() passes recheckFiles here when rechecking a modified subset (mainwindow.cpp:1986-1995), so any valid project exclude that only matches a file outside that subset is reported as unused and the recheck is aborted. Restrict this validation to a full analysis, or validate against the complete project input set rather than the recheck subset.

@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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread gui/filelist.cpp
Comment thread gui/mainwindow.cpp 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Pattern coverage can incorrectly hide genuinely unused exclusions.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)

Comment thread lib/pathmatch.cpp
Comment on lines +165 to +169
// paths inside a matched directory are not traversed, so a pattern that is
// covered by a matched pattern is considered used
const Filemode mode = !s.empty() && PathIterator::issep(s.back(), mSyntax) ? Filemode::directory : Filemode::regular;
return std::none_of(mMatchedPatterns.cbegin(), mMatchedPatterns.cend(), [&](const std::string& matched) {
return match(matched, s, mBasepath, mode, mSyntax);
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