Skip to main content
QUICK REVIEW

[Paper Review] Sourcerer's Apprentice and the study of code snippet migration

Stephen Romansky, Cheng Chen|arXiv (Cornell University)|Jul 31, 2018
Software Engineering ResearchComputer Science35 references4 citations
TL;DR

The paper introduces Sourcerer’s Apprentice, a web service that detects code clone migration between StackOverflow and open-source projects like Python modules and documentation, revealing widespread relicensing and attribution violations. It finds that 68,491 Python 2.7 documentation clones on StackOverflow lack proper attribution and conflict with CC-BY-SA 3.0 licensing, exposing developers and companies to legal risks from improper reuse.

ABSTRACT

On the worldwide web, not only are webpages connected but source code is too. Software development is becoming more accessible to everyone and the licensing for software remains complicated. We need to know if software licenses are being maintained properly throughout their reuse and evolution. This motivated the development of the Sourcerer's Apprentice, a webservice that helps track clone relicensing, because software typically employ software licenses to describe how their software may be used and adapted. But most developers do not have the legal expertise to sort out license conflicts. In this paper we put the Apprentice to work on empirical studies that demonstrate there is much sharing between StackOverflow code and Python modules and Python documentation that violates the licensing of the original Python modules and documentation: software snippets shared through StackOverflow are often being relicensed improperly to CC-BY-SA 3.0 without maintaining the appropriate attribution. We show that many snippets on StackOverflow are inappropriately relicensed by StackOverflow users, jeopardizing the status of the software built by companies and developers who reuse StackOverflow snippets.

Motivation & Objective

  • To investigate whether code snippets shared on StackOverflow are being improperly relicensed and attributed when copied from open-source projects like Python.
  • To assess the bi-directional flow of code between StackOverflow and open-source software repositories, challenging the assumption of unidirectional propagation.
  • To develop a scalable web service that detects license-inconsistent code clones to help developers avoid legal risks from improper reuse.
  • To highlight the risks posed by missing attribution and incompatible licensing in widely used code snippets on community platforms.
  • To provide actionable recommendations for developers, StackOverflow, and open-source foundations to improve license compliance and attribution practices.

Proposed method

  • The authors extended SourcererCC, a state-of-the-art code clone detector, to enable large-scale, distributed clone detection across StackOverflow posts, Python 2.7 modules, and documentation.
  • They integrated Ninka, a license inference tool, with a recursive license inference mechanism to improve license detection accuracy across large code corpora.
  • The system employs asynchronous task parallelization and distributed data sharding to achieve horizontal scalability and reduce query response times.
  • Performance optimization was achieved through profiling and tuning of the indexing pipeline to amortize startup costs and improve index efficiency.
  • The web service supports four key use cases: detecting clones between StackOverflow and exercises, documentation and StackOverflow, within student assignments, and between software projects and broader codebases.
  • Empirical analysis was conducted using 1,000 popular pip packages and Python 2.7 documentation, with results validated via clone detection and license conflict analysis.

Experimental results

Research questions

  • RQ1To what extent are code snippets from Python modules and documentation being copied to StackOverflow without proper attribution or license compliance?
  • RQ2How do license conflicts arise when code is migrated from open-source projects to StackOverflow, particularly regarding CC-BY-SA 3.0 and MIT-licensed code?
  • RQ3Is the flow of code between StackOverflow and open-source projects unidirectional, or is there significant reverse propagation from open-source projects to StackOverflow?
  • RQ4What is the prevalence of missing attribution to the Python Software Foundation in cloned documentation snippets on StackOverflow?
  • RQ5How effective is the Sourcerer’s Apprentice web service in detecting license-inconsistent code clones at scale?

Key findings

  • 68,491 clones of Python 2.7 documentation on StackOverflow lack proper attribution to the Python Software Foundation, with only four potentially providing correct attribution.
  • 46,709 clones from MIT-licensed pip modules on StackOverflow conflict with the CC-BY-SA 3.0 license imposed by StackOverflow, creating license incompatibility.
  • The flow of code between StackOverflow and open-source projects is bi-directional, with significant code migration from open-source projects to StackOverflow, contrary to the assumption of unidirectional flow.
  • 66% of StackOverflow users are unaware of the CC-BY-SA 3.0 license applied to their code, increasing the risk of unintentional license violations.
  • The Sourcerer’s Apprentice web service successfully scales to detect large-scale clone and license conflicts through distributed indexing, parallelization, and performance optimization.
  • The study reveals that developers and companies relying on StackOverflow code snippets face legal risks due to missing attribution and incompatible relicensing, potentially invalidating their software distribution rights.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.