]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23343 Add impacts to regulatory report
authorOrlovAlexander <alexander.orlov@sonarsource.com>
Tue, 15 Oct 2024 12:09:21 +0000 (14:09 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 16 Oct 2024 20:03:02 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileComparison.java

index 41373d9c5a84cf2b007b152dd58b5c86ecd977db..d6350ed21077043b5a77ed1b8b216813776816b6 100644 (file)
     </collection>
   </resultMap>
 
+  <resultMap id="ruleResultMapImpactsOnly" type="org.sonar.db.rule.RuleDto" autoMapping="true">
+    <id property="uuid" column="r_uuid"/>
+    <collection property="defaultImpacts" column="rdi_softwareQuality" notNullColumn="rdi_softwareQuality" javaType="java.util.Set" ofType="Impact">
+     <result property="softwareQuality" column="rdi_softwareQuality"/>
+     <result property="severity" column="rdi_severity"/>
+    </collection>
+  </resultMap>
+
   <select id="selectEnabled" resultMap="ruleResultMap">
     select
       <include refid="selectJoinedTablesColumns"/>
     order by r.uuid
   </select>
 
-  <select id="selectByLanguage" parameterType="String" resultType="org.sonar.db.rule.RuleDto" fetchSize="${_scrollFetchSize}"
+  <select id="selectByLanguage" parameterType="String" resultMap="ruleResultMapImpactsOnly" fetchSize="${_scrollFetchSize}"
           resultSetType="FORWARD_ONLY">
     select
-      r.uuid as uuid,
+      rdi.rule_uuid as "rdi_ruleUuid",
+      rdi.software_quality as "rdi_softwareQuality",
+      rdi.severity as "rdi_severity",
+      r.uuid as r_uuid,
       <include refid="ruleColumns"/>
     from
       rules r
+    <include refid="leftOuterJoinRulesDefaultImpacts"/>
     where
       <include refid="conditionNotExternalRulesByLanguage" />
   </select>
index 42464c303e27470ec2b1b51bb95349b05b720384..6f1444f770e2c3c366033f6c6a4674bee91336a9 100644 (file)
@@ -99,7 +99,7 @@ public class QProfileComparison {
     }
   }
 
-  private static Map<SoftwareQuality, Severity> computeEffectiveImpactMap(RuleDto ruleDto, Map<SoftwareQuality, Severity> activeRuleImpacts) {
+  public static Map<SoftwareQuality, Severity> computeEffectiveImpactMap(RuleDto ruleDto, Map<SoftwareQuality, Severity> activeRuleImpacts) {
     Map<SoftwareQuality, Severity> impacts = ruleDto.getDefaultImpactsMap();
     impacts.replaceAll(activeRuleImpacts::getOrDefault);
     return impacts;