Water heater replacement runs into trouble

Who must pay to fix code violations that home inspector missed?