Section 352 CrPC itself provides exceptions where a judicial officer may act as both complainant and judge, as listed in Sections 344, 345, 349 and 350.
Superintendent of Police, Tiruvannamalai District, Tiruvannamalai v. Judicial Magistrate Court, Cheyyar, Tiruvannamalai District2015 AIR(Mad) 298para 20