Syntax-driven duplicate-code detection
Syntaxí řízená detekce duplicitního kódu
diploma thesis (DEFENDED)

View/ Open
Permanent link
http://hdl.handle.net/20.500.11956/124432Identifiers
Study Information System: 218239
Collections
- Kvalifikační práce [11325]
Author
Advisor
Referee
Kopecký, Michal
Faculty / Institute
Faculty of Mathematics and Physics
Discipline
Software and Data Engineering
Department
Department of Software Engineering
Date of defense
16. 9. 2020
Publisher
Univerzita Karlova, Matematicko-fyzikální fakultaLanguage
English
Grade
Very good
Keywords (Czech)
detekce duplicitního kódu, syntaxí řízené porovnání, anotace abstraktních syntaktických stromůKeywords (English)
duplicate-code detection, syntax-driven comparison, abstract-syntax tree annotationDuplicitný kód sa vyskytuje v zdrojových súboroch z rôznych dôvodov. V mnohých prípadoch je motiváciou pre kopírovanie kódu lenivosť programátora, alebo pokus o použitie cudzieho zdrojového kódu. V priebehu rokov bolo vyvinutých niekoľko metód na detekciu duplicitného zdrojového kódu. Prístupy k problému sa líšia v spôsobe akým porovnávajú zdrojové súbory. Metódy založené na anlýze syntaktických vlastností kódu často používajú abstraktné syntaktické stromy. Skúmaním stromovej reprezentácie sú tieto metódy schopné odhaliť duplicitný kód, ktorý prešiel zmenami formátovania ako aj premenovaním identifikátorov. Fragmenty duplicitného kódu sú odhalené identifikovaním podstromov s rovnakým tvarom. Po nájdení podozrivých častí stromu nasleduje hlbšia analýza vlastností stromu za účelom odhalenia duplikátov. Ako súčasť tejto práce sme vyvinuli nástroj na detekciu duplicitného zdrojového kódu na základe porovnávania abstraktných syntaktických stromov.
Duplicate code occurs in source files for different reasons. In many cases the motivation for copying the code is laziness of a programmer, or an attempt to use an alien source code. Over the years, multiple methods for detection of the duplicate source code have been developed. Approaches vary in the ways they analyze the code, focusing on different representations of the program. Methods based on the analysis of the syntactic properties of the source code often use abstract syntax trees. By examining the tree representation instead of the textual representation of the code, these methods are able to detect duplicate code that underwent formatting changes as well as changes to the names of identifiers. Duplicate code fragments are discovered by identifying the subtrees of the same shape. After the suspicious parts of the tree are identified, further examination of AST properties determines to what extent the code was copied. In this work we develop a system for duplicate code detection based on AST comparison.