# Sonarqube is raising false-positive NPE

**URL:** <https://community.sonarsource.com/t/sonarqube-is-raising-false-positive-npe/4515>\
**Category:** Report False-positive / False-negative...\
**Tags:** java\
**Created:** [November 22, 2018, 5:21pm UTC](https://community.sonarsource.com/t/sonarqube-is-raising-false-positive-npe/4515 "2018-11-22T17:21:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamil](https://avatars.discourse-cdn.com/v4/letter/k/94ad74/32.png) [@kamil](https://community.sonarsource.com/u/kamil)\
**Post date:** [November 22, 2018, 5:21pm UTC](https://community.sonarsource.com/t/sonarqube-is-raising-false-positive-npe/4515/1 "2018-11-22T17:21:31Z")

</div>

I have a code

```auto
final Comparator<Attachment> comparator = getComparator(sort);
if (nonNull(comparator)) {
	sort(comparator.reversed());
}

```

where `nonNull` is static import to the method:

```auto
public static boolean nonNull(final Object o) {
	return o != null;
}

```

And Sonarqube raises:  
`Null pointers should not be dereferenced` in line `sort(comparator.reversed());` while clearly NPE can not happen there

---

<div class="post-metadata">

**Author:** ![Lena](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/lena/32/66719_2.png) [@Lena](https://community.sonarsource.com/u/Lena)\
**Post date:** [July 5, 2019, 1:17pm UTC](https://community.sonarsource.com/t/sonarqube-is-raising-false-positive-npe/4515/2 "2019-07-05T13:17:26Z")

</div>

I expect that `nonNull` implementation is in the another file than the main code. Unfortunately that’s the current limitation we have for this rule. If you move `nonNull` in the file, FP should disappear.  
This problem can’t be fixed easily, so for now I suggest you to mark issue as FP in SonarQube UI.  
Anyway thanks for reporting it.
