Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Feature: getViewOrThrow() in onAttachView() Lint-Check #160

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

jreehuis
Copy link

Description

This PR implements a new lint check to detect a direct or transitive call of TiPresenter.getViewOrThrow() in TiPresenter.onAttachView().

In TiPresenter.onAttachView() the view of the presenter might still be null. So calling TiPresenter.getViewOrThrow() would throw an exception during runtime.
In production this usually crashes the App. This behaviour is correct to detect the issue later on.

With this lint check the issue can be easily detected already during development.

Merge Information

Merge after #158 as this PR uses the Lint Check implementation of #158 as foundation.

@StefMa StefMa changed the base branch from master to feature/composition September 24, 2018 13:03
@StefMa StefMa changed the base branch from feature/composition to master September 24, 2018 13:03
@StefMa
Copy link
Contributor

StefMa commented Sep 24, 2018

In TiPresenter.onAttachView() the view of the presenter might still be null.

How can this happen? 🤔

So calling TiPresenter.getViewOrThrow() would throw an exception during runtime.

Why should someone call getViewOrThrow() instead of using the given View from the method?

Do we need to update the annotation here - when its possible to have a nullable View?
https://github.com/grandcentrix/ThirtyInch/blob/d761dbe800d935cd24a2e813ffd08ccdc4dddf61/thirtyinch/src/main/java/net/grandcentrix/thirtyinch/TiPresenter.java#L507

@passsy
Copy link
Contributor

passsy commented Sep 24, 2018

getViewOrThrow() never returns null in onAttachView.

This lint warning could hint to use the parameter view instead of getViewOrThrow()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

4 participants