Regarding avoiding copy-paste; I'm a JavaScript developer, and from time to time, I run `npx jsinspect src` in the root of my projects to detect copy-paste. The results are always interesting.
I've got slightly mixed feeling on copy-paste because sometimes it leads to lots of dependencies--some with conflicts--and you would have been better off writing if (s != null && !s.isEmpty()