Skip to content

Instantly share code, notes, and snippets.

@opqdonut
Created March 9, 2021 13:42
Show Gist options
  • Save opqdonut/f5078e62aac2325d9c8fd989d46feb91 to your computer and use it in GitHub Desktop.
Save opqdonut/f5078e62aac2325d9c8fd989d46feb91 to your computer and use it in GitHub Desktop.
Finding the longest functions in a clojure codebase
# via awk, assuming everything with a ( in column 0 is a definition:
awk '/^\(/ {print c, f, s; f=FILENAME; s=$0; c=0} {c++} END {print c, FILENAME, s}' **/*.clj **/*.cljs **/*.cljc | sort -rn | head
# or, more accurately via the clj-kondo linter
clj-kondo --config '{:output {:analysis true :format :json}}' --lint src --lint test | jq -r '.analysis ["var-definitions"] | .[] | ((.["end-row"] - .row) | tostring) + " " + .ns + "/" + .name ' | sort -rn | head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment