Open thayannevls opened 1 year ago
I was analyzing your case, and I even wrote a test scenario to simulate this.
(deftest analyze-test-using-access-layers-and-accessed-by-layers
(testing "should return zero violations when there is a layer defined that is not accessed by any other but there is a layer that defines which accesses it"
(is (= []
(analyzer/analyze {:config {:layers {:a {:defined-by ".*\\.a\\..*"
:accessed-by-layers #{}}
:b {:defined-by ".*\\.b\\..*"
:accessed-by-layers #{:a}}
:c {:defined-by ".*\\.c\\..*"
:access-layers #{:b}}}}
:dependencies-by-namespace {'foo.a.bar #{'foo.c.bar 'foo.b.bar}
'foo.b.bar #{'foo.b.baz}
'foo.b.baz #{}
'foo.c.bar #{'foo.b.bar}}})))))
BTW, when writing the test scenario it seemed contradictory to have a config that defines that a layer should not be accessed by any other when in the same config there is another layer defined that can access it.
Mixing :accessed-by-layers
and :access-layers
can lead to confusion. It seems to make sense for clj-depend to validate when this occurs and alert the user to only use one form. Wdyt?
Hello! I'm developing two configurations using clj-depend, where I want one configuration know about layers of the another but not the other way around.
Imagine that this is configuration A:
And this is configuration B:
I don't want that config A knows about B, so it's not a option for me to add
:bar
inaccessed-by-layers
in:foo
.The thing is clj-depend throws a violation even though I defined
:accesses-layers #{:foo}
. I believe this happens because of this code:If you agree that it should not throw an error in this case, we could change to return true only if it's not accessible in any way: