Styler: Learning Formatting Conventions to Repair Checkstyle Violations
Authors:
- Benjamin LoriotBLBenjamin Loriot
- Fernanda MadeiralFMFernanda Madeiral
- Martin MonperrusMMMartin Monperrus
Preprint
Abstract
Ensuring the consistent usage of formatting conventions in software systems is an important aspect of modern software quality assurance. In this paper, we present Styler, a tool dedicated to fixing formatting rule violations raised by format checkers. Given a project, Styler first generates training data by injecting violations of the project-specific rules in violation-free source code files. Then, it learns fixes by encoding the training data into token sequences and feeding long short-term memory neural networks with them. Finally, it predicts fixes for real formatting violations with the trained models. Currently, Styler supports a single checker, Checkstyle, which is a highly configurable and popular format checker for Java. In an empirical evaluation, we found that Styler repairs 42% of 27,699 Checkstyle violations mined from 105 GitHub projects. Moreover, we compared Styler with the IntelliJ plugin CheckStyle-IDEA and the machine-learning-based code formatters Naturalize and CodeBuff. We found out that Styler fixes violations from a diverse set of Checkstyle rules (24/25 rules), generates small repairs, and predicts repairs in seconds once trained on a project. Through a manual analysis, we identified cases in which Styler does not succeed to generate correct repairs, which can guide further improvements in Styler. Finally, the results suggest that Styler can be used in development environments to repair Checkstyle violations for developers.Keywords
All Related Versions
This publication has 24 references indexed in Scilit:
- SpongeBugs: Automatically generating fix suggestions in response to static code analysis warningsJournal of Systems and Software, 2020
- C-3PR: A Bot for Fixing Static Analysis Violations via Pull Requests2020
- Style-Analyzer: Fixing Code Style Inconsistencies with Interpretable Unsupervised Algorithms2019
- Are Static Analysis Violations Really Fixed? A Closer Look at Realistic Usage of SonarQube2019
- Context is king: The developer perspective on the usage of static analysis tools2018
- How Open Source Projects Use Static Code Analysis Tools in Continuous Integration Pipelines2017
- Oops, My Tests Broke the Build: An Explorative Analysis of Travis CI with GitHub2017
- Analyzing the State of Static Analysis: A Large-Scale Evaluation in Open Source Software2016
- elytS edoCIEEE Software, 2011
- Using Static Analysis to Find BugsIEEE Software, 2008