Skip to content

Instantly share code, notes, and snippets.

@motiejus
Created June 8, 2012 12:17
Show Gist options
  • Select an option

  • Save motiejus/2895328 to your computer and use it in GitHub Desktop.

Select an option

Save motiejus/2895328 to your computer and use it in GitHub Desktop.
Erlang record coupling analyzer
#!/bin/bash
ERLS=`find src apps -name '*.erl' 2>/dev/null`
HRLS=`find include -name '*.hrl' 2>/dev/null`
records=
for hrl in $HRLS; do
records+=$(grep -e '-record(' $hrl | perl -pe 's=-record\(([^,]+).*=\1=')
done
for record in $records; do
echo -n "#${record} | "
for erl in $ERLS; do
cnt=$(grep -E "^[^%]*#'?${record}'?" $erl | wc -l)
[[ $cnt != 0 ]] && echo -n "${erl},${cnt} "
done
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment