Last active
January 29, 2018 18:10
-
-
Save 89luca89/37930d89082d48441cd6fa42d1bd9bea to your computer and use it in GitHub Desktop.
Simple code analyzer, using PMD and Zenity for a little gui. I'm using it with Vim but outputs to file so compatible with any tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TITLE="Analyze the code" | |
TEXT="Choose your rules (can be multiple)" | |
FILENAME=/tmp/pmd-$(date "+%F-%H-%M").log | |
declare -a RULES=("android" | |
"basic" | |
"braces" | |
"codesize" | |
"design" | |
"finalizers" | |
"imports" | |
"junit" | |
"logging-java" | |
"naming" | |
"optimizations" | |
"strictexception" | |
"typeresolution" | |
"unusedcode") | |
SEL_RULES=$(zenity --list --multiple --title="$TITLE" --text="$TEXT" --width=640 --height=640 --column=Rules ${RULES[@]} 2>/dev/null) | |
IFS='|' read -r -a rules <<<$(echo $SEL_RULES) | |
if [ ! -z $1 ]; then | |
DIR=$1 | |
else | |
DIR=$(pwd) | |
fi | |
while test "$DIR" != "/"; do | |
for m in GNUmakefile makefile Makefile gradlew Gradle; do | |
if [ -f "${DIR}/${m}" ]; then | |
echo "Using ${m} from ${DIR}" >/dev/stderr | |
echo -e "Executing the subsequent analysis: "${rules[@]}"\n\n" >$FILENAME | |
for rule in ${rules[@]}; do | |
echo "Running $rule" | |
echo -e "$rule \n\n" >>$FILENAME | |
$HOME/Programs/pmd*/bin/pmd.sh $DIR text $rule >>$FILENAME | |
echo -e "\n\n" >>$FILENAME | |
done | |
echo "$FILENAME" | |
cat $FILENAME | |
exit 0 | |
fi | |
done | |
DIR=$(dirname "${DIR}") | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment