From e6a26d74c17402deb1ba8d215e0710b2c1764065 Mon Sep 17 00:00:00 2001
From: Eddie Groh <groh@fortiss.org>
Date: Wed, 30 Aug 2023 16:12:23 +0200
Subject: [PATCH] YELLOW

Issue-Ref: 4310
Issue-Url: https://git.fortiss.org/af3/af3/-/issues/4310

Signed-off-by: Eddie Groh <groh@fortiss.org>
---
 org.fortiss.tooling.ext.quality.ui/.project   |  21 ++++++
 .../html/developer/.ratings                   |   1 +
 .../html/developer/documentation.html         |  13 ++++
 .../icons/library.png                         | Bin 675 -> 0 bytes
 .../icons/metric.png                          | Bin 0 -> 826 bytes
 org.fortiss.tooling.ext.quality.ui/plugin.xml |   2 +-
 .../fortiss/tooling/ext/quality/ui/.ratings   |   2 +
 .../ui/ModelQualityExtractionMenu.java        |  13 ++--
 .../quality/ui/ModelQualityUIActivator.java   |  20 +++++-
 .../tooling/ext/quality/ui/view/fx/.ratings   |   3 +
 .../ui/view/fx/IModelQualityViewPart.java     |   2 +-
 .../ui/view/fx/ModelQualityFXController.java  |  65 +++++++-----------
 .../ui/view/fx/ModelQualityFXViewPart.java    |   2 +-
 .../org/fortiss/tooling/ext/quality/.ratings  |   4 ++
 .../ext/quality/GraphMetricsProvider.java     |  24 +++----
 .../quality/HierarchicElementProvider.java    |  27 ++------
 .../tooling/ext/quality/IMetricProvider.java  |   6 +-
 .../fortiss/tooling/ext/quality/data/.ratings |   3 +
 .../ext/quality/data/MetricDataManager.java   |  14 ++--
 .../tooling/ext/quality/data/MetricKey.java   |  11 ++-
 .../ext/quality/data/MetricTreeNode.java      |  37 ++++------
 .../tooling/ext/quality/service/.ratings      |   2 +
 .../quality/service/IModelQualityService.java |   6 +-
 .../quality/service/ModelQualityService.java  |  50 +++++++++-----
 .../tooling/ext/quality/storage/.ratings      |   2 +
 .../ext/quality/storage/CSVFileWriter.java    |  16 +++--
 .../storage/ModelQualityStorageManager.java   |  14 ++--
 27 files changed, 208 insertions(+), 152 deletions(-)
 create mode 100644 org.fortiss.tooling.ext.quality.ui/html/developer/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality.ui/html/developer/documentation.html
 delete mode 100644 org.fortiss.tooling.ext.quality.ui/icons/library.png
 create mode 100644 org.fortiss.tooling.ext.quality.ui/icons/metric.png
 create mode 100644 org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/.ratings
 create mode 100644 org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/.ratings

diff --git a/org.fortiss.tooling.ext.quality.ui/.project b/org.fortiss.tooling.ext.quality.ui/.project
index 72f463be0..5ab5ccca9 100644
--- a/org.fortiss.tooling.ext.quality.ui/.project
+++ b/org.fortiss.tooling.ext.quality.ui/.project
@@ -5,6 +5,11 @@
 	<projects>
 	</projects>
 	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.systemfocus.tooling.emfgeneration.git.EcoreBuilderGIT</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 		<buildCommand>
 			<name>org.eclipse.jdt.core.javabuilder</name>
 			<arguments>
@@ -20,9 +25,25 @@
 			<arguments>
 			</arguments>
 		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.systemfocus.tooling.codereview.builder.CodeReviewBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.systemfocus.tooling.codereview.builder.RemoveWarningsBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.systemfocus.tooling.codereview.builder.GuidelinesCheckBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
 	</buildSpec>
 	<natures>
 		<nature>org.eclipse.pde.PluginNature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.systemfocus.tooling.codereview.nature.CodeReviewNature</nature>
 	</natures>
 </projectDescription>
diff --git a/org.fortiss.tooling.ext.quality.ui/html/developer/.ratings b/org.fortiss.tooling.ext.quality.ui/html/developer/.ratings
new file mode 100644
index 000000000..91f80958f
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality.ui/html/developer/.ratings
@@ -0,0 +1 @@
+documentation.html aaa534ab30ef337c5e7bc75d37490eb6a5a4edd1 YELLOW
diff --git a/org.fortiss.tooling.ext.quality.ui/html/developer/documentation.html b/org.fortiss.tooling.ext.quality.ui/html/developer/documentation.html
new file mode 100644
index 000000000..aaa534ab3
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality.ui/html/developer/documentation.html
@@ -0,0 +1,13 @@
+<html><body>
+<h1>Developer Documentation for <i>AF3 Model Quality</i> (org.fortiss.tooling.ext.quality.ui)</h1>
+
+<h2>Plugin description</h2>
+<p>This is the user interface part of the tooling.ext.quality plugin. It provides a simple view to display collected metrics</p>
+
+<h2>Package description</h2>
+<ul>
+<li><tt>quality.ui</tt>: main package with the UI plugin activator.</li>
+<li><tt>quality.ui.view.fx</tt>: implementation of quality library view (FX-based).</li>
+</ul>
+
+</body></html>
diff --git a/org.fortiss.tooling.ext.quality.ui/icons/library.png b/org.fortiss.tooling.ext.quality.ui/icons/library.png
deleted file mode 100644
index 3c63b714bc5d9b65e08f80b35ac8df1e1b5a7339..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 675
zcmV;U0$lxxP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00009a7bBm000id
z000id0mpBsWB>pHRY^oaR5*>Dlf6zGQ4oc{-Mh=$@-9D$EF@C7qo6U88&ZU4utc3S
zlu+gk(nX?%E**s>I%*`~DIkC&rNUUSKX*O%uJ@*~Q4}mi%2cBnoimy_XFTT|p67i6
zCV*vegh0bN_x<liFi&1yUQVMZT8I`AR#sL%FY3(+qVw}}k|d$kYSC)7h@uD)p(qN{
zG-YdR>)j#(Z+m<Dt5WLY#>U1<yWL(}US3X`&1SRFXav6Rdv#sA$z)O$MNxJ-oga^n
zk3aA3?jCM#Zl0#oX(LcdJ)fPOeMpjoMx%l6`)`KKZV)=>x^-Q5CzA<TmeKF`zXT%U
z-`?KRZnsI2gr%h=f*_!(Do#&N0odEyLn(!|7Gn%qmN6cW5fMKS5tZjTaU2tdA<j95
z!y$vg0OuS4M@L8W`+e5e*AWrQvZN>qL_`JFTC~<=S%y-ItE(%nudi8KTO*ER0Maz&
z<m7~%ogKQ}E?R5Kvcy`8UsV+%LZ0VjSw^qd!#T&n!2z94ht17R4i67;&e7}jD2f8D
zH6lV)RRqQuPejmK69fU)TCyx-I2<w>jfkR%hldBW){I6Ys;YV=FvfU+wN{m7iBbyB
z^9aKbYc1pPm^{xB5uTr)vDT93IrEigE2zL)8|HaVUDs4q#l^)1)>@8_k6(4Xyu8Hs
zeFlR8ySuw+t<hRztqlWXOsKU+DMcK|?C<Zhy1GgfMMP2bDyfK&rYZOL_ZVZCPNx`S
zLN5%%Z@}E97H|t6;;pd&p1j#NzMmEU1^$!7I_G|QbF=(!{08pwTb)pyzc2s*002ov
JPDHLkV1iQTFd+Z{

diff --git a/org.fortiss.tooling.ext.quality.ui/icons/metric.png b/org.fortiss.tooling.ext.quality.ui/icons/metric.png
new file mode 100644
index 0000000000000000000000000000000000000000..0822af9ca579b86080348b6520d12b0f93dab96c
GIT binary patch
literal 826
zcmV-A1I7G_P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV0004mX+uL$Nkc;*
zaB^>EX>4Tx04R}tkv&MmKpe$iTct%RB32L)$xxjvh>AFB6^c+H)C#RSm|Xe=O&XFE
z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx6k5c1aNLh~_a1le0DryARI_6oP&La)
zCE`LRyD9`<5yCLS=tr-_Onpuilkgm0_we!cF2=LG&;2>Nm7K`{pFljzbi*RvAfDc|
zbk6(45muBG;&b9LgDyz?$aUG}H_ioz{X8>bq*L?65n`dx#&R38qM;H`5l0nOqkMnH
zWrgz=XSG~q&3p0}hI87=GS_JiA%R6KL4*JqRg_SMg&3_GDJD|1ANTMNI)0H{GPz1%
z<XAujDkR4b{s+IiHS?1bZc;c7biUa3#|RMI1sXNm{yw(t#t9I32ClT0zfuQgK1r{&
zwCEAgvkhEaw={VVxZD8-o^;8O94SE4pU(sDXY@^3pzjvwT624A?&I_UNK;qI8{ps&
z7%foty2rai?Y;ebrrF;QP5N?}Yye`k00009a7bBm001r{001r{0eGc9b^rhX2XskI
zMF-~y9t{Bwu~=o|0000PbVXQnLvL+uWo~o;Lvm$dbY)~9cWHEJAV*0}P*;Ht7XSbO
zBuPX;R5;6}k}*!iKnz8nLykbPThJmZYC4X<Rp=-YNECEvJ1Wk=br3aKiA8~hO*WZK
zOfi#Th5%y0)!1^L|933>Hnwl{t8&f;aeQ)=<X4xsn*ogJQ9u-sKPYHg>mDj7`U7Bg
zIQDxE_1Yo=ssst&DmdLQlKc#)n+^h6Hn&h!Hp;w(yPds}++Coy*~c*dTGbtb-=IW0
zm|o9P!u<tHlMRcG6c~s5{1@!<6|_%2criJmii!l^tE!7Sq8-@BMJNrj%Vx{hG}Nlv
zI_WCuC3Zy-h=Rfd$~I5@JAet(CAQE#%>8P-xe1hQhN^h3gREPN`01Jeig{=n<~_H$
z&m_9U9@JY+0E;JA)IK<SGnsD+r-w29=r)Auf%1=d2T7}h8iZ&>3jhEB07*qoM6N<$
Ef~Iz3w*UYD

literal 0
HcmV?d00001

diff --git a/org.fortiss.tooling.ext.quality.ui/plugin.xml b/org.fortiss.tooling.ext.quality.ui/plugin.xml
index 69b3dfdaf..da353e822 100644
--- a/org.fortiss.tooling.ext.quality.ui/plugin.xml
+++ b/org.fortiss.tooling.ext.quality.ui/plugin.xml
@@ -12,7 +12,7 @@
          point="org.eclipse.ui.views">
       <view
             class="org.fortiss.tooling.ext.quality.ui.view.fx.ModelQualityFXViewPart"
-            icon="icons/library.png"
+            icon="icons/metric.png"
             id="org.fortiss.tooling.ext.quality.ui.metricsView"
             name="Metrics"
             restorable="true">
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/.ratings b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/.ratings
new file mode 100644
index 000000000..b156be9c8
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/.ratings
@@ -0,0 +1,2 @@
+ModelQualityExtractionMenu.java 87cdfa5d4f939cc9f21afc8d6361a2089f440f20 YELLOW
+ModelQualityUIActivator.java 47787eb293198014ba5a5a9b21d004a379117f5e YELLOW
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityExtractionMenu.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityExtractionMenu.java
index e260d8d38..87cdfa5d4 100644
--- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityExtractionMenu.java
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityExtractionMenu.java
@@ -1,7 +1,5 @@
-package org.fortiss.tooling.ext.quality.ui;
-
 /*-------------------------------------------------------------------------+
-| Copyright 2019 fortiss GmbH                                              |
+| Copyright 2023 fortiss GmbH                                              |
 |                                                                          |
 | Licensed under the Apache License, Version 2.0 (the "License");          |
 | you may not use this file except in compliance with the License.         |
@@ -15,6 +13,9 @@ package org.fortiss.tooling.ext.quality.ui;
 | See the License for the specific language governing permissions and      |
 | limitations under the License.                                           |
 +--------------------------------------------------------------------------*/
+
+package org.fortiss.tooling.ext.quality.ui;
+
 import static java.util.Arrays.asList;
 import static java.util.Collections.emptyList;
 import static org.fortiss.tooling.kernel.ui.service.IContextMenuService.BOTTOM_MOST_MENU_SECTION_ID;
@@ -34,7 +35,7 @@ import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
 import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
 
 /**
- * Crates a context menu entry to generate the for the selected
+ * Creates a context menu entry to extract metrics for the selected {@link FileProject}.
  * 
  * @author groh
  */
@@ -62,13 +63,13 @@ public class ModelQualityExtractionMenu implements IContextMenuContributor {
 
 	/** Returns the icon that is visible in the context menu for this entry. */
 	protected ImageDescriptor getActionIcon() {
-		return ModelQualityUIActivator.getImageDescriptor("icons/componentarchitecture.gif");
+		return ModelQualityUIActivator.getImageDescriptor("icons/metric.png");
 	}
 
 	/** Action for generating the set of . */
 	protected class MetricExtractionAction extends Action {
 
-		/** */
+		/** {@link FileProject} on which the action will be triggered. */
 		private final FileProject fp;
 
 		/** Constructor. */
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityUIActivator.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityUIActivator.java
index 2a6eea8fe..47787eb29 100644
--- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityUIActivator.java
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/ModelQualityUIActivator.java
@@ -1,3 +1,18 @@
+/*-------------------------------------------------------------------------+
+| Copyright 2023 fortiss GmbH                                              |
+|                                                                          |
+| Licensed under the Apache License, Version 2.0 (the "License");          |
+| you may not use this file except in compliance with the License.         |
+| You may obtain a copy of the License at                                  |
+|                                                                          |
+|    http://www.apache.org/licenses/LICENSE-2.0                            |
+|                                                                          |
+| Unless required by applicable law or agreed to in writing, software      |
+| distributed under the License is distributed on an "AS IS" BASIS,        |
+| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
+| See the License for the specific language governing permissions and      |
+| limitations under the License.                                           |
++--------------------------------------------------------------------------*/
 package org.fortiss.tooling.ext.quality.ui;
 
 import static org.eclipse.jface.resource.ResourceLocator.imageDescriptorFromBundle;
@@ -7,8 +22,9 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.osgi.framework.BundleContext;
 
 /**
+ * The activator class controls the plug-in life cycle.
+ * 
  * @author blaschke
- *
  */
 public class ModelQualityUIActivator extends Plugin {
 
@@ -36,7 +52,7 @@ public class ModelQualityUIActivator extends Plugin {
 	/**
 	 * Returns the shared instance.
 	 *
-	 * @return The shared instance of ModelQualityUIActivator
+	 * @return The shared instance of {@link ModelQualityUIActivator}
 	 */
 	public static ModelQualityUIActivator getDefault() {
 		return plugin;
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/.ratings b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/.ratings
new file mode 100644
index 000000000..5bbde6cd3
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/.ratings
@@ -0,0 +1,3 @@
+IModelQualityViewPart.java 708f8089645df12098ea67190805cce343045d2e YELLOW
+ModelQualityFXController.java 391dc121678e1741b8ee98f90de18996ba2c37b2 YELLOW
+ModelQualityFXViewPart.java 179abf18d6e3b6c844076620f53b43ac8a42c217 YELLOW
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/IModelQualityViewPart.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/IModelQualityViewPart.java
index f730a8d37..708f80896 100644
--- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/IModelQualityViewPart.java
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/IModelQualityViewPart.java
@@ -16,7 +16,7 @@
 package org.fortiss.tooling.ext.quality.ui.view.fx;
 
 /**
- * Interface for views displaying the Metrics view
+ * Interface for views displaying the Metrics view.
  *
  * @author groh
  */
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java
index a477b26f6..391dc1216 100644
--- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXController.java
@@ -61,6 +61,7 @@ import javafx.scene.chart.PieChart;
 import javafx.scene.chart.ScatterChart;
 import javafx.scene.chart.XYChart;
 import javafx.scene.control.ChoiceBox;
+import javafx.scene.control.Label;
 import javafx.scene.control.SplitPane;
 import javafx.scene.layout.BorderPane;
 
@@ -74,22 +75,19 @@ import javafx.scene.layout.BorderPane;
 public class ModelQualityFXController extends CompositeFXControllerBase<SplitPane, Node>
 		implements ISelectionListener {
 
-	/** The {@link IProjectRootElement} in which the selected element is contained in. */
-	private IProjectRootElement currentRootElement;
-
-	/** a choiceBox */
+	/** ChoiceBox for selecting the metric which shall be displayed. */
 	@FXML
 	private ChoiceBox<MetricKey> choiceBox;
 
-	/** The bottom {@link BorderPane} for the spiderchart */
+	/** The bottom {@link BorderPane} for the spider chart. */
 	@FXML
 	private BorderPane borderPane;
 
-	/** a pieChart */
+	/** PieChart displaying the metrics. */
 	@FXML
 	private PieChart pieChart;
 
-	/** a scatterChart */
+	/** A scatter chart for displaying metrics. */
 	@FXML
 	private ScatterChart<Number, Number> scatterChart;
 
@@ -106,8 +104,8 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
 	}
 
 	/**
-	 * The last IHierachicElement which the user has clicked. Might be null when no or invalid
-	 * Object is selected
+	 * The last {@link EObject} which the user has clicked. Might be null when no or an invalid
+	 * Object is selected.
 	 */
 	private EObject lastSelectedElement;
 
@@ -115,38 +113,32 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
 	@Override
 	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
 
+		// Invalidate last selection, so if no new selection is found the charts are cleared
+		lastSelectedElement = null;
+
 		ModelQualityService.getInstance();
-		var manager = ModelQualityService.metricDataManagerInstance;
-		if(manager == null) {
-			// topLabel.setText("No Metrics were available at " +
-			// timeFormat.format(LocalDateTime.now()));
-			return;
-		}
+		var manager = ModelQualityService.getInstance().getMetricDataManagerInstance();
 
 		EObject selected = checkAndPickFirst(selection, EObject.class);
 
 		if(selected == null) {
-			// topLabel.setText("Nothing selected");
+			updateCharts();
 			return;
 		}
 
-		if(selected instanceof IProjectRootElement) {
-			currentRootElement = (IProjectRootElement)selected;
-		} else {
-			currentRootElement = getFirstParentWithType(selected, IProjectRootElement.class);
-		}
+		IProjectRootElement currentRootElement =
+				selected instanceof IProjectRootElement ? (IProjectRootElement)selected
+						: getFirstParentWithType(selected, IProjectRootElement.class);
 
 		if(currentRootElement == null) {
-			// There was no root element for the selected element. (Usually should be the
-			// FileProject.) This is not displayed here.
-			// topLabel.setText("No root found");
+			updateCharts();
 			return;
 		}
 
-		var root_provider = manager.getRootNodes().get(currentRootElement);
+		var root_provider = manager.getRootNodesMap().get(currentRootElement);
 
 		if(root_provider == null) {
-			// topLabel.setText("No Metric found for this project, did you export metrics?");
+			updateCharts();
 			return;
 		}
 
@@ -155,25 +147,22 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
 	}
 
 	/**
-	 * Is triggered when the refresh button is pressed.
+	 * Is triggered when the choice box changes.
 	 */
 	public void onChoiceBoxChange() {
 		updateCharts();
 	}
 
-	/**
-	 * Updates the chart in the metric view
-	 */
+	/** Updates the chart in the metric view. */
 	private void updateCharts() {
 
 		if(lastSelectedElement != null) {
-			MetricDataManager manager = ModelQualityService.metricDataManagerInstance;
+			MetricDataManager manager =
+					ModelQualityService.getInstance().getMetricDataManagerInstance();
 			MetricTreeNode node = manager.getTreeNodeLookupTable().get(lastSelectedElement);
 
 			if(node != null) {
 
-				// topLabel.setText("Text");
-
 				Set<MetricKey> validKeys = new HashSet<>();
 				validKeys.addAll(node.getStoredDoubles().keySet());
 				validKeys.addAll(node.getStoredIntegers().keySet());
@@ -212,8 +201,6 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
 					scatterChart.getXAxis().setLabel("NUMBER_OF_TOTAL_LEAF_ELEMENTS");
 					scatterChart.getYAxis().setLabel("NUMBER_OF_TOTAL_CYCLOMATIC_COMPLEXITY");
 
-					// Create BubbleChart
-					// bubbleChart = new BubbleChart<>(xAxis, yAxis);
 					scatterChart.getData().clear();
 
 					for(var child : node.getChildren()) {
@@ -234,23 +221,21 @@ public class ModelQualityFXController extends CompositeFXControllerBase<SplitPan
 					// Return, otherwise the data will be cleared
 					return;
 				}
-
-			} else {
-				// topLabel.setText("Element not in metrics");
 			}
 		}
-		borderPane.setCenter(null);
+		borderPane.setCenter(new Label("No metrics available for this selection"));
 		pieChart.getData().clear();
 	}
 
 	/**
 	 * @param node
 	 *            of which the data will be visualized
+	 * @param key
+	 *            {@link MetricKey} of the data to visualize
 	 * @return {@link SpiderChartViewer} with the matching metrics
 	 */
 	private static SpiderChartViewer buildSpiderChart(MetricTreeNode node, MetricKey key) {
 		SpiderChart spiderChart = new SpiderChart();
-		// spiderChart.setTitle("Amount of Ports");
 		spiderChart.setLegendLabel("Legend");
 		ChartStyle chartStyle = new ChartStyle(true, true, true);
 
diff --git a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXViewPart.java b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXViewPart.java
index cb30f69cc..179abf18d 100644
--- a/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXViewPart.java
+++ b/org.fortiss.tooling.ext.quality.ui/src/org/fortiss/tooling/ext/quality/ui/view/fx/ModelQualityFXViewPart.java
@@ -40,7 +40,7 @@ public class ModelQualityFXViewPart extends AF3FXViewPart implements IModelQuali
 	}
 
 	/**
-	 * Returns the initialized {@link ModelQualityFXController} for the reuse
+	 * Returns the initialized {@link ModelQualityFXController} for the quality
 	 * version of the {@link AF3FXViewPart}.
 	 *
 	 * @return The view controller for the metrics view
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/.ratings b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/.ratings
new file mode 100644
index 000000000..f6e940178
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/.ratings
@@ -0,0 +1,4 @@
+AF3QualityActivator.java 353c3d99f423997e4e99a896b3c095fd77d81431 YELLOW
+GraphMetricsProvider.java 2d3fff61af2537bc5b10b3c210dc8e4b3ad49c1d YELLOW
+HierarchicElementProvider.java 3c114abd47ecc0d7da751c3f05c83fd49a30717b YELLOW
+IMetricProvider.java 5e3d0debc0f81ed4e6c7dbc0f8d0e55df1bfde39 YELLOW
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/GraphMetricsProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/GraphMetricsProvider.java
index bb73def50..2d3fff61a 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/GraphMetricsProvider.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/GraphMetricsProvider.java
@@ -36,15 +36,16 @@ import org.fortiss.tooling.ext.quality.data.MetricKey;
 import org.fortiss.tooling.kernel.utils.EcoreUtils;
 
 /**
+ * Supplies methods to compute certain graph metrics.
  * 
  * @author groh
  */
 public class GraphMetricsProvider {
 
 	/**
-	 * Creates a list of nodes contained in the graph centered around the provided element
+	 * Creates a list of nodes contained in the graph centered around the provided element.
 	 * It will contain all elements contained within the provided element as well as all elements
-	 * connected to the provided element
+	 * connected to the provided element.
 	 * 
 	 * @param scopeElement
 	 *            element defining the scope of the graph
@@ -54,9 +55,6 @@ public class GraphMetricsProvider {
 	 */
 	private static Set<IHierarchicElement> getLocalGraphView(IHierarchicElement scopeElement,
 			boolean recursively) {
-		// Create a view consisting of all nodes inside this element, as well as all elements
-		// connected to this element
-
 		// This ensures that elements inside this element communicating with elements outside
 		// this element are properly recognized
 		Set<IHierarchicElement> graphNodes = new HashSet<>();
@@ -83,7 +81,7 @@ public class GraphMetricsProvider {
 	}
 
 	/**
-	 * Get all leafs inside the provided element
+	 * Get all leafs inside the provided element.
 	 * 
 	 * @param element
 	 *            the element containing leafs
@@ -100,7 +98,7 @@ public class GraphMetricsProvider {
 
 	/**
 	 * Follows outgoing connections until the connector has no further outgoing connections and then
-	 * saves the owner of this connector to the provided list
+	 * saves the owner of this connector to the provided list.
 	 * 
 	 * @param connector
 	 *            starting point for search
@@ -124,8 +122,7 @@ public class GraphMetricsProvider {
 
 	/**
 	 * Follows incoming connections until the connector has no further incoming connections and
-	 * then
-	 * saves the owner of this connector to the provided list
+	 * then saves the owner of this connector to the provided list.
 	 * 
 	 * @param connector
 	 *            starting point for search
@@ -148,7 +145,7 @@ public class GraphMetricsProvider {
 	}
 
 	/**
-	 * Collects all neighbors regardless of the direction of connection
+	 * Collects all neighbors regardless of the direction of connection.
 	 * 
 	 * @param element
 	 *            of which the neighbors should be collected
@@ -156,6 +153,7 @@ public class GraphMetricsProvider {
 	 */
 	private static Set<IHierarchicElement> getUndirectedNeighbors(IHierarchicElement element) {
 		Set<IHierarchicElement> neighbors = new HashSet<>();
+
 		for(ExitConnectorBase exitConnectors : EcoreUtils.pickInstanceOf(ExitConnectorBase.class,
 				element.getConnectors())) {
 			recursivlyFollowOutgoingConnection(exitConnectors, neighbors);
@@ -168,7 +166,7 @@ public class GraphMetricsProvider {
 	}
 
 	/**
-	 * Calculates the clustering coefficient based on the neighborhood
+	 * Calculates the clustering coefficient based on the neighborhood.
 	 * 
 	 * @param element
 	 *            of which the coefficient shall be calculated
@@ -183,6 +181,8 @@ public class GraphMetricsProvider {
 			return 0.0; // If there are fewer than 2 neighbors, the coefficient is undefined (or 0).
 		}
 
+		// Iterate over neighbors and get their neighbors and check if they are also our neighbor in
+		// which case we have a triangle
 		int triangles = 0;
 		for(IHierarchicElement neighbor : neighbors) {
 
@@ -200,7 +200,7 @@ public class GraphMetricsProvider {
 
 	/**
 	 * Calculates and saves the betweenness centrality of all elements contained inside the provided
-	 * scopeElement
+	 * scopeElement.
 	 * 
 	 * @param scopeElement
 	 *            the scope of this calculation
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/HierarchicElementProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/HierarchicElementProvider.java
index f98165974..3c114abd4 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/HierarchicElementProvider.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/HierarchicElementProvider.java
@@ -25,37 +25,23 @@ import org.fortiss.tooling.kernel.model.INamedCommentedElement;
 import org.fortiss.tooling.kernel.utils.EcoreUtils;
 
 /**
- * {@link IMetricProvider} to count the ratio of filled out comments of
- * INamedCommentedElements.
+ * {@link IMetricProvider} to collect various metrics from an {@link IHierarchicElement}.
  * 
  * @author blaschke
  * @author groh
  */
 public class HierarchicElementProvider implements IMetricProvider<IHierarchicElement> {
-	/**
-	 * returns an array of integers or <String,Double> Map Number of children of the
-	 * hierarchical Element (on this level) Number of ports on the hierarchical
-	 * Element (on this level) Number of channels in the hierarchical element (on
-	 * this level) Number of totalPorts in whole tree Number of totalElements in
-	 * whole tree Average SubTree Size
-	 */
-
-	/**
-	 * List containing all HierarchicElementSizeProvider for components inside the
-	 * IHierarchicElement
-	 */
-
-	/** */
-	public HierarchicElementProvider() {
-		super();
-	}
-
 	/** {@inheritDoc} */
 	@Override
 	public void collectMetrics(MetricTreeNode node, IHierarchicElement currentElement) {
 
 		var integers = node.getStoredIntegers();
+		// Only collect these metrics if the name is null, in which case they have not been
+		// collected before
+		// This is used in some cases to combine metrics from two different IHierarchicElement
 		if(node.getName() == null) {
+
+			// Metrics are always set to default value, as these metric are combined later
 			boolean isElementCommentable = currentElement instanceof INamedCommentedElement;
 			integers.put(MetricKey.NUMBER_OF_TOTAL_COMMENTABLE_ELEMENTS,
 					isElementCommentable ? 1 : 0);
@@ -79,6 +65,7 @@ public class HierarchicElementProvider implements IMetricProvider<IHierarchicEle
 		integers.put(MetricKey.NUMBER_OF_CONTAINED_ELEMENTS,
 				currentElement.getContainedElements().size());
 		integers.put(MetricKey.NUMBER_OF_CONNECTIONS, currentElement.getConnections().size());
+
 		// depth metrics
 		integers.put(MetricKey.NUMBER_OF_TOTAL_CONNECTORS, connectors.size());
 		var entry_connectors = EcoreUtils.pickInstanceOf(EntryConnectorBase.class, connectors);
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/IMetricProvider.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/IMetricProvider.java
index 43606a0df..5e3d0debc 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/IMetricProvider.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/IMetricProvider.java
@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------+
-| Copyright 2011 fortiss GmbH                                              |
+| Copyright 2023 fortiss GmbH                                              |
 |                                                                          |
 | Licensed under the Apache License, Version 2.0 (the "License");          |
 | you may not use this file except in compliance with the License.         |
@@ -21,9 +21,9 @@ import org.fortiss.tooling.ext.quality.service.IModelQualityService;
 import org.fortiss.tooling.kernel.service.base.IEObjectAware;
 
 /**
- * Interface for the migration provider implementations.
+ * Interface for all metric providers.
  * <P>
- * migration provider extensions are handled by {@link IModelQualityService}.
+ * They are called by {@link IModelQualityService} to collect metrics on model elements.
  * 
  * @author blaschke
  */
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/.ratings b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/.ratings
new file mode 100644
index 000000000..6e8571fab
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/.ratings
@@ -0,0 +1,3 @@
+MetricDataManager.java 36dc2d04485702ce18dd914789d06d873eb99564 YELLOW
+MetricKey.java ecb1c765a7de855091c7ac8b287eaf9503e0da33 YELLOW
+MetricTreeNode.java d89ef9aab7171a66ff7fc30c904e06f50d164ff9 YELLOW
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricDataManager.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricDataManager.java
index 093c59f8b..36dc2d044 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricDataManager.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricDataManager.java
@@ -22,19 +22,20 @@ import org.eclipse.emf.ecore.EObject;
 import org.fortiss.tooling.kernel.model.IProjectRootElement;
 
 /**
+ * Class containing all computed metrics for the current af3 instance.
  * 
  * @author groh
  */
 public class MetricDataManager {
 
-	/** a map to lookup the corresponding tree node */
+	/** a map to lookup the corresponding tree node for any {@link EObject} */
 	private Map<EObject, MetricTreeNode> treeNodeLookupTable;
 
-	/** the root tree node */
+	/** a map to lookup the corresponding root tree node for a project */
 	private Map<IProjectRootElement, MetricTreeNode> root_nodes;
 
 	/**
-	 * Constructs a new instance of the MetricDataManager
+	 * Constructor: Creates a new instance of the MetricDataManager.
 	 */
 	public MetricDataManager() {
 		root_nodes = new HashMap<>();
@@ -42,16 +43,17 @@ public class MetricDataManager {
 	}
 
 	/**
-	 * @return the lookup map
+	 * @return the lookup mapping between {@link EObject} and a {@link MetricTreeNode}.
 	 */
 	public Map<EObject, MetricTreeNode> getTreeNodeLookupTable() {
 		return treeNodeLookupTable;
 	}
 
 	/**
-	 * @return a map containing all root nodes
+	 * @return the map between {@link IProjectRootElement} and the corresponding root
+	 *         {@link MetricTreeNode}.
 	 */
-	public Map<IProjectRootElement, MetricTreeNode> getRootNodes() {
+	public Map<IProjectRootElement, MetricTreeNode> getRootNodesMap() {
 		return root_nodes;
 	}
 }
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java
index 2b24baa69..ecb1c765a 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricKey.java
@@ -19,6 +19,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
+ * Enum class representing a key which can be used to store a respective metric.
  * 
  * @author groh
  */
@@ -115,7 +116,7 @@ public enum MetricKey {
 	private boolean isDoubleValue;
 
 	/**
-	 * Basic constructor
+	 * Constructor for regular integer metric keys.
 	 * 
 	 * @param isCollectorKey
 	 *            decides if this is a key returned by {@link MetricKey#getCollectorKeys()}
@@ -125,6 +126,8 @@ public enum MetricKey {
 	}
 
 	/**
+	 * Constructor for metric key storing a double.
+	 * 
 	 * @param isCollectorKey
 	 *            decides if this is a key returned by {@link MetricKey#getCollectorKeys()}
 	 * @param isDoubleValue
@@ -137,6 +140,8 @@ public enum MetricKey {
 	}
 
 	/**
+	 * Constructor for metric key storing a string.
+	 * 
 	 * @param isCollectorKey
 	 *            decides if this is a key returned by {@link MetricKey#getCollectorKeys()}
 	 * @param isStringValue
@@ -150,7 +155,7 @@ public enum MetricKey {
 
 	/**
 	 * If this value is true, it should be expected that the value corresponding to this key should
-	 * be a string and be stored in an appropriate place
+	 * be a string and be stored in an appropriate place.
 	 * 
 	 * @return if the value associated with this key is a string
 	 */
@@ -160,7 +165,7 @@ public enum MetricKey {
 
 	/**
 	 * If this value is true, it should be expected that the value corresponding to this key should
-	 * be a integer and be stored in an appropriate place
+	 * be a integer and be stored in an appropriate place.
 	 * 
 	 * @return if the value associated with this key is a integer
 	 */
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricTreeNode.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricTreeNode.java
index 25be67105..d89ef9aab 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricTreeNode.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/data/MetricTreeNode.java
@@ -23,8 +23,8 @@ import java.util.function.Consumer;
 
 /**
  * A general class for storing all kinds of metric data in a hierarchical tree structure.
- * 
- * Allows for efficient storage and retrieval of data
+ * <p>
+ * Allows for efficient storage and retrieval of data.
  * 
  * @author groh
  */
@@ -45,9 +45,7 @@ public class MetricTreeNode {
 	/** name of the element which is associated with this data */
 	private String name;
 
-	/**
-	 * Constructs a new node
-	 */
+	/** Constructor. */
 	public MetricTreeNode() {
 		children = new ArrayList<>();
 		storedIntegers = new HashMap<>();
@@ -55,49 +53,40 @@ public class MetricTreeNode {
 		storedStrings = new HashMap<>();
 	}
 
-	/**
-	 * @return the children of this node
-	 */
+	/** @return the children of this node */
 	public List<MetricTreeNode> getChildren() {
 		return children;
 	}
 
-	/**
-	 * @return the name of the element which is associated with this data
-	 */
+	/** @return the name of the element which is associated with this data */
 	public String getName() {
 		return name;
 	}
 
-	/** Set the name */
+	/** Set the name of this node. */
 	public void setName(String name) {
 		this.name = name;
 	}
 
-	/**
-	 * @return the stored Integer map
-	 */
+	/** @return the stored Integer map */
 	public Map<MetricKey, Integer> getStoredIntegers() {
 		return storedIntegers;
 	}
 
-	/**
-	 * @return the stored Doubles map
-	 */
+	/** @return the stored Doubles map */
 	public Map<MetricKey, Double> getStoredDoubles() {
 		return storedDoubles;
 	}
 
-	/**
-	 * @return the stored Strings map
-	 */
+	/** @return the stored Strings map */
 	public Map<MetricKey, String> getStoredStrings() {
 		return storedStrings;
 	}
 
 	/**
-	 * Allows to retrieve allows to retrieve the value of a key which may be stored as double or integer type.
-	 * In the latter case the value will automatically be converted into a double
+	 * Allows to retrieve allows to retrieve the value of a key which may be stored as double or
+	 * integer type.
+	 * In the latter case the value will automatically be converted into a double.
 	 * 
 	 * @param key
 	 *            for which the value shall be retrieved
@@ -112,7 +101,7 @@ public class MetricTreeNode {
 	}
 
 	/**
-	 * Traverses the tree in post-order
+	 * Traverses the tree in post-order.
 	 * 
 	 * @param consumer
 	 *            which is applied to each node
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/.ratings b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/.ratings
new file mode 100644
index 000000000..eef481260
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/.ratings
@@ -0,0 +1,2 @@
+IModelQualityService.java 5168db33728ae6ea4cae4a698ce21a26dce5ec79 YELLOW
+ModelQualityService.java 75d1301f64d64c273a1f649ff7a02e396eb98b35 YELLOW
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IModelQualityService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IModelQualityService.java
index f355df420..5168db337 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IModelQualityService.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/IModelQualityService.java
@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------+
-| Copyright 2011 fortiss GmbH                                              |
+| Copyright 2023 fortiss GmbH                                              |
 |                                                                          |
 | Licensed under the Apache License, Version 2.0 (the "License");          |
 | you may not use this file except in compliance with the License.         |
@@ -20,7 +20,7 @@ import org.fortiss.tooling.ext.quality.IMetricProvider;
 import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
 
 /**
- * Performs metric analysis
+ * A service for performing metric extraction and analysis.
  * 
  * @author groh
  */
@@ -34,6 +34,6 @@ public interface IModelQualityService {
 	<T extends EObject> void registerMetricProvider(IMetricProvider<T> provider,
 			Class<T> modelElementClass);
 
-	/** Schedules an analysis of the metrics and processes them */
+	/** Schedules an analysis of the metrics and processes them. */
 	void scheduleMetricCollection(ITopLevelElement top);
 }
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java
index 65d4ba8af..75d1301f6 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/service/ModelQualityService.java
@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------+
-| Copyright 2013 fortiss GmbH                                              |
+| Copyright 2023 fortiss GmbH                                              |
 |                                                                          |
 | Licensed under the Apache License, Version 2.0 (the "License");          |
 | you may not use this file except in compliance with the License.         |
@@ -60,7 +60,7 @@ import org.fortiss.tooling.kernel.utils.EcoreUtils;
  * @author blaschke
  * @author groh
  */
-public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider<?>>
+public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider<? extends EObject>>
 		implements IIntrospectiveKernelService, IModelQualityService, IPersistencyServiceListener {
 
 	/** The singleton instance. */
@@ -81,14 +81,14 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 	/** The connector attribute name. */
 	private static final String ATTRIBUTE_NAME = "metricService";
 
-	/** Static instance of the MetricDataManager */
-	public static MetricDataManager metricDataManagerInstance = new MetricDataManager();
+	/** Instance of the MetricDataManager. */
+	private MetricDataManager metricDataManagerInstance = new MetricDataManager();
 
 	/** Top-level elements queued to be processed by the metric collector. */
 	private final Queue<ITopLevelElement> queuedProcessableElements =
 			new ConcurrentLinkedQueue<ITopLevelElement>();
 
-	/** Stores the constraint checking job. */
+	/** Stores the metrics collector job. */
 	private final Job metricCollectorJob = new Job("Collecting metrics ...") {
 
 		@Override
@@ -123,7 +123,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 		IPersistencyService.getInstance().addTopLevelElementListener(this);
 	}
 
-	/** Registers the migration provider with the service. */
+	/** Registers the metric provider with the service. */
 	@Override
 	public <T extends EObject> void registerMetricProvider(IMetricProvider<T> provider,
 			Class<T> modelElementClass) {
@@ -136,19 +136,22 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 		return getIntrospectionLabel() +
 				"\n\nThis service allows the tracking of metrical development in modeling." +
 				"\n the service outputs the current metric analysis of the model and stores" +
-				"\n the data within logs for later history analysis." +
+				"\n the data within a csv for later history analysis." +
 				"\n\nThe service extension point is '" + EXTENSION_POINT_NAME + "'.";
 	}
 
 	/**
+	 * Collects all metrics for all elements in the provided {@link ITopLevelElement}.
+	 * 
 	 * @param topLvl
-	 *            the file project on which the analysis should be performed
+	 *            the {@link ITopLevelElement} on which the analysis should be performed
 	 */
 	private void performMetricCollection(ITopLevelElement topLvl) {
 		// Sort root elements, as some metrics are saved into trees from other root elements
 		// To avoid these problems, the elements have to be processed in a certain order
 
-		// Currently the only element affected by this is the allocation table which
+		// Currently the only element affected by this is the allocation table, which is
+		// why push it to the end of the list
 		List<IProjectRootElement> rootElements = new ArrayList<>();
 		rootElements.addAll(EcoreUtils.getChildrenWithType(topLvl.getRootModelElement(),
 				IProjectRootElement.class));
@@ -156,6 +159,8 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 		String allocationTableClassName =
 				"org.fortiss.af3.allocation.model.impl.AllocationTableCollectionImpl";
 
+		// Sort with custom comparator which pushes the object back if it matches the above class
+		// name
 		Collections.sort(rootElements, (r1, r2) -> {
 			if(allocationTableClassName.equals(r1.getClass().getName())) {
 				return 1;
@@ -167,7 +172,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 
 		for(IProjectRootElement rootElement : rootElements) {
 
-			var root_nodes = metricDataManagerInstance.getRootNodes();
+			var root_nodes = metricDataManagerInstance.getRootNodesMap();
 			MetricTreeNode rootNode = new MetricTreeNode();
 
 			if(rootElement instanceof IHierarchicElement) {
@@ -184,6 +189,7 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 					ConstraintCheckerService.getInstance()
 							.performAllConstraintChecksRecursively(rootElement);
 
+			// Add the violated constraints to the corresponding tree node
 			for(Entry<? extends EObject, List<IConstraintViolation<? extends EObject>>> entry : contraintViolations
 					.stream().collect(Collectors.groupingBy(IConstraintViolation::getSource))
 					.entrySet()) {
@@ -206,10 +212,12 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 			metricDataManagerInstance.getTreeNodeLookupTable().put(rootElement, rootNode);
 		}
 		// Store all currently saved metrics to the csv
-		CSVFileWriter.metricExtractionToCSV(metricDataManagerInstance.getRootNodes());
+		CSVFileWriter.metricExtractionToCSV(metricDataManagerInstance.getRootNodesMap());
 	}
 
 	/**
+	 * Collect metrics for the given {@link IHierarchicElement} and all its contained elements.
+	 * 
 	 * @param node
 	 *            to which the data is collected
 	 * @param currentElement
@@ -278,6 +286,9 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 	}
 
 	/**
+	 * Collect all metrics provided by any {@link IMetricProvider}} for the given object and saves
+	 * them in the {@link MetricTreeNode}.
+	 * 
 	 * @param node
 	 *            to which the data is collected
 	 * @param object
@@ -286,20 +297,18 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 	@SuppressWarnings("unchecked")
 	private void collectMetrics(MetricTreeNode node, EObject object) {
 
-		List<IMetricProvider<?>> providers = getAllMetricProviders(object);
+		List<IMetricProvider<? extends EObject>> providers = getAllMetricProviders(object);
 
-		if(providers.isEmpty()) {
-			// it should not happen that no provider is found
-			// throw new IllegalStateException();
-		}
+		for(IMetricProvider<? extends EObject> provider : providers) {
 
-		for(IMetricProvider<?> provider : providers) {
+			// The provider in the list has to have a compatible method for the actual type
+			// as we just collected providers with a compatible type
 			((IMetricProvider<EObject>)provider).collectMetrics(node, object);
 		}
 	}
 
 	/** Get all suitable {@link IMetricProvider} for the given input. */
-	private List<IMetricProvider<?>> getAllMetricProviders(EObject input) {
+	private List<IMetricProvider<? extends EObject>> getAllMetricProviders(EObject input) {
 		List<IMetricProvider<?>> providers = new ArrayList<>();
 		for(Entry<Class<?>, List<IMetricProvider<?>>> migEntry : handlerMap.entrySet()) {
 			if(migEntry.getKey().isAssignableFrom(input.getClass())) {
@@ -374,4 +383,9 @@ public class ModelQualityService extends EObjectAwareServiceBase<IMetricProvider
 	public void topLevelElementContentChanged(ITopLevelElement element) {
 		scheduleMetricCollection(element);
 	}
+
+	/** @return the {@link MetricDataManager} for this service instance. */
+	public MetricDataManager getMetricDataManagerInstance() {
+		return metricDataManagerInstance;
+	}
 }
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/.ratings b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/.ratings
new file mode 100644
index 000000000..10d1f9061
--- /dev/null
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/.ratings
@@ -0,0 +1,2 @@
+CSVFileWriter.java 4e079908d3dd9af600ef97773f795c3e6a726c4b YELLOW
+ModelQualityStorageManager.java 124faddb3d297d23448c15379446cc847a2790a9 YELLOW
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/CSVFileWriter.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/CSVFileWriter.java
index c7ef4a391..4e079908d 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/CSVFileWriter.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/CSVFileWriter.java
@@ -37,13 +37,20 @@ import org.fortiss.tooling.ext.quality.data.MetricTreeNode;
 import org.fortiss.tooling.kernel.model.IProjectRootElement;
 
 /**
+ * Allows the export of metrics to a csv file.
  * 
  * @author groh
  */
 public class CSVFileWriter {
 
 	/**
-	 * Method to write the data into a csv
+	 * Method to write the data into the default csv.
+	 * <p>
+	 * It will always write to the same file, if it is already present it will attempt to read the
+	 * keys and convert them into {@link MetricKey} and then write these keys in the ordering that
+	 * is already present. This is done such that the log file always remains consistent, but can
+	 * cause newly added {@link MetricKey} not to be exported if they were not present when the file
+	 * was exported the first time.
 	 * 
 	 * @param map
 	 *            to convert into csv
@@ -56,15 +63,14 @@ public class CSVFileWriter {
 			return;
 		}
 
+		// Ensure the folder exists
 		if(!ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR.exists()) {
-
 			ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR.mkdirs();
 		}
 
 		// path to csv file
-		Path path =
-				new File(ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR, "metric_logfile.csv")
-						.toPath();
+		Path path = new File(ModelQualityStorageManager.MODEL_QUALITY_PROJECT_DIR,
+				ModelQualityStorageManager.CSV_FILE_NAME).toPath();
 
 		List<String> allKeys = new ArrayList<>();
 		boolean createNewIndex = true;
diff --git a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/ModelQualityStorageManager.java b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/ModelQualityStorageManager.java
index df5eddf73..124faddb3 100644
--- a/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/ModelQualityStorageManager.java
+++ b/org.fortiss.tooling.ext.quality/src/org/fortiss/tooling/ext/quality/storage/ModelQualityStorageManager.java
@@ -1,5 +1,5 @@
 /*-------------------------------------------------------------------------+
-| Copyright 2021 fortiss GmbH                                              |
+| Copyright 2023 fortiss GmbH                                              |
 |                                                                          |
 | Licensed under the Apache License, Version 2.0 (the "License");          |
 | you may not use this file except in compliance with the License.         |
@@ -22,22 +22,22 @@ import java.io.File;
 import org.eclipse.core.resources.IWorkspaceRoot;
 
 /**
- * Manages the local log of the model quality service.
+ * Manages the directory of the csv files.
  *
  * @author groh
  */
 public class ModelQualityStorageManager {
 
-	/** The name of the general reuse (library) directory. */
+	/** The name of the general quality plugin directory. */
 	public static final String AF3_QUALITY_DIRECTORY_NAME = "AF3-Model-Quality-Directory";
 
-	/** AF3 reuse library files extension */
-	public static final String AF3_MODEL_QUALITY_FILES_EXTENSION = "af3_mq";
-
 	/** The current workspace root. */
 	public static final IWorkspaceRoot WORKSPACE_ROOT = getWorkspace().getRoot();
 
-	/** The File handler of the reuse project. */
+	/** {@link File} representing the directory where all data is saved. */
 	public static final File MODEL_QUALITY_PROJECT_DIR =
 			new File(WORKSPACE_ROOT.getLocation() + File.separator + AF3_QUALITY_DIRECTORY_NAME);
+
+	/** Name of the file in which the data is written. */
+	public static final String CSV_FILE_NAME = "metric_logfile.csv";
 }
-- 
GitLab