google / google/error-prone

Warn when injecting more than one of the exact same binding

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

Description

We had this code:
```java
@Inject public ItsAThing(@App Context context, //
Thing thing, //
@Named(SOMETHING) Foo foo, //
@Named(OTHER_THING) Bar bar,
Hello hello,
Blah blah,
Fizz fizz,
Buzz buzz,
@Aaaaa Aaaaaaa aaaaa,
@App Context app) {
```
which has a hard to spot bug. We're injecting `@App Context` twice as the first and last parameters. This happened organically over years.

Since these could potentially be unscoped bindings, having two isn't 100% of the time incorrect. That case is so infrequent that I would like it to be a build error. I'd be happy if it was merely a warning that I could then promote to error in error-prone.

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.