technomancy/slamhound

Removes require with no alias

Closed this issue · 2 comments

If a namespace is required (with no alias or refer etc) and used in a fully-qualified way to reference Vars, Slamhound still removes it.

Example:

(ns slamtest.core
  (:require [slamtest.aux]))

(defn foo [x]
    (slamtest.aux/helper x))

After Slamhound:

(ns slamtest.core)

(defn foo [x]
    (slamtest.aux/helper x))

This won't work since slamtest/aux is not loaded before it referenced.

I initially ran into this with a private function being used via full qualification but tested locally and repro'd with both private and public functions.

guns commented

Unfortunately, this is not something Slamhound can fix until we switch to a static analyzer (maybe):

https://github.com/technomancy/slamhound#fully-qualified-and-dynamically-resolved-vars

ATM I work around this by always using an alias. Sorry, but thanks for the report!

Fair enough. I'll update our code. I think we only do this in one place, maybe two.