I have several issues with the installation.
The NM ought to have terminated in a box,with a receptacle. There are a few reasons for this.
The first is that, by putting a cord cap on the NM, you're treating the NM as if it were nothing but an extension cord. We are not allowed to use such cords as a substitute for permanent wiring. Where we do use a cord, we are not allowed to have that cord pass through a wall or floor - even passing the cord through a hole in the cabinet to the area under the sink is kind of 'iffy.' (I know, it's often done ... but let's not get into debating the exact meaning of 'wall.')
Putting a cord cap on NM is a bad idea. The grip on the cord cap is essential for providing strain relief, and the connection will not pass the required tests. I can say this, as I have tried it, under lab conditions. The cable will work loose over time.
The idea of adding a cord and plug has been the matter of lively debate. at both other forums and at listing agencies. Personally, I think the debate is silly, and the listing agency folks have another concern that never comes up: that is, if you add a cord, in their eyes that makes it a 'portable' appliance, and their standards MIGHT differ a bit. There is also some concern whether the appliance is equipped to provide the cord with proper strain relief. For the most part, it's something I wouldn't lose any sleep over. In my view, the ability to easily and definitely disconnect the machine makes up for a lot of lesser sins.