Edit: On the other hand, what is so bad about citing your sources? There is a lot of products in use today that has an "endless" list of legal stuff for using other people's "stuff". If you have an iPhone, for instance, have a look at "Legal Notices" in Settings -> General -> "Legal Notices". Spotify: Help -> Show Licences.
I'd prefer for someone to directly copy and then cite the source vs. copying and trying to modify the code so it doesn't look like the source any more. If you copy something and cite the source, it's not really plagiarism any more, because you're not attempting to make it look like your original work.
Just as a note, copying things from stackoverlflow.com is perfectly safe, since everything you share there get Creative Commons Attribution Share Alike license
If you copy code, it can be "perfectly safe" from any copyright concerns and still be plagiarism.