The trouble with a code violation is that it's between the owner of the dwelling and the city.
The owner or tenant can rent you a closet and you would be stuck with it since you signed the contract accepting it.
Your only way out without penalty (loss of deposit, lawsuit, etc) is to call the city (or county) code enforcement agency and ask for an inspection.
If the enforcement agency cites the owner and tells you that you can't live in that room anymore, you are free to leave and seek the return of your deposit and any unearned rent (from your leave date forward).

