fabiodomingues/clj-depend

False violation when using :access-layers due to dependency on namespaces not defined in layers

Closed this issue · 0 comments

When using :access-layers you are generating violations due to dependency on namespaces not defined in the layers.

Test scenario that simulates this issue:

(testing "should return zero violations when a layer has namespaces that depend on another namespace that is not in any layer of the configuration"
    (is (= []
           (analyzer/analyze {:config                    {:layers {:a {:defined-by ".*\\.a\\..*", :accesses-layers #{:c :b}},
                                                                   :c {:defined-by ".*\\.c\\..*", :accesses-layers #{}}}}
                              :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}}}))))

Output:

({:dependency-layer     nil
  :dependency-namespace foo.b.bar
  :layer                :a
  :message              "\"foo.a.bar\" should not depend on \"foo.b.bar\" (layer \":a\" on \"\")"
  :namespace            foo.a.bar}
 {:dependency-layer     nil
  :dependency-namespace foo.b.bar
  :layer                :c
  :message              "\"foo.c.bar\" should not depend on \"foo.b.bar\" (layer \":c\" on \"\")"
  :namespace            foo.c.bar})