Does this violate electrical code? (UF run plugged into GFCI to use smart outlet)
It does violate the NEC (assuming that you are in the US and the NEC applies to you). UF cable is not designed to connect to portable cord devices, portable cord devices are not designed to accept UF cable. Article 110.3(B) states: "Listed or labeled equipment
shall be installed and used in accordance with any instructions included in the listing or labeling." You will not find any instructions with the listing or labeling saying you can do this, ergo you cannot.