Google Summer of Code 2022 Final Report
Project - Practice What You Preach
Vyom YadavStudent -
Nick Mancuso, Roman Ivanov, Richard Veach, Baratali Izmailov, Pavel BludovMentors -
Practice What You Preach
Description: There are a lot of static analysis tools for Java language, it is not a problem to activate them in the project and get a report on what to improve. The problem is the next step, how to start fixing reported problems gradually and at the same time keep focusing on feature delivery as before and not let anybody else contribute new violations while the team is fixing old problems.
Finding time to fix old problems is a hard but possible task. Not all engineers agree to spend time on this so usually small part of engineers start doing this to let others see the benefits of this and later the amount of involved engineers is growing. The most frustrating for engineers fact is that while resolving such violations some other contributors create violations (most of the time unintentionally). Fixing problems after code is merged to a common code base is a few times harder when doing it at the time of initial implementation.
The goal of this project is to find ways to activate more analysis tools in our code and find a way to enforce more strict rules step by step to not interfere with other engineers, and not let other engineers contribute new violations if some rules are enforced in a certain part of code.
Exact tasks with the goal above in mind:
- Move Teamcity inspections config to be based on a configuration file in a code, and explain all suppression for inspections in separate Javadoc tag to be explicit about why a violation is false-positive or won’t fix.
- Enforce 0 violations by Error-Prone over our code.
- Use of ArchUnit in UT for design verification over classes and between classes.
- Extend the usage of pitest to activate all mutators and cover all survivals by tests, and resolve all existing suppressions.
- Activate the Checker Framework and fix violations from it.
Implementation and Work Done during GSoC
- You can find all my work in the Pull Requests submitted to Checkstyle.
PIT is a state-of-the-art mutation testing system, providing gold standard test coverage for Java and the JVM. It’s fast, scalable, and integrates with modern test and build tooling.
Checkstyle is using pitest for quite some time. This summer the goal was to make a new suppression system for pitest as pitest natively doesn’t support suppressing individual suppressions.
After the creation of a new system, all existing suppressions were killed (except the indentation package).
To utilize the full potential of pitest, all the available pitest mutators were activated and new suppressions related to those were added. To reduce the time pitest took to execute, the CDG Accelerator plugin was also integrated which improved the performance.
- Killing Surviving mutations(67)
- New suppression system
- Activating ALL mutator group(27)
- Include CDG Accelerator Plugin to boost pitest performance
Idea Inspections version was updated to the latest in all Checkstyle repos, and all the related violations were killed or suppressed with justification.
Error-Prone was successfully integrated with the codebase. Groovy script was developed to execute Error Prone and check the error-prone report. A custom suppression model was built for Error Prone and all the new violations were placed in the suppressions list. GitHub Action was also created to run the check in CI.
ArchUnit is a free, simple, and extensible library for checking the architecture of your Java code using any plain Java unit test framework. That is, ArchUnit can check dependencies between packages and classes, layers and slices, check for cyclic dependencies, and more. It does so by analyzing given Java bytecode, importing all classes into a Java code structure.
ArchUnit was already used in Checkstyle at a very basic level. New and powerful ArchUnit tests were created that support adding in-code suppressions.
The Checker Framework enhances Java’s type system to make it more powerful and useful. This lets software developers detect and prevent errors in their Java programs. The Checker Framework includes compiler plug-ins (“checkers”) that find bugs or verify their absence.
Selected Checkers were integrated with the project, custom suppression system was built for suppressing new violations.
I would like to thank the Checkstyle team for giving me this amazing opportunity. I am immensely grateful to my mentors Nick Mancuso, Roman Ivanov, Richard Veach, Baratali Izmailov, and Pavel Bludov who have been supporting me in successfully completing my project. I am looking forward to keep on contributing to this wonderful product to the best of my abilities.