A judge's job is not to apply the law to the letter, but to the spirit. They are not going to throw their hands up when a tenant is kept out of their unit, no matter what the landlord might have decided to sneak in into the rental agreement: the law is there to protect the tenant.
If the contract said “and you agree to give me your life savings” somewhere in the fine print that doesn’t make it enforceable.
It’s like half the point of having these things in law so landlords can’t put them in lease agreements.
Actually, the law is pretty explicit about that. And judges have a decent amount of leeway to determine if a landlord has been acting in bad faith.
If you are a landlord, and you have a bad tenant, you are definitely not interested in any "shenanigans" if you have any amount of rationality. All you care about is getting a bad tenant out as soon as possible, and the last thing you'd want is for a judge to delay the process, or penalize you, because they have found that you haven't complied with the law.