Skip to content

Instantly share code, notes, and snippets.

@thiagocordeiro
Created November 26, 2021 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiagocordeiro/535feba34546cd4db8c0622a7e74f5bf to your computer and use it in GitHub Desktop.
Save thiagocordeiro/535feba34546cd4db8c0622a7e74f5bf to your computer and use it in GitHub Desktop.
check-file-size.sh
#!/bin/bash
echo "$(git ls-files | xargs cat | wc -l | xargs) Lines of code"
RESULT=$(wc -l $(git ls-files) | grep .php | grep -v "tests/" | awk '{ if ( $1 > 250 ) printf("%-6s | %s \n\r", $1, $2) }')
if [ -n "$RESULT" ]; then
awk 'BEGIN {s=sprintf("%131s","");gsub(/ /,"-",s);print s}'
echo "LINE | FILE"
awk 'BEGIN {s=sprintf("%131s","");gsub(/ /,"-",s);print s}'
echo $RESULT
awk 'BEGIN {s=sprintf("%131s","");gsub(/ /,"-",s);print s}'
echo "There are files with more then 250 lines"
awk 'BEGIN {s=sprintf("%131s","");gsub(/ /,"-",s);print s}'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment