DEV Community

Discussion on: 6 Questions to ask yourself before copy-pasting code

Collapse
 
hnrtns profile image
Henri Tanskanen • Edited

I know this post isn't really about legal issues, but as a lawyer, I just can't resist pointing out that before copy-pasting code, you should also ask yourself:

Am I infringing anyone's copyright?

If you have a company policy or guideline that covers this, the simplest scenario would be to ensure you are in line with that and have done the actions required, where any.

Otherwise, you should always keep in mind that copy-pasting any non-trivial amount of code (assume a low threshold) from somewhere else and incorporating it into yours usually means you are either creating a derivative work of or reproducing (making a copy of) a work protected by copyright. This requires a permission of some kind from the copyright holder(s) of that piece of code. Usually, you would rely on a standardized license by the rights holder(s) for this, often an open-source one. Just remember that even the most permissive licenses usually carry additional requirements of some kind, often related to retaining or adding the license text or notice and the original copyright statement as part of your source code and/or documentation, or something similar.

Copy-pasting code, perhaps the most important (legal) questions you should be able to answer are:

  • What's the license for the code you're copying?
  • Are you able to fulfill the requirements of that license? This includes making sure it's compatible with the requirements of the license(s) you are using, i.e., that you are able to fulfill the requirements of all applicable licenses at the same time without creating a conflict. With common permissive licenses (e.g. MIT, BSD, Apache-2.0) this isn't usually a problem, but you should be more careful with copyleft-style licenses such as different variants and versions of GPL and MPL, which may require you to adopt the same license for your code.

Some useful resources off the top of my head:

Collapse
 
paulasantamaria profile image
Paula Santamaría

Thanks for the info, Henri!