简体   繁体   English

SonarQube:新代码的质量门覆盖范围

[英]SonarQube: quality gate coverage on new code

The scenario below is not working for me. 下面的情况不适用于我。

I performed two analysis t1 and t2 as described below 我执行了如下的两个分析t1和t2

t1: Code with 13.6% coverage is analysed and sent to SonarQube server. t1:分析覆盖率为13.6%的代码并将其发送到SonarQube服务器。 Here I am using /d:sonar.projectDate=2016-11-24 as parameter to the scanner. 在这里,我使用/d:sonar.projectDate=2016-11-24作为扫描仪的参数。 It is 61 lines of code in t1. t1中有61行代码。

在此处输入图片说明

t2: Removed the date parameter. t2:删除了date参数。 Added new code without coverage and also added some duplicated lines. 添加了没有覆盖范围的新代码,还添加了一些重复的行。 It is 158 lines of code in t2. t2中有158行代码。 Coverage dropped to 3.8%. 覆盖率下降到3.8%。 Meaning that lots of code was introduced without the expected coverage. 这意味着在没有预期的覆盖范围的情况下引入了许多代码。

在此处输入图片说明

Questions: 问题:

  1. Why is my quality gate still not failing? 为什么我的质量门仍然没有失败? I am using default quality gate on a local instance. 我在本地实例上使用默认质量门。 Anything less then 80% should fail the quality gate. 低于80%的质量都不能通过质量检验。
  2. I see some other posts where people say that SCM should be enabled for this to work. 我看到其他一些帖子,人们说应该启用SCM才能使其正常工作。 What would be the relation? 有什么关系? Does anybody know how this coverage on new code is really calculated? 有人知道如何计算新代码的覆盖率吗?
  3. If I enable "common-cs:InsufficientLineCoverage" then the quality gate fail. 如果启用“ common-cs:InsufficientLineCoverage”,则质量门将失败。 But it is not related to the thresold that exists on the quality gate, it will follow the thresold of the rule which by default is 65%. 但这与质量门上存在的阈值无关,它将遵循规则的阈值,默认情况下为65%。

Context where it happens: 发生情况的上下文:

  1. Local instance with Default Profile and Quality Gates 具有默认配置文件和质量门的本地实例
  2. SonarQube 6.1 SonarQube 6.1
  3. Scanner 2.2.0.24 扫描仪2.2.0.24
  4. C# Plugin 5.5.0.479 C#插件5.5.0.479
  • to be able to determine what is new code, SonarQube relies on the SCM (commit date) information provided 为了确定什么是新代码,SonarQube依靠提供的SCM(提交日期)信息
  • the sonar.projectDate parameter is used to rewrite the history of a project to have an evolution of issues created at different point of times sonar.projectDate参数用于重写项目的历史记录,以解决在不同时间点产生的问题的演变
  • if you cannot use an SCM plugin (why not?), then change your Quality Gate to fail if the overall coverage is lower than 80%. 如果您不能使用SCM插件 (为什么不使用),那么如果总覆盖率低于80%,则将Quality Gate更改为失败。 The Quality Gate will then fail as long as the project coverage is lower than 80% 只要项目覆盖率低于80%,质量门就会失败

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 针对新代码覆盖范围的SonarQube质量门因未发现依赖于Java烘焙的代码而失败 - SonarQube quality gate on new code coverage fails for uncovered code that relies on things baked into Java Sonarqube优质门生皮覆盖率 - Sonarqube Quality Gate Hide Coverage 是否可以创建声纳质量门条件来赶上最新的声纳版本(6.7版)中代码覆盖率的降低? - Is it possible to create a sonarqube quality gate condition to catch reduction in the code coverage in latest sonarqube(Version 6.7)? 如何配置Sonarqube Quality Gate,以便每次代码覆盖率低于thresold值时发送电子邮件警报 - How to configure Sonarqube Quality Gate inorder to sent email alert everytime there is low code coverage than thresold value SonarQube 质量门怪癖 - SonarQube Quality Gate Quirk Sonarqube质量门配置 - Sonarqube quality gate configuration 如果新代码中的代码覆盖率低于整体代码,如何使 sonarqube 质量代码失败? - How to fail sonarqube quality code if code coverage in new code is less than overall code? 在没有新分析的情况下重新评估 Sonarqube 中的质量门 - Re-evaluate quality gate in Sonarqube without a new analysis 质量门周期(SonarQube 5.4) - Quality Gate periods (SonarQube 5.4) 如何在 SonarQube 上配置质量门 - How to configure Quality Gate on SonarQube
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM