# STYLE-ANALYZER: fixing code style inconsistencies with interpretable   unsupervised algorithms

**Authors:** Vadim Markovtsev, Waren Long, Hugo Mougard, Konstantin Slavnov, Egor, Bulychev

arXiv: 1904.00935 · 2019-04-02

## TL;DR

STYLE-ANALYZER is an unsupervised, interpretable tool that automatically detects and fixes code style inconsistencies, adapting to each codebase using decision tree forests, thus reducing manual review effort.

## Contribution

It introduces a novel unsupervised approach with decision trees to automatically learn and fix code style violations, improving interpretability and adaptability over existing black-box ML methods.

## Key findings

- High precision in reproducing original code styles
- Effective in fixing real style mistakes
- Works well across multiple JavaScript projects

## Abstract

Source code reviews are manual, time-consuming, and expensive. Human involvement should be focused on analyzing the most relevant aspects of the program, such as logic and maintainability, rather than amending style, syntax, or formatting defects. Some tools with linting capabilities can format code automatically and report various stylistic violations for supported programming languages. They are based on rules written by domain experts, hence, their configuration is often tedious, and it is impractical for the given set of rules to cover all possible corner cases. Some machine learning-based solutions exist, but they remain uninterpretable black boxes. This paper introduces STYLE-ANALYZER, a new open source tool to automatically fix code formatting violations using the decision tree forest model which adapts to each codebase and is fully unsupervised. STYLE-ANALYZER is built on top of our novel assisted code review framework, Lookout. It accurately mines the formatting style of each analyzed Git repository and expresses the found format patterns with compact human-readable rules. STYLE-ANALYZER can then suggest style inconsistency fixes in the form of code review comments. We evaluate the output quality and practical relevance of STYLE-ANALYZER by demonstrating that it can reproduce the original style with high precision, measured on 19 popular JavaScript projects, and by showing that it yields promising results in fixing real style mistakes. STYLE-ANALYZER includes a web application to visualize how the rules are triggered. We release STYLE-ANALYZER as a reusable and extendable open source software package on GitHub for the benefit of the community.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1904.00935/full.md

## Figures

33 figures with captions in the complete paper: https://tomesphere.com/paper/1904.00935/full.md

## References

24 references — full list in the complete paper: https://tomesphere.com/paper/1904.00935/full.md

---
Source: https://tomesphere.com/paper/1904.00935