Created
June 23, 2015 23:54
-
-
Save jacquelinekay/292d010fbdfe67254ad7 to your computer and use it in GitHub Desktop.
Bash script to produce a markdown table with real-time safety static code analysis results
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
#!/usr/bin/env bash | |
# run this in ros2_ws/src/ros2 | |
# space-delimited list of real-time unsafe keywords | |
keywords="new delete malloc free std::cout std::vector std::map std::list throw" | |
# Get list of libraries checked | |
libraries=$(ls --hide examples --hide system_tests -p | grep "/") | |
echo "key |" $libraries | sed 's#/ # | #g' | |
cols=$(echo "$libraries" | grep -c "/") | |
echo "---"`printf "%${cols}s" | sed 's/ /|---/g'` | |
rm -f output | |
for word in $keywords; do | |
echo ">>>> $word" >> output | |
data=$(grep -rI $word --include=\*.{cpp,c,hpp,h}* --exclude output --exclude-dir examples --exclude-dir system_tests .) | |
outline="$word " | |
# Count occurrences of libraries | |
for library in $libraries; do | |
outline+="| `echo "$data" | grep -c $library`" | |
done | |
echo $outline | |
# Dump output to file | |
echo "$data" >> output | |
echo "" >> output | |
echo "" >> output | |
done | |
# Now echo the totals | |
outline="total " | |
for library in $libraries; do | |
outline+="| `grep -c $library output`" | |
done | |
echo $outline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment