I don't know of any code violation, but it seems a poor design, IMO. I'd personally prefer a 20-amp circuit running to the dishwasher and disposer switch, leaving the dishwasher with unswitched power.

Dave