Created
January 21, 2014 10:32
-
-
Save jesperronn/8537714 to your computer and use it in GitHub Desktop.
Duplicate java class finder Finds java classes with same name and counts occurrences
This file contains 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
# Find all java classes in tree. (including auto-generated classes in 'target' folders: | |
find . -name "*.java" | xargs egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1 | |
# Use git (faster). | |
#Ignores any auto-generated classes since they are typically inside ignored 'target' folders | |
git grep --extended-regexp --no-index "class [A-Z]\w+" | egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1 | |
#example output: | |
find . -name "*.java" | xargs egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1 | |
6 HeightGroup | |
6 LengthGroup | |
6 MeasureGroup | |
6 Price | |
6 WeightGroup | |
7 Adapter1 | |
8 SOAPExceptionBean | |
10 FaultMessage | |
12 Location | |
55 Factory | |
63 ObjectFactory | |
git grep --extended-regexp --no-index "class [A-Z]\w+" | egrep -o "class [A-Z]\w+" | awk '{print $2}' | sort | uniq -c | sort -n | grep -v 1 | |
3 Main | |
3 UnitTestDataCreator | |
4 DataTypeConverter | |
6 Location | |
6 ObjectFactory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment