Skip to content

Commit

Permalink
First import
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulTaykalo committed Oct 20, 2017
1 parent efbcab5 commit 194e5e5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Empty file added README.md
Empty file.
32 changes: 32 additions & 0 deletions unused.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/zsh
echo 'Gathering functions'
grep -rRh 'func [[:alnum:]]*' **/*.swift > raw_functions.txt
cat raw_functions.txt | grep -v '@IBAction' > raw_without_action.txt

cat raw_without_action.txt | grep -rRoh 'func [[:alnum:]]*' | sort | uniq | grep -o '[[:alnum:]]*$' > functions.txt

FUNCTIONS_COUNT=`cat functions.txt | wc -l`
echo "There are ${FUNCTIONS_COUNT} potential functions found"

echo "Gathering usage information"
cat functions.txt | while read line
do
FOUND_ITEMS=`grep -r "$line" **/*.swift | wc -l`
if [ "1" -eq "$FOUND_ITEMS" ]; then
echo "$line $FOUND_ITEMS"
fi
done > usage.txt

FUNCTIONS_WIT_LOW_USAGE=`cat usage.txt | wc -l`
echo "There are ${FUNCTIONS_WIT_LOW_USAGE} potential functions to be deleted found"

cat usage.txt | sort -nk2 > sorted_usage.txt

echo "Gathering usage per each of them"
cat sorted_usage.txt | while read line
do
NAME=`echo $line | grep -o '[[:alnum:]]*'`
USAGES=`grep -rR -C 3 "$NAME" **/*.swift`
echo "---- $NAME ----"
echo "$USAGES"
done > delete_me.txt

0 comments on commit 194e5e5

Please sign in to comment.