# Quality Gate has passed while new code is not tested

**URL:** <https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076>\
**Category:** SonarQube Server / Community Build\
**Tags:** coverage\
**Created:** [April 22, 2021, 8:12am UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076 "2021-04-22T08:12:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Collignon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thomas_collignon/32/21438_2.png) [@Thomas\_Collignon](https://community.sonarsource.com/u/Thomas_Collignon)\
**Post date:** [April 22, 2021, 8:12am UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/1 "2021-04-22T08:12:29Z")

</div>

The Overview tab shows that quality gate has passed, while it should fail if _Coverage on New Code_ is \< 70%. The Metrics frame shows “_0 new lines to cover_” while lots of new lines have been added.

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

Going into the Measures tab, and into a file where untested code was added:

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

The new code is clearly identified as _Not covered by tests_ (as displayed when hovering on red bars).

Why doesn’t this new untested code fall into the category _New lines to cover_ ?  
What is missing here for the quality gate to fail ?

Using SonarQube version 7.9.5

---

<div class="post-metadata">

**Author:** ![Jeff\_Zapotoczny](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jeff_zapotoczny/32/2816_2.png) [@Jeff\_Zapotoczny](https://community.sonarsource.com/u/Jeff_Zapotoczny)\
**Post date:** [April 22, 2021, 2:57pm UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/2 "2021-04-22T14:57:14Z")

</div>

Hi @Thomas_Collignon, welcome to the SonarSource Community!

It looks like what you’re calling the new code isn’t actually considered new code by SonarQube. What do you see if you expand the “Size” measure in the Measures tab? Are any lines reported as new and does it match your expectation?

You may have a New Code Period setting that isn’t aligning well with your analysis usage.

---

<div class="post-metadata">

**Author:** ![Thomas\_Collignon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thomas_collignon/32/21438_2.png) [@Thomas\_Collignon](https://community.sonarsource.com/u/Thomas_Collignon)\
**Post date:** [April 23, 2021, 2:45pm UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/3 "2021-04-23T14:45:05Z")

</div>

Hi Jeff,

Size measure is zero. No new line to report.

I thought that what is considered as new code is simply the diff with the branch _master_, as specified at the top of the frame:

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

In case it’s linked I also have this warning:

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

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

---

<div class="post-metadata">

**Author:** ![Thomas\_Collignon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thomas_collignon/32/21438_2.png) [@Thomas\_Collignon](https://community.sonarsource.com/u/Thomas_Collignon)\
**Post date:** [May 2, 2021, 6:36am UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/4 "2021-05-02T06:36:26Z")

</div>

I also find in [the doc of short-lived branches](https://docs.sonarqube.org/7.9/branches/short-lived-branches/) that

> everything changed in the branch is new code

I would then expect my code to be considered as new code.

@Jeff_Zapotoczny

---

<div class="post-metadata">

**Author:** ![Jeff\_Zapotoczny](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jeff_zapotoczny/32/2816_2.png) [@Jeff\_Zapotoczny](https://community.sonarsource.com/u/Jeff_Zapotoczny)\
**Post date:** [May 3, 2021, 8:15pm UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/8 "2021-05-03T20:15:12Z")

</div>

Hi Thomas,

Can you clarify which edition of SonarQube you’re running? Looks like it’s Developer Edition possibly.

> [@Thomas\_Collignon](#):
>
> In case it’s linked I also have this warning:
> 
> ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/b/3/b3e1553922dfb646bce8e8885f59b23c148979fb.png)
> 
> ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/d/c/dc8f7b3bf569ca0bfa39b48a42130e83e32abfeb.png)

Now that we know it’s a short-lived branch or Pull Request branch being analyzed, yes, this warning can very much be related to your lack of new code. The state of the local checkout needs to cleanly contain the head revision for the branch (not be in any kind of preview merge state) and also contain the full ref for the target branch. Depending on your CI, it may be possible to specify the checkout behavior to include the ref or you can do it manually with something like:  
`git fetch --no-tags ${GIT_URL} +refs/heads/master:refs/remotes/origin/master`

---

<div class="post-metadata">

**Author:** ![Thomas\_Collignon](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/thomas_collignon/32/21438_2.png) [@Thomas\_Collignon](https://community.sonarsource.com/u/Thomas_Collignon)\
**Post date:** [May 4, 2021, 5:43am UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/10 "2021-05-04T05:43:39Z")

</div>

It’s _Community Edition Version 7.9.5 (build 38598)_.

Thanks for the help, I’ll contact the CI admin (company stuff).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [May 11, 2021, 8:50pm UTC](https://community.sonarsource.com/t/quality-gate-has-passed-while-new-code-is-not-tested/42076/13 "2021-05-11T20:50:11Z")

</div>

Closed on May 11, 2021, 8:50pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
