The tasks of clone detection and program refactoring have been widely researched, but the existing general methods and solutions are often not applicable in practice due to strict technical requirements and specific contexts of use. The large telecommunication company uses the interpreted programming language Lua to develop embedded systems. The limited memory size of these devices imposes limitations on the size of source code. In this work, we propose a solution for detection and automatic refactoring of clones with preservation of program semantics and source code structure to simplify the debugging process. Implementation of the solution in the build process reduces the size of Lua code downloaded to the network device by 5-7%.
Keywords: clone detection, refactoring, extract method, clone elimination, Lua, network devices