# Quality gate mark old code issue as new

**URL:** <https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502>\
**Category:** SonarQube Cloud\
**Tags:** sonarqube-cloud\
**Created:** [September 2, 2020, 1:56pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502 "2020-09-02T13:56:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roy\_Sela](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roy_sela/32/7041_2.png) [@Roy\_Sela](https://community.sonarsource.com/u/Roy_Sela)\
**Post date:** [September 2, 2020, 1:56pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/1 "2020-09-02T13:56:26Z")

</div>

SonarCloud java 8 repo, all of the sudden quality failing on a problem that was not identified (or even related) in the PR which was just merged…

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/0/0ec2303d95bf6dc6245449e247937435bd00284e.png)

Focusing on the 2 “new code” bugs, it looks as if the code is new (23 minutes ago):

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/1/1f822d121676ea7fb23b59cd305d31c09244f731.png)

But drilling-in, this is old code:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/b06cf2b14af0f65845620744cc7c114d8e611940.png)

Top part is from December 2019:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/9/9b62e280723ec5e33c0cde56fc5597e4fa6977c9.png)

Bottom part the same:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/2/2e28fc11559564fb256a8750a3267a006ff8bfce.png)

Also both issues are false positives as we do check for null, but this is less relevant for the timing issue:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/8/81a01725700d9cb78e23de0523476e904b2b484f.png)

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 2, 2020, 4:42pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/2 "2020-09-02T16:42:11Z")

</div>

Hi,

Your issue has multiple locations. What are the dates on these other locations? For an issue like this, it’s quite possible that a “new” NPE is raised on old code because something _leading up_ to the issue (those 2ndary locations) has changed.

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![Roy\_Sela](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roy_sela/32/7041_2.png) [@Roy\_Sela](https://community.sonarsource.com/u/Roy_Sela)\
**Post date:** [September 2, 2020, 4:50pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/3 "2020-09-02T16:50:51Z")

</div>

First issue only had 3 locations, all listed in the screenshots I provided and none is new as can be seen.

Second issue has 5 locations, again none are new:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/f/ff6aa6dd3ec75bb0a7090fb749a3228f04a16105.png)

Specifically the first two:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/c/c8a18d16f344e78e9495d3332a58d6a850b799a2.png)

The third:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/b701bb595e2f3366454988e1dc68d3406b416de4.png)

Last two:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/bfffe3b81d636eee7c55614416b215b609ee4190.png)

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [September 2, 2020, 5:04pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/4 "2020-09-02T17:04:58Z")

</div>

Hi,

Then the other option is that what the analyzer _was_ considering the null-check was recently _removed_. Unfortunately, we have no way of indicating this. It can also be a problem in PR analysis that contains deletions. Hopefully this makes sense…

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![Roy\_Sela](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roy_sela/32/7041_2.png) [@Roy\_Sela](https://community.sonarsource.com/u/Roy_Sela)\
**Post date:** [September 2, 2020, 5:21pm UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/5 "2020-09-02T17:21:00Z")

</div>

The thing is, the PR merge that lead for this build did not even relate to this file:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/e/e93ad4f6832525a34fb66fe5085cf5cabfdc621c.png)

Also the PR itself passed the quality gate just before the merge:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/5/5ab1446a5f4573b5a70d9bae0c68d69c85cc3e9c.png)

And in any case, this file was last touched 3 days ago (no deletion):

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/b3fd096bf8ce4edec8b32d2fe8472bd285e6adc6.png)

So I don’t see any reason for this file to suddenly produce issues…

---

<div class="post-metadata">

**Author:** ![Roy\_Sela](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roy_sela/32/7041_2.png) [@Roy\_Sela](https://community.sonarsource.com/u/Roy_Sela)\
**Post date:** [September 6, 2020, 10:22am UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/7 "2020-09-06T10:22:56Z")

</div>

Any update? I’m asking as I just saw a similar issue on another repository.

Again Sonar is marking a code issue as new:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/a/a64d717d8991a95a7950bb568037f32f7b3a4139.png)

But it’s really not - new new code mark:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/8/8b9162051bcb3f0d77daa5bce97378ec18d31040.png)

And specifically for these lines:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/3/382156ca010b400449fe555f0e57b17791e24bfa.png)

And specifically for these lines:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/6/6756d081959dc28c8b9749833139632e70369105.png)

Needless to say, these issues just appeared out of nowhere, they were not listed 4 days ago in the previous build and this file is not even related to the content that invoked this build.

---

<div class="post-metadata">

**Author:** ![Roy\_Sela](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/roy_sela/32/7041_2.png) [@Roy\_Sela](https://community.sonarsource.com/u/Roy_Sela)\
**Post date:** [September 6, 2020, 10:24am UTC](https://community.sonarsource.com/t/quality-gate-mark-old-code-issue-as-new/30502/8 "2020-09-06T10:24:58Z")

</div>

BTW, just like last time - these two issues are false positive… same rule and same error as before.
