Java squid:S2583 with kotlin nullable object


(Tyler Thrailkill) #1

A kotlin data object with a nullable parameter results in false positive on null checks

SonarQube Version: 6.7.5.38563
SonarAnalyzer (Java)

data class OnlineSalesDetailsView(
        ...
        val loanPurpose: LoanPurpose?,
        ...
)
        if (!optOsView.isPresent()) {
            return Optional.empty();
        }

        OnlineSalesDetailsView osView = optOsView.get();

        // It is possible loan amount is null (pre-approval flow)
        if(osView.getLoanAmount() == null) { // error here
            return Optional.empty();
        }