From a01bc890cd5376d53b6af1757908eba980d2eac3 Mon Sep 17 00:00:00 2001
From: Jan-Niclas Struewer <j.n.struewer@gmail.com>
Date: Fri, 3 Nov 2023 14:55:12 +0100
Subject: [PATCH] Added internal and external quality and changed position of
 documentation kpi

---
 .../dataprovider/kpi/enumeration/KpiKind.kt   | 57 +++++++++++++++++--
 .../dataprovider/kpi/service/KPIService.kt    | 23 ++++++--
 2 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt
index 920adcce..e09afe3b 100644
--- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt
+++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/enumeration/KpiKind.kt
@@ -174,15 +174,18 @@ enum class KpiKind {
             return KPITreeResponseDto(
                 value = value,
                 name = this.getName(),
-                description = "Used to approximate the the availability of documentation " +
-                    "based upon the availability of, e.g., a wiki, and/or a docs folder.",
+                description = "Used to assess compliance with a common development process and" +
+                    " certain software quality standards. For this purpose, it is checked whether " +
+                    "the repository provides documentation for the software made available. It should " +
+                    "be noted that this is not a sufficient criterion, since in this case only the existence " +
+                    "of certain folders or wiki pages is checked.",
                 children = children,
                 isEmpty = isEmpty
             )
         }
 
         override fun getName(): String {
-            return "Documentation Infrastructure"
+            return "Existence of Documentation Infrastructure"
         }
     },
 
@@ -209,6 +212,50 @@ enum class KpiKind {
             return "Commit Signature Ratio"
         }
     },
+    INTERNAL_QUALITY {
+        override fun toViewModel(
+            value: Int,
+            children: List<KPITreeChildResponseDto>,
+            isEmpty: Boolean
+        ): KPITreeResponseDto {
+            return KPITreeResponseDto(
+                value = value,
+                name = this.getName(),
+                description = "Assesses software quality from a developer perspective" +
+                    " and includes metrics for code quality, maintainability, readability and testability.",
+                children = children,
+                isEmpty = isEmpty,
+                order = 3
+            )
+        }
+
+        override fun getName(): String {
+            return "Internal Quality"
+        }
+    },
+    EXTERNAL_QUALITY {
+        override fun toViewModel(
+            value: Int,
+            children: List<KPITreeChildResponseDto>,
+            isEmpty: Boolean
+        ): KPITreeResponseDto {
+            return KPITreeResponseDto(
+                value = value,
+                name = this.getName(),
+                description = "Assesses the software quality from the user's perspective " +
+                    "and includes metrics for the fulfillment of functional requirements, user-friendliness, " +
+                    "reliability and performance." +
+                    "has context menu",
+                children = children,
+                isEmpty = isEmpty,
+                order = 3
+            )
+        }
+
+        override fun getName(): String {
+            return "External Quality"
+        }
+    },
     PROCESS_COMPLIANCE {
         override fun toViewModel(
             value: Int,
@@ -223,7 +270,7 @@ enum class KpiKind {
                     " compared with common development standards to enable an assessment.",
                 children = children,
                 isEmpty = isEmpty,
-                order = 4
+                order = 5
             )
         }
 
@@ -246,7 +293,7 @@ enum class KpiKind {
                     "about the software development process within the repository.",
                 children = children,
                 isEmpty = isEmpty,
-                order = 3
+                order = 4
             )
         }
 
diff --git a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt
index cfe145a5..f0db4f59 100644
--- a/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt
+++ b/src/main/kotlin/de/fraunhofer/iem/dataprovider/kpi/service/KPIService.kt
@@ -224,7 +224,7 @@ class KPIService(
             kind = KpiKind.PROCESS_TRANSPARENCY,
             calculationStrategy = AggregationKPICalculationStrategy()
         )
-        processTransparencyKPI.addChildKPI(documentationKpi, 0.5)
+        processComplianceKPI.addChildKPI(documentationKpi, 0.5)
         processTransparencyKPI.addChildKPI(signedCommitsRatioKPI, 0.5)
 
         val securityKPI = KpiCalculationDto(
@@ -232,6 +232,19 @@ class KPIService(
             calculationStrategy = AggregationKPICalculationStrategy()
         )
 
+        val internalQuality = KpiCalculationDto(
+            kind = KpiKind.INTERNAL_QUALITY,
+            calculationStrategy = AggregationKPICalculationStrategy()
+        )
+
+        val externalQuality = KpiCalculationDto(
+            kind = KpiKind.EXTERNAL_QUALITY,
+            calculationStrategy = AggregationKPICalculationStrategy()
+        )
+
+        externalQuality.addChildKPI(documentationKpi, 1.0)
+        internalQuality.addChildKPI(documentationKpi, 1.0)
+
         val maximalDependencyVulnerabilityKPI = KpiCalculationDto(
             kind = KpiKind.MAXIMAL_VULNERABILITY,
             calculationStrategy = MaximumKPICalculationStrategy()
@@ -262,9 +275,11 @@ class KPIService(
             calculationStrategy = AggregationKPICalculationStrategy(),
         )
 
-        rootKPI.addChildKPI(processTransparencyKPI, 0.25)
-        rootKPI.addChildKPI(processComplianceKPI, 0.25)
-        rootKPI.addChildKPI(securityKPI, 0.5)
+        rootKPI.addChildKPI(processTransparencyKPI, 0.1)
+        rootKPI.addChildKPI(processComplianceKPI, 0.1)
+        rootKPI.addChildKPI(internalQuality, 0.15)
+        rootKPI.addChildKPI(externalQuality, 0.25)
+        rootKPI.addChildKPI(securityKPI, 0.4)
         return rootKPI
     }
 
-- 
GitLab