A staggering amount of buildings are also NOT built to code. My smoke detector failed and isn't getting replaced for a whole week. My heater makes scraping noises every time it starts and maintainence thinks it's normal. Smack in the middle of Silicon Valley.
But this is the best of what I could afford. It's decent. It's clean. Everything else I saw at my budget was worse. One apartment I saw was $2400 for a 1-bedroom and had the toilet paper holder was bolted to the wall right above a red hot heating element recessed in the wall with a grill. Needless to say I didn't rent there.
Want an apartment that is built to code? It'll cost you $3000 or more.