Expand clj-depend beyond cross-layer dependency analysis
fabiodomingues opened this issue · 1 comments
clj-depend was initially created to be a namespace analyzer for the Clojure community, being a tool to help control dependencies between namespaces, which can be separate namespaces or namespaces belonging to a layer.
By priority, layer dependency analysis was the first feature, and it's working fine.
However, the delay in releasing other functionalities for layer-independent namespace analysis is causing people to look for alternative ways in tools other than clj-depend, which is a risk for the project in the long term.
Option 1)
{:source-paths #{,,,}
:layers {,,,}
:rules [{:doc "An integration test should not depend on ..."
:defined-by "integration\\..*"
:should-not-depend-on #{'matcher-combinators.test
"(?!integration).*-test"}}
{:doc "An unit test should not depend on state-flow"
:defined-by "(?!integration).*-test"
:should-not-depend-on #{"state-flow.*"}}
{:doc "Specific namespace should not depend on ..."
:namespaces #{'foo.x}
:should-not-depend-on #{'bar.x}}]}
- Does it make sense to make the
should-not-depend-on
attribute accept a single value, collection, or set? - Is
should-not-depend-on
the best name for this attribute? Or isnot-allowed
better?
Assumptions:
- Namespace if it's a symbol
- Regex if it's a string
Option 2)
{:source-paths #{,,,}
:layers {,,,}
:rules [{:doc "An integration test should not depend on...."
:rule ["integration\\..*" :should-not-depend-on "matcher-combinators.test"]}]}
Compose the parts of the rule into a vector.
Option 3)
{:source-paths #{,,,}
:layers {,,,}
:rules [{:doc "An integration test should not depend on...."
:left "integration\\..*"
:condition :should-not-depend-on
:right 'matcher-combinators.test}]}
For lack of better names, I am representing left and right, as parts of an equation: x (left) should not depend on y (right)
.
Regardless of the option, clj-depend currently generates messages in the following format:
"foo.x" should not depend on "bar.x" (layer ":a" on ":b")
In this case where we don't have layers, the message will probably look like this (without the layer information at the end):
"foo.x" should not depend on "bar.x"
We also have the option of including text from the doc attribute to give more context:
"foo.x" should not depend on "bar.x" (An unit test should not depend on state-flow)
It may soon be interesting to address a way for people to be able to customize their own violation messages, so I created an issue #52 to discuss this issue separately.