sounds like there is a “switched hot” = there is a constant hot wire connected to a switch and when switch is opened/off the power is disconnected other devices and circuits, likewise when the switch is closed/on the power to the fixture and the other devices turn on. As for the the the code regulations mentioned YES, THEY SHOULD be made compliant as per qualified electrician. He will be able to fix the switched hot like he was eating cake..