From feb46495ebba27980fd234ef0fe09ee88f87723c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 28 Sep 2017 11:53:11 +0200 Subject: check_java_packages : imporve output --- check_java_packages | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/check_java_packages b/check_java_packages index 1b9b5f8..d12f4fb 100755 --- a/check_java_packages +++ b/check_java_packages @@ -13,9 +13,10 @@ RED="\033[0;31m" BROWN="\033[0;33m" GREEN="\033[0;32m" -cd $TOPDIR -find . -name *.java | while read file; do - CORRECT=$(echo $file | sed 's/\.\///; s/\/\+/\./g; s/\.\w\+.java//') +find $TOPDIR -name *.java | while read file; +do + relpath=${file#${TOPDIR}} + CORRECT=$(echo $relpath | sed 's/\.\///; s/\/\+/\./g; s/\.\w\+.java//') N=$(cat $file | grep package | wc -l) if [ $N -gt 1 ]; then echo -e "$file : $BROWN more then 1 package directive$RESET"; @@ -33,7 +34,8 @@ find . -name *.java | while read file; do echo -e "$file : $RED$PACKAGE$RESET -> $GREEN$CORRECT$RESET"; touch $ERRORS fi - for IMPORT in $(cat $file | sed -n 's/import\s\+.*\.\(.*\);/\1/p'); do + for IMPORT in $(cat $file | sed -n 's/import\s\+.*\.\(.*\);/\1/p'); + do cat $file | grep $IMPORT | grep -qv import if [ $? -ne 0 ]; then echo -e "$file : import $RED$IMPORT$RESET might be useless"; -- cgit v1.1-2-g2b99