Detecting code smells using artificial intelligence : a prototype
Virmajoki, Joonas (2020)
Diplomityö
Virmajoki, Joonas
2020
School of Engineering Science, Tietotekniikka
Kaikki oikeudet pidätetään.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi-fe2020092976199
https://urn.fi/URN:NBN:fi-fe2020092976199
Tiivistelmä
Artificial intelligence is one of the major subtleties of our time. Artificial intelligence is utilized in improving the quality of software projects and in applications themselves. Code smells are characteristics in the source code that indicate there is a deeper problem, and they are a long-term nuisance for developers. Code smells make it hard to maintain, reuse, and expand software. You can refactor your source code to get rid of code smells, but first you need to find code smells. In this thesis, I made a prototype for detecting code smells as well as presented its design and development. The prototype was implemented in the Python programming language, using machine learning, neural networks, and deep learning. Training and testing data were taken from the MLCQ code smell dataset, and non-smelly samples were collected from GitHub’s open source Java repositories. The prototype was able to detect “long method” and “feature envy” code smells successfully, although only a relatively small amount of data was collected and used for the training of the prototype. Tekoäly on yksi aikamme merkittävistä hienouksista. Tekoälyä hyödynnetään ohjelmistoprojektien laadun parantamisessa ja myös itse sovelluksissa. Koodihajut ovat piirteitä lähdekoodissa, jotka indikoivat syvempää ongelmaa, ja ne ovat koodaajien pitkäaikainen riesa. Koodihajut vaikeuttavat ohjelmien ketterää ylläpidettävyyttä, uudelleenkäyttöä ja laajennettavuutta. Lähdekoodia refaktoroimalla voi päästä koodihajuista eroon, mutta ensiksi koodihajut täytyy löytää. Tutkimuksessa tehtiin prototyyppi koodihajujen havaitsemiseen sekä esiteltiin sen suunnittelu ja kehitys. Prototyyppi toteutettiin Python-ohjelmointikielellä, käyttäen koneoppimista, neuroverkkoja ja syväoppimista. Opetus- ja testidata otettiin MLCQ-koodihajuaineistosta, sekä lisäksi dataa kerättiin GitHubin avoimen lähdekoodin Java-kielen ohjelmavarastoista. Prototyyppi onnistui havaitsemaan onnistuneesti ”long method” ja ”feature envy” koodihajuja, vaikka dataa kerättiin ja käytettiin vain suhteellisen vähän prototyypin opettamiseen.