Repository navigation
Conversation
|
Thanks @MrYawe! I am wondering if we can't already emit something similar by using --fail-above on |
|
@josevalim Concrete example: we have a base schema module that all our Ecto schemas use ( So What I really need is only the threshold. So maybe simpler: I drop the stats part, and the option applies to the label: compile-connected already means "compile dependency on a file with at least 1 dependency", so this would just make that 1 configurable. WDYT? |
|
Yes, the smaller one is better. But also, quick question, couldn't you use --exclude or --group? |
With --label compile-connected, a compile-time dependency is only considered compile-connected if the file it points to has at least the given number of transitive dependencies.
8676d54 to
656141a
Compare
|
I tried both on our app. In practice though, groups can't overlap, so files sharing a dependency end up merged together. For us that gives 17 groups and about 130 paths to keep in the CI command, the biggest one with 53 files, and everything inside a group becomes invisible. --exclude is about 50 paths, and half of them are files other modules depend on at compile time, so we would hide those too. And each time someone adds a small helper to one of those modules, the list needs an update. With the threshold it's one number and nothing to maintain. I'll update the PR with the smaller version (the option on the label, no change to stats). |
| Once those files are addressed, you can keep new ones from being introduced, | ||
| for example in your continuous integration server, by failing whenever there | ||
| is a compile-time dependency on a file with too many transitive dependencies: | ||
|
|
||
| $ mix xref graph --label compile-connected --min-transitive-dependencies 10 --fail-above 0 | ||
|
|
There was a problem hiding this comment.
I think we can remove this from the intro section and perhaps have a new section on CI checks, where we can talk about this, --exclude and --group. WDYT?
| end | ||
| end | ||
|
|
||
| test "min transitive dependencies requires the compile-connected label" do |
There was a problem hiding this comment.
These are probably too many tests, they have a good amount of redundancy. For example, the one that checks --fail-above does not raise can be mixed with the ones that prints and so on.
This adds
--min-transitive-dependenciestomix xref graph --label compile-connected, as discussed below. The first version of this pull request changed--fail-abovefor stats; that part is gone.Today a compile-time dependency is compile-connected when the file it points to has at least one dependency. The new option raises that minimum, counting transitive dependencies, so compile-time dependencies on files with only a few dependencies can be left out:
The tests use these files:
bhas 4 transitive dependencies (a,c,dande) anddhas 1 (e), so:Some notes:
mix xref explain: all files reachable from the file, with any label.bhas 3 direct dependencies and is still listed with a minimum of 4--label compile-connectedand a value greater than 0, and raises otherwise--format stats --label compile-connectedalso uses it for its lists. Without the option nothing changes--format cycles, where compile-connected already means compile