Dependency Analyzer tool - enforce boundaries

I wrote a small static analysis tool to enforce architectural boundaries and dependency rules. I am not sure i should publish it to pub.dev or not. Do you think this is something useful for the community?

Basically you define a set of rules inside a yaml config file, like this

rules:
  - key: "no_circular_dependencies"
    description: "Circular dependencies are not allowed"

  - key: "no_package_to_package"
    description: "Features cannot depend on other features"
    from: "pattern:feature_*"
    to: "pattern:feature_*"

  - key: "no_package_to_package"
    description: "Packages cannot depend on other packages in shared folder"
    from: "folder:shared"
    to: "folder:shared"

  - key: "no_package_to_package"
    description: "Feature b cannot depend on feature a and vice versa"
    from: "feature:feature_b"
    to: "feature:feature_a"
    inverse: true # This rule is inverse because we want to avoid circular dependencies

Run the script

dart run lib/main.dart -p example -c ./lib/config.yaml

And it outputs if any violation is found inside the project.
I wrote this to run on a CI/CD and fail the pipeline if there is any violation.

6 Likes

Hey i’d be interested in this. Can’t see the harm in publishing to pub.dev. Also would be interesting to know how you implemented it.