Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jsigee87
Created April 26, 2020 23:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsigee87/e78a80d7c1595efb9854d003abdb3ab7 to your computer and use it in GitHub Desktop.
Save jsigee87/e78a80d7c1595efb9854d003abdb3ab7 to your computer and use it in GitHub Desktop.
Script to find todo and fixme statements
#!/usr/bin/env bash
# Who am I
######################################################################
MYFILENAME="todo-linter.sh"
if [ $# -eq 0 ] || [ $# -gt 1 ];
then
echo "Usage:"
echo " bash ${MYFILENAME} [file or filepath]"
echo "You may pass a single file or a filepath. The script will recursively check subdirectories."
exit 1
fi
search_path=$1
keywords="TODO|FIXME"
# 1. Find all files ending with .py or .sh excepting .env/ directories and
# print their contents.
# 2. For all of the contents, grep for the keyword in a case insensitive manner, using
# the options listed.
# 3. Pipe into perl and insert the warning command.
######################################################################
find "${search_path}" \( -name "*.py" -or -name ".sh" \) -not -path "*.env*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching --ignore-case --no-messages "($keywords).*\$" | perl -p -e "s/($keywords)/ warning: \$1/i"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment