Skip to content

Instantly share code, notes, and snippets.

@fernandospr
Created January 27, 2023 15:03
Show Gist options
  • Save fernandospr/2c3f4f6a28f6bd117e3e45e620b2b3a7 to your computer and use it in GitHub Desktop.
Save fernandospr/2c3f4f6a28f6bd117e3e45e620b2b3a7 to your computer and use it in GitHub Desktop.
Recursively looks for Request/Response Kotlin models that may have missing @SerializedName annotations
#!/bin/bash
if [ -z "$1" ]; then
echo "Recursively looks for Kotlin files having missing @SerializedName annotations."
echo
echo "Usage: $0 <directory to analyze>"
exit 1
fi
currentPath=$PWD
cd $1
files=`find $PWD -type f \( -name "*Response*.kt" -o -name "*Request*.kt" \)`
for file in $files
do
propertyCount=`cat $file | grep "val \|var " -c`
annotationCount=`cat $file | grep "SerializedName" -c`
if [ $propertyCount -ne $annotationCount ]; then
echo "$file may have missing @SerializedName annotations."
fi
done
cd $currentPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment