From d2d07421cad4a20778bf591e279358dd0442382e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 5 Jul 2013 22:42:06 +0200 Subject: [PATCH] tools: add check-imports.sh script Checks that `using` statements in src/*.cc are properly sorted and actually used. --- tools/check-imports.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 tools/check-imports.sh diff --git a/tools/check-imports.sh b/tools/check-imports.sh new file mode 100755 index 0000000000..54cba93d83 --- /dev/null +++ b/tools/check-imports.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +cd `dirname "$0"`/../ + +for FILE in src/*.cc; do + sed -rne 's/^using (\w+::\w+);$/\1/p' $FILE | sort -c || echo "in $FILE" +done + +for FILE in src/*.cc; do + for IMPORT in `sed -rne 's/^using (\w+)::(\w+);$/\2/p' $FILE`; do + if ! sed -re '/^using (\w+)::(\w+);$/d' $FILE | grep -q "$IMPORT"; then + echo "$IMPORT unused in $FILE" + fi + done +done