There is no way to do that (reliably) in an automated fashion. To do it properly, you need to read through the code line by line and look for problems. There is the Theme Check plugin which can pick out some simple (potential) problems though.