by venantius

venantius / yagni

A Leiningen plugin for finding dead code

208 Stars 12 Forks Last release: almost 2 years ago (v0.1.7) Eclipse Public License 1.0 66 Commits 5 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


Build Status Dependency Status Clojars Project

Yagni - You Aren't Gonna Need It.

Yagni is a static code analyzer that helps you find unused code in your applications and libraries.

I've written a blog post describing Yagni in greater depth here.


No matter how it happens, sooner or later an application is going to end up with unused code. It's time to call Yagni, the exterminator.

Yagni works by identifying all of the interned vars and declared Java classes in the namespaces findable within your

, and then walking the forms of those vars and declarations.

As it walks the forms, it builds a graph of references to other vars and declarations. It then searches the graph from a set of entrypoints (by default your project's

method), and emits warnings for anything that it couldn't find in the graph's search.


Merge the following into your

{:user {:plugins [[venantius/yagni "0.1.7"]]}}


To have Yagni search for dead code, just run:

$ lein yagni


Yagni works by searching your codebase from an initial set of entrypoints. By default, Yagni assumes that the only entrypoint for your project is the one listed in your project.clj's

key. Obviously, this is only useful for applications and tools with CLI invocations.

As libraries, multi-main programs, and certain other types of projects either tend to have no

or many entrypoint methods, you can instead enumerate a list of entrypoints for your project in a
file in the root directory of your project. Feel free to take a look at the one in this project as an example.



lein yagni
on the sample project located here will emit the following output:
$ lein yagni
=================== WARNING: Parents ======================
== Could not find any references to the following vars. ===


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



In general, bug reports, fixes, and code cleanup are always appreciated. Feature requests are liable to be subject to a bit more discussion.

When filing issues, please include the following:

  • The operating system
  • The JDK version
  • The Leiningen version
  • The Clojure version
  • Any plugins and dependencies in your
    and your


Copyright © 2018 W. David Jarvis

Distributed under the Eclipse Public License, the same as Clojure.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.