Romex wire connected to standard male plug.

During an inspection of a living room, I came upon a Romex cable that was run from an on-the-wall switch box, wired to a standard male 3-prong plug, which was plugged into a standard receptacle. I tagged this in my report because the Romex was within 6-7 feet of the floor and wasn’t covered or enclosed in a raceway. I also cited the fact that Romex isn’t intended to be used as a flexible “extension” cable. Obviously, the switch box should have been hard-wired.

What I’m wondering is, is it an actual code violation to use Romex with male or female 3-prong plugs? I would have liked to have cited an actual code violation if one exists.

Also, if the Romex connection is, in fact, a code violation, then would it have been OK to run a regular flexible cord (in some kind of raceway) from the switch box, connected to the male 3-prong plug, and then plugged into the receptacle?

Thank you in advance to anyone who can help me.

I’m confused. Was the switch being fed from the receptacle and if so, what was the switch operating?
You’re right though, definitely the wrong application for NMC.

Sorry for the confusion. Yes, the switch was being fed from the receptacle. The switch was operational and was controlling a bank of track lights.