Skip to content

Conversation

@fain182
Copy link
Collaborator

@fain182 fain182 commented Dec 27, 2025

This commit adds two new expression rules to support exact namespace matching, addressing the feature request in issue #406:

  • ResideInOneOfTheseNamespacesExactly: Validates that classes reside in one of the specified namespaces exactly, without matching child namespaces
  • NotResideInOneOfTheseNamespacesExactly: The inverse rule that validates classes do NOT reside in the specified namespaces exactly

The existing rules (ResideInOneOfTheseNamespaces and NotResideInTheseNamespaces) match recursively, including all child namespaces. The new rules provide an exact match option for stricter architectural constraints.

fixes #406

This commit adds two new expression rules to support exact namespace
matching, addressing the feature request in issue #406:

- ResideInOneOfTheseNamespacesExactly: Validates that classes reside
  in one of the specified namespaces exactly, without matching child
  namespaces
- NotResideInOneOfTheseNamespacesExactly: The inverse rule that
  validates classes do NOT reside in the specified namespaces exactly

The existing rules (ResideInOneOfTheseNamespaces and
NotResideInTheseNamespaces) match recursively, including all child
namespaces. The new rules provide an exact match option for stricter
architectural constraints.

Implementation:
- Added namespaceMatchesExactly() method to ClassDescription
- Created ResideInOneOfTheseNamespacesExactly expression class
- Created NotResideInOneOfTheseNamespacesExactly expression class
- Added comprehensive test coverage for both new rules
- All existing tests continue to pass
@codecov
Copy link

codecov bot commented Dec 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.80%. Comparing base (730d429) to head (53d43d5).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #554      +/-   ##
============================================
+ Coverage     97.74%   97.80%   +0.05%     
- Complexity      614      658      +44     
============================================
  Files            79       81       +2     
  Lines          1775     1913     +138     
============================================
+ Hits           1735     1871     +136     
- Misses           40       42       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlessandroMinoccheri
Copy link
Member

It seems ok for me, what about adding few lines in the readme to document it?

Updated README.md to include documentation for the two new namespace
matching rules introduced in the previous commit:

- ResideInOneOfTheseNamespacesExactly
- NotResideInOneOfTheseNamespacesExactly

The documentation includes:
- Clear descriptions of how exact matching differs from recursive matching
- Code examples showing typical use cases
- Visual examples demonstrating what matches and what doesn't

These rules address issue #406 by providing stricter namespace
validation options.
@fain182
Copy link
Collaborator Author

fain182 commented Jan 5, 2026

Great point, thanks!

Copy link
Member

@AlessandroMinoccheri AlessandroMinoccheri left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.

Support for checking the namespace exactly

4 participants