Skip to content

feat: add ignorePaths method to exclude specified paths from arch ana…#1716

Open
sonalidudhia wants to merge 1 commit into
pestphp:5.xfrom
sonalidudhia:ignorepath-exception
Open

feat: add ignorePaths method to exclude specified paths from arch ana…#1716
sonalidudhia wants to merge 1 commit into
pestphp:5.xfrom
sonalidudhia:ignorepath-exception

Conversation

@sonalidudhia
Copy link
Copy Markdown

Summary

This PR introduces a minimal ignorePaths() API for architecture expectations to reduce noise during architecture analysis.

In larger projects, architecture rules may unintentionally analyze generated, infrastructure, or third-party files (for example migrations, vendor code, cache, or generated artifacts), which can create false positives unrelated to application boundaries.

Example:

arch()
    ->expect('App')
    ->ignorePaths([
        'vendor',
        'database/migrations',
    ])
    ->not->toUse(['dd', 'dump']);

Why

Architecture tests are typically intended to validate application boundaries and conventions.

In practice, projects often contain directories that are:

  • generated
  • infrastructure-related
  • historical (e.g. migrations)
  • third-party

These may not be desirable targets for architecture expectations and can introduce noise into otherwise intentional rules.

This PR adds a small, framework-agnostic API to selectively exclude paths from architecture analysis.

Design

The implementation intentionally keeps the API minimal:

  • single fluent API: ignorePaths(array $paths)
  • framework agnostic
  • chainable with existing expectations
  • cross-platform path normalization
  • no additional configuration
  • no framework-specific helpers

Tests

Added coverage for:

  • single ignored path
  • multiple ignored paths
  • nested directory matching
  • partial path matching
  • Windows path separators
  • non-ignored files remaining analysable
  • chaining with existing expectations

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.

1 participant