Skip to content

Instantly share code, notes, and snippets.

@Vyom-Yadav
Last active August 14, 2024 12:21
Show Gist options
  • Save Vyom-Yadav/a61273a6eb40bcf136f1d0c559e9b6ab to your computer and use it in GitHub Desktop.
Save Vyom-Yadav/a61273a6eb40bcf136f1d0c559e9b6ab to your computer and use it in GitHub Desktop.
GSoC 2022 Final Report

Google Summer of Code 2022 Final Report

Project - Practice What You Preach

Student - Vyom Yadav

Organisation - Checkstyle

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:

  1. 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.
  2. Enforce 0 violations by Error-Prone over our code.
  3. Use of ArchUnit in UT for design verification over classes and between classes.
  4. Extend the usage of pitest to activate all mutators and cover all survivals by tests, and resolve all existing suppressions.
  5. 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.

Pitest

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.

Pull Requests:

TeamCity Violations

Idea Inspections version was updated to the latest in all Checkstyle repos, and all the related violations were killed or suppressed with justification.

Pull Requests:

Error Prone

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.

Pull Request:

ArchUnit

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.

Pull Requests:

Checker Framework

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.

Pull Request:

Acknowledgments

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment