google / google/error-prone

Adding or subtracting a number and itself

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

Description

Over a year ago, I ran a check over Google code for two patterns:
- `x - x`
- `(x + x) / 2` (but probably even `x + x` is suspicious)

Results are in internal CL 49788955. I see some of the same kinds of things you see for `x == x` (e.g., `foo1.getX() - foo1.getX()` instead of `foo1.getX() - foo2.getX()`). I also see some people using bad date APIs that require January = 0, for which they write `1 - 1` for January, `12 - 1` for December, etc. There may be other patterns where we wouldn't want to do this. Maybe we can just throw out anything with literals?

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.