elasticsearch/elasticsearch — pull request #3902 by spinscale (2013-10-13 12:07:12+00:00)
Title: Added missing builder.endObject calls

After closing #3878 it came to me, that we might have other code snippets of missing or too much `builder.endObject()` / `builder.startObject()` methods (same for arrays), so I wrote this kind of hacky shell script

```sh
#/bin/bash
for x in Object Array ; do

start="\.start$x"
end="\.end$x"

for i in $(ag -l "$start") ; do
startingCount=$(grep -c "$start" $i)
endingCount=$(grep -c "$end" $i)

if [ $startingCount -ne $endingCount ] ; then
echo "$i $x: start $startingCount end $endingCount"
fi
done

done
```

only found two other pieces of code and a couple of false positives.

I am thinking if we could automate this by doing something similar as the `forbidden-api` maven module does and parse the source itself (to prevent false positives).

Anyone having experience with that?