google / google/error-prone

Open source GoodTime checks

Open
#5,088 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

### Context

Google projects like Guava have `@SuppressWarnings("GoodTime")` in various places ([github search](https://github.com/search?q=repo%3Agoogle%2Fguava%20GoodTime&type=code), [sourcegraph search](https://sourcegraph.com/search?q=context:global+%40SuppressWarnings%28%22GoodTime%22%29+r:github.com/google/&patternType=keyword&sm=0)).

As I understand it from my time at Google, the GoodTime checks make working with time better in Java, and help devs avoid footguns. Things like:
- prefer using `java.time` over older libraries like Joda
- prefer using strongly typed `Instant` and `Duration` over weakly typed `int millis` or `int epochSeconds`
- use TimeSource instead of `Instant.now()` to allow testing with an externally-supplied fake clock/source
- many others I'm sure

### Issue

Are these GoodTime checks something that might be open sourced? I remember them fondly and wish they were running on my current codebases!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.