Google Summer of Code 2022 @ Robolectric

Google Summer of Code 2022 @ Robolectric

Google Summer of Code final work submission

Introduction

Robolectric uses error-prone to check the common code quality problems. Currently, there are many warnings/recommendations left to fix, my project was focused on fixing those problems to improve the Robolectric’s code quality. There are a significant number of error-prone warnings, and all of the noise generated from the warnings can obfuscate real compile errors in Robolectric code.

The other aspect of this project involves experimenting with writing parts of Robolectric in Kotlin. The Android ecosystem has transitioned to Kotlin-first, yet Robolectric has not adopted Kotlin at all. A great start is to convert many of Robolectric’s tests to be written in Kotlin to make them more concise and build out support for Kotlin in Robolectric’s build scripts.

Milestone 1

During this phase, I focused mainly on fixing the error-prone warnings, there are almost 25 unique warnings across 9 modules which I fixed with the help of mentors, not all the warnings were fixed by the end of phase 1, so it continued in phase 2 as well. Also, I've done the conversion from Java to Kotlin for utils module tests.

Milestone 2

During this phase, finished the work that was left in phase 1 where we fixed almost 99% of the warnings that we decided and migrated the tests for resource and plugin module as well (which we had to roll back later).

PRs merged

  • Error-prone and google format fix for annotation module: PR#7154
  • Bumped error-prone plugin version from 1.3.0 to 2.0.2: PR#7218
  • Change the top-level project name from parent to robolectric PR#7347
  • Eliminated AlmostJavadoc warnings across project PR#7354
  • Eliminated Byte buffer backing array warning: PR#7368
  • Eliminated Catch and print stack trace warning: PR#7370
  • Eliminated Bad import warning: PR#7373
  • Eliminated unused variable warning: PR#7374
  • Eliminated default charset warning: PR#7376
  • Suppressed do not call suggester warning: PR#7377
  • Eliminated empty catch warning: PR#7379
  • Eliminated Equals get class warning: PR#7381
  • Eliminated Inline me inliner warning: PR#7382
  • Eliminated InlineMeSuggester warning: PR#7386
  • Eliminated EmptyBlockTag warning: PR#7391
  • Eliminated InvalidInlineTag warning: PR#7392
  • Eliminated InvalidBlockTag warning: PR#7393
  • Eliminated JavaLangClash warning: PR#7394
  • Eliminated JavaUtilDate warning: PR#7395
  • Eliminated MissingSummary warning: PR#7399
  • Eliminated VariableNameSameAsType warning: PR#7401
  • Eliminated UnusedMethod warning: PR#7402
  • Eliminated UnnecessaryParentheses warning: PR#7403
  • Eliminated UnnecessaryLambda warning: PR#7404
  • Eliminated StringSplitter warning: PR#7405
  • Eliminated ThreadLocalUsage warning: PR#7406

PRs under discussion

Tests which is converted from Java to Kotlin PRs might get rolled back because the final artifact contains the Kotlin dependencies which might conflict with client applications. So currently, it is under discussion.

  • Test conversion for Scheduler test of utils module: PR#7235
  • Test conversion of Temp Directory test for utils module: PR#7236
  • Test conversion of Pref stats collector test of utils module: PR#7237
  • Test conversion of Plugin finder test for utils module: PR#7238
  • Test conversion of Service finder adapter test for utils module: PR#7239

Final outcome

Now, the console logs look a lot cleaner as compared to those previously filled with countless warnings which creates a lot of confusion when looking for a specific error.

Challenges faced

  1. Setting up a project on an M1 mac is a challenge on its own, because some libraries don't support mac out of the box, but later when I used Ubuntu everything just works magically.
  2. Understanding the big code initially is a bit intimidating, but slowly I get used to it.
  3. Following the famous code styles like Google Java format, and other linters to keep the code quality top-notch

Things I learned

  • Keeping patience because of different timezone, and people working on open source projects have other commitments as well. So, understanding that and how to work in that environment
  • Learning in-depth about most of the error-prone warnings and how to eliminate them.
  • Using git on the terminal and not just through the GUI as suggested by my mentor.

Thanks for reading!

Feel free to reach out to me.

Thanks to my awesome mentor utzcoz who answered all of my silly questions and guided me throughout the program.