Styler: Learning Formatting Conventions to Repair Checkstyle Errors.
Benjamin Loriot, Fernanda Madeiral, Martin Monperrus · arXiv (Cornell University) · 2019
Ensuring code formatting conventions is an essential aspect of modern software quality assurance, because it helps in code readability. In this paper, we present STYLER , a tool dedicated to fix formatting errors raised by Checkstyle, a highly configurable format checker for Java. To fix formatting errors in a given project, STYLER 1) learns fixes for self-generated errors according to the project-specific Checkstyle ruleset, based on token sequence fed into a LSTM neural network, and then 2) predicts fixes. In an empirical evaluation, we find that STYLER repairs 38% of 11,220 real Checkstyle errors mined from 70 GitHub projects. Moreover, we compare STYLER with the IntelliJ plugin CHECKSTYLE-IDEA and the machine learning-based code formatters NATURALIZE and CODEBUFF. We find that STYLER fixes errors from a more diverse set of Checkstyle rules (24 rules, compared to CHECKSTYLE-IDEA: 19; NATURALIZE : 20; C ODE B UFF: 17), and it uniquely repairs errors for two rules. Finally, STYLER generates small repairs, and once trained, it predicts repairs in seconds. The promising results suggest that STYLER can be used in IDEs and in Continuous Integration environments to repair Checkstyle errors.