In nearly all of the fifty states, there is an implied promise, read into residential leases, that the property will be suitable for its desired purpose. To renters, this means that the home will be suitable for inhabiting. This promise requires that the landlord maintain substantial compliance with any applicable building codes and make repairs as necessary.
The point of the warranty is not to oppress the landlord by requiring exact compliance with codes. Instead, it only requires substantial compliance, which means minor and temporary issues will not amount to a breach of that warranty, nor will they excuse the renter from paying full rent.
On the other hand, public policy and the implied warranty of habitability dictate that slumlords should not profit from maintaining uninhabitable property. A substantial departure from the building code, such as a lack of heat or running water, would justify the renter taking further action, such as withholding the rent or breaking the lease.
Should an apartment's condition fall below the minimum required by the local building code, there are a few legal remedies for an aggrieved tenant. The first is to request repairs from the landlord in writing. Should the landlord refuse or neglect to make the repairs, another step to consider is to report the landlord to your local building inspector.
If all else fails, there is also the possibility of withholding rent. A portion of the rent, equal to the diminution in value of the apartment from the code violation should be placed into a separate bank account. If the full amount of rent has been paid, a tenant might be able to recover part of the paid rent as overpayment due to the violations. Finally, if the landlord attempts to evict the tenant for nonpayment or underpayment of rent, the code violations will serve as a defense.