No way to know which object in Repository is being used in scripts

I have tried that and chose to delete all unused objects. It turned out that it deleted all my objects even the ones that were used. Is this because of the way i declare objects in the scripts? I do not use TestObject objectName = new TestObject(objectID)

Instead i declare it this way.

String = ‘object ID’

WHen I would declare an obkect like this TestObject objectName = new TestObject(objectID)
my scripts would fail. so instead i declare them this way…String = ‘object ID’

Could this be the reason why its showing all objects in the unused object list?