venantius/yagni

Functions calls without `require` are not tracked

Closed this issue · 6 comments

We have a function defined like this:

src/circle/config.clj:48:(defn commit-hooks?

And the two usages like this:

src/circle/http/builds.clj:266:  (when (circle.config/commit-hooks?)
src/circle/http/pull_requests.clj:64:      (when (circle.config/commit-hooks?)

yagni reports that circle.config/commit-hooks? is not called.

Huh, that's fascinating. Probably something in how I'm using resolve. I'll look into it.

Awesome. I ran YAGNI over the full Circleci code base today. This lead to a
bunch of false positives.

I'll look into the results some more tomorrow.

On Monday, July 20, 2015, Ursa americanus kermodei notifications@github.com
wrote:

Huh, that's fascinating. Probably something in how I'm using resolve.
I'll look into it.


Reply to this email directly or view it on GitHub
#31 (comment).

I tried replicating this with the following example:

(ns yagni-test.fullname)

(defn foo
  []
  true)

(defn bar?
  []
  (yagni-test.fullname/foo))
(ns yagni-test.fullname-2)

(defn baz
  []
  (yagni-test.fullname/bar?))

Output:

[ursa@ziz:yagni-test] 16:03:55 $ lein yagni
=================== WARNING: Parents ======================
==    Could not find any references to the following     ==
===========================================================

yagni-test.fullname-2/baz

================== WARNING: Children ======================
==   The following have references to them, but their    ==
==   parents do not.                                     ==
===========================================================

yagni-test.fullname/foo
yagni-test.fullname/bar?

Which seems to be the expected behavior.

You're sure that commit-hooks? isn't in the list of children?

Thanks for looking into this.

The commit-hooks? function is definitely in the parents section, under:

=================== WARNING: Parents ======================
==    Could not find any references to the following     ==
===========================================================

section. I don't get a children section - yagni seems to crash before then: the end of the output of the Parents looks like this:

circle.pallet.splunk/aws
circle.backend.git.error/bad-object?
circle.http.api/maybe-add-cors-header
circle.http.api/api1-user-token
Subprocess failed

I don't have time to try to build a repro-case I'm afraid. The call to commit-hooks? is from a fn called start-build-from-hook which calls (circle.config/commit-hooks? ...) fully-qualified. start-build-from-hook is called full qualified in another ns as (circle.http.builds/start-build-from-hook ...). That call is created in a def which is created by a macro that builds a HTTP route using lib-noir :) So teasing the code appary could be difficult I'm afraid.

Hmm. Well, Yagni isn't crashing in this case - it purposefully exits with a non-zero status code if it finds either parents or children; an actual crash would be accompanied by a stacktrace. It is interesting that there aren't any children, though.

So, some additional questions - is there anything special about start-build-from-hook? Does that function also show up in the list of parents? Is that the only place commit-hooks? is called from?

I'm assuming you're using the latest version of Yagni (0.1.3-SNAPSHOT) as downloaded and installed from GH here?

As I haven't been able to replicate this error and I haven't heard anything on this issue in some time, I'm going to close it. If you're able to create a small and reproducible test case I'm happy to return to it and try to figure out what's going on.