google / google/error-prone

CanIgnoreReturnValueSuggester should not warn on Swing cell renderer implementations

Open
#3,433 0 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

ErrorProne 2.15.0 introduced `CanIgnoreReturnValueSuggester`.

Most warnings it raised were legit, but one very common case which wasn't was on Swing cell renderers:
* `ListCellRenderer#getListCellRendererComponent`
* `TableCellRenderer#getTableCellRendererComponent`
* `TreeCellRenderer#getTreeCellRendererComponent`

Quite commonly, a Swing cell renderer is implemented by subclassing a component, so many implementations do return `this`. However, the implementation is free to change at any point as the method contract does not say that it must return `this` (and some implementations do not), so there is no guarantee that ignoring the return value is safe. Rather, I'd like to annotate these with something else saying that you can't ignore it, but I don't know whether such an annotation exists.

We suppressed all the warnings, but this could be a reasonable case for not getting the warning in the first place.

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.