Politecnico di Torino (logo)

Research, implementation and analysis of source code metrics in Rust-Code-Analysis

Marco Ballario

Research, implementation and analysis of source code metrics in Rust-Code-Analysis.

Rel. Luca Ardito, Maurizio Morisio, Michele Valsesia. Politecnico di Torino, Corso di laurea magistrale in Ingegneria Informatica (Computer Engineering), 2022

PDF (Tesi_di_laurea) - Tesi
Licenza: Creative Commons Attribution Non-commercial No Derivatives.

Download (3MB) | Preview

Context: Software metrics are procedures to measure software processes, products, and resources. Source code metrics are a subset of software metrics to measure source code properties. Using these measures, developers can have a picture of the status of a codebase, identify potentially problematic parts in advance and improve the code during its evolution. Static code analysers are automated tools developed to analyse source code without executing it. These tools are particularly adapted to implement source code metrics and aim to be quick to give immediate feedback. Rust-Code-Analysis (RCA) is an open source static code analyser which computes source code metrics from an intermediate representation of a source code file: the Abstract Syntax Tree (AST). The tool can parse many different programming languages and generate metrics at various levels of granularity by dividing the source code into blocks called Spaces. RCA is a Rust library developed by Mozilla to support the Firefox browser development process. Anyone can contribute to its development and propose changes to its code. Objectives: This thesis has two main objectives. The first one consists of expanding Rust-Code-Analysis by adding support for new source code metrics. The library already supports eleven metrics for ten different programming languages. The second objective, instead, consists of studying the values produced by these new metrics for various repositories and then evaluating their results. In particular, we are interested in the significance of the measures, their relationships with the size of a codebase, and their possible thresholds. Method: We have started by selecting a set of metrics to implement in Rust-Code-Analysis from scientific articles and existing static analysis tools. The chosen metrics focus on three different aspects: the size of the codebase, object-oriented programming paradigm, and security. In parallel, we have introduced new features to the tool, adding some integration tests and the average of specific metrics to learn how the library works. Starting from the acquired knowledge, we have implemented the selected metrics for the Java language, making the necessary modifications to Rust-Code-Analysis. Each implementation includes an exhaustive set of unit tests and has been subjected to an accurate and severe review workflow before being accepted into the official repository. Using these metrics, we have measured several popular Java projects of various sizes and versions, reporting the obtained results in graphs. The results analysis has been conducted in two parts. In the first part, we have focused on the measures obtained from repositories of various sizes, pinning them to a specific version. For the second part, we have analysed the metrics values for several versions of the same codebase. By inspecting the measures and graphs, we have examined and discussed the behaviour of each metric from distinct perspectives. Conclusions: The work produced in this thesis consisted of the implementation of six new metrics for the Java language within Rust-code-analysis. Other contributors could also implement these new metrics for additional object-oriented languages since the project is open source. At last, we have shown the behaviour of these metrics in actively maintained repositories, specifying which could be their potential uses.

Relators: Luca Ardito, Maurizio Morisio, Michele Valsesia
Academic year: 2022/23
Publication type: Electronic
Number of Pages: 102
Corso di laurea: Corso di laurea magistrale in Ingegneria Informatica (Computer Engineering)
Classe di laurea: New organization > Master science > LM-32 - COMPUTER SYSTEMS ENGINEERING
Aziende collaboratrici: UNSPECIFIED
URI: http://webthesis.biblio.polito.it/id/eprint/24499
Modify record (reserved for operators) Modify record (reserved for operators)