Type-2 Code Clone Detection for Dockerfiles
Tomoaki Tsuru, Tasuku Nakagawa, Shinsuke Matsumoto, Yoshiki Higo, Shinji Kusumoto · 2021
This paper proposes a Type-2 code clone detection technique for Dockerfiles. Docker is a plat-form for realizing containerized virtual environments that has been attracting significant attention as a technology support for server infrastructures. In Docker, the procedure to realize a virtual environment is de-scribed in the form of a source code called a Dockerfile. Therefore, code clones such as repetitions and duplications with similar structures are often included. In this study, we propose a Type-2 code clone detection technique for deriving patterns within Dockerfiles. More specifically, our technique detects code clones by normalizing tokens properly, separating Docker syntax and shell syntax, and then adopting suffix array algorithm for each syntax. We conducted application experiments on approximately 5,000 Dockerfiles available on GitHub and found that our technique could detect Type-2 code clones with a high precision. Our technique derived some patterns in Dockerfiles, such as those used for building a new distribution on a container.