Skip to content

Add warning for unmatched include/exclude patterns#55

Merged
simone-viozzi merged 4 commits intomainfrom
copilot/raise-warning-for-patterns
Nov 23, 2025
Merged

Add warning for unmatched include/exclude patterns#55
simone-viozzi merged 4 commits intomainfrom
copilot/raise-warning-for-patterns

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 23, 2025

Implement warning for unmatched include/exclude patterns

The goal is to raise a warning to stderr when some patterns did not match anything.

Plan:

  • Add tracking mechanism to FilterEngine to record which patterns matched at least once
  • Modify FilterEngine.matches() to track when patterns successfully match
  • Add method to get unmatched patterns from FilterEngine
  • Display warnings for unmatched patterns in main() function
  • Write tests for the warning functionality
  • Run existing tests to ensure no regressions
  • Manually test with CLI to verify warnings appear correctly
  • Address code review feedback
  • Refactor tests to extend existing test files instead of creating new standalone file

Implementation Details:

Changes to filter.py:

  • Added _pattern_matched dictionary to track whether each pattern has matched at least once
  • Modified matches() method to set the tracking flag when a pattern matches
  • Added get_unmatched_patterns() method to return list of unmatched patterns with their rule kinds
  • Removed unreachable code in _include_can_match_descendant()

Changes to gpt_copy.py:

  • Added warning display at end of main() function to show unmatched patterns to stderr
  • Warning format: --include 'pattern' or --exclude 'pattern' for each unmatched pattern

Test changes:

  • Extended test_file_filtering.py with 2 FilterEngine unit tests for tracking mechanism
  • Extended test_user_issue_exclusion.py with 2 CLI tests for warnings
  • Extended test_filter_spec.py with 1 CLI test for warnings in complex scenarios
  • Total: 63 tests (58 original + 5 new integrated tests)

Testing:

  • All 63 tests pass
  • Manual testing confirmed warnings appear correctly for unmatched patterns
  • No warnings when all patterns match
  • Linting and formatting checks pass
  • Code review feedback addressed
Original prompt

This section details on the original issue you should resolve

<issue_title>raise a warning if an inclusion exclusion pattern is not matching anything</issue_title>
<issue_description>The app should raise a warning to stderr some patterns did not match anything.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 23, 2025 16:50
- Modified FilterEngine to track which patterns have matched at least once
- Added get_unmatched_patterns() method to retrieve patterns that didn't match
- Updated main() to display warnings to stderr for unmatched patterns
- Added comprehensive tests for the new functionality
- All existing tests pass

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
- Remove unreachable code in filter.py
- Clarify misleading comment in test_unmatched_patterns.py

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add warning for unmatched inclusion exclusion patterns Add warning for unmatched include/exclude patterns Nov 23, 2025
Copilot AI requested a review from simone-viozzi November 23, 2025 16:56
Copy link
Copy Markdown
Owner

@simone-viozzi simone-viozzi left a comment

Choose a reason for hiding this comment

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

instead of adding 5 new tests, extend some of the existing ones

Instead of creating a standalone test file with 7 new tests, extended existing test files:
- Added 2 FilterEngine unit tests to test_file_filtering.py
- Added 2 CLI warning tests to test_user_issue_exclusion.py
- Added 1 CLI warning test to test_filter_spec.py
- Removed standalone test_unmatched_patterns.py

Total: 63 tests (down from 65, as 5 new tests integrated into existing files)

Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 23, 2025

instead of adding 5 new tests, extend some of the existing ones

Done. I've integrated the tests into existing test files:

  • Added 2 FilterEngine unit tests to test_file_filtering.py
  • Added 2 CLI warning tests to test_user_issue_exclusion.py
  • Added 1 CLI warning test to test_filter_spec.py
  • Removed standalone test_unmatched_patterns.py

Total test count is now 63 (down from 65, as 5 new tests were integrated into existing files). All tests pass. (commit 861b730)

Copilot AI requested a review from simone-viozzi November 23, 2025 17:06
@simone-viozzi simone-viozzi marked this pull request as ready for review November 23, 2025 22:57
@simone-viozzi simone-viozzi merged commit 3f93610 into main Nov 23, 2025
5 checks passed
@simone-viozzi simone-viozzi deleted the copilot/raise-warning-for-patterns branch November 23, 2025 22:57
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.

raise a warning if an inclusion exclusion pattern is not matching anything

2 participants