Skip to content

Instantly share code, notes, and snippets.

@ehpc
Created August 3, 2022 11:21
Show Gist options
  • Save ehpc/6f628353d997733bb9446087629bb937 to your computer and use it in GitHub Desktop.
Save ehpc/6f628353d997733bb9446087629bb937 to your computer and use it in GitHub Desktop.
Get metric of how many `any`'s are there compared to line count for TypeScript codebase (in percents)
#!/bin/sh
# Calculates a metric of how many `any`'s are there compared to line count for TypeScript codebase (in percents)
# Basically we count all `any` occurences, then count all lines in the codebase, and lastly divide one by another
echo "scale = 4; $(find -name "*.ts?" -not -path "./node_modules/*" | xargs grep -o '\bany\b' | wc -l) * 100 / $(find -name "*.ts?" -not -path "./node_modules/*" | xargs wc -l | tail -1 | awk '{print $1}')" | bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment