Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I ignore vendor analysis when using --fail-on-uncovered #1182

Closed
razvan-tache opened this issue May 16, 2023 · 2 comments
Closed

How can I ignore vendor analysis when using --fail-on-uncovered #1182

razvan-tache opened this issue May 16, 2023 · 2 comments
Labels

Comments

@razvan-tache
Copy link

Hi, I'm trying to use deptrac for my project.

I want to use --fail-on-uncovered as it's a pretty nifty tool to identify how you application is using the vendor library.
I only want to check how and if I user my direct imports from composer.json.

I do not want to analyze any vendor file, as I am interested in only how I am using them, and not in how themselves are using their imports.

Example:

deptrac:
  paths:
    - ./src
    - ./vendor/psr/log
    - ./vendor/slickdeals/statsd
  exclude_files:
    - '#.*test.*#i'
  layers:
    - name: Application
      collectors:
        - type: directory
          value: src/Application
    - name: Domain
      collectors:
        - type: directory
          value: src/Domain
    - name: Infrastructure
      collectors:
          - type: directory
            value: src/Infrastructure
    - name: Monitoring
      collectors:
          - type: directory
            value: src/Monitoring

    - name: VendorPsrLog
      collectors:
          - type: directory
            value: vendor/psr/log
    - name: VendorStatsClient
      collectors:
          - type: directory
            value: vendor/slickdeals/statsd
  ruleset:
    Application:
      - Domain
      - Monitoring
      - VendorPsrLog
    Domain:
      - Monitoring
      - VendorPsrLog
    Infrastructure:
      - Domain
      - Monitoring
      - VendorPsrLog
      - VendorStatsClient # For Monitoring
    Monitoring:
      - VendorPsrLog

How can I achieve this? How can I exclude VendorPsrLog and VendorStatsClient from analysing their own dependencies?

@patrickkusebauch
Copy link
Collaborator

This is possible by making 2 changes:

  1. Remove ./vendor/psr/log and ./vendor/slickdeals/statsd from paths - this way you tell deptrac you do not want those folders analysed
  2. Change your collectors in Vendor* layers to not use directory collector. You have several options there. You can use ClassNameRegex collector or similar and match on the namespace of the dependency, or, in the next release of Deptrac, you can use the composer collector.

@razvan-tache
Copy link
Author

I understand. That's actually really smart.
It worked.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants