]> source.dussan.org Git - sonarqube.git/commitdiff
Update scanner report viewer to show QP and plugins
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 8 Aug 2017 17:24:23 +0000 (19:24 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 7 Sep 2017 06:33:31 +0000 (08:33 +0200)
sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java

index e34e0421444b5dc544097cf1fb0472796a2d8a7f..ed5accc8d00160aac973a6b532061290ebae744f 100644 (file)
@@ -32,8 +32,8 @@ import java.nio.charset.StandardCharsets;
 import java.sql.Date;
 import java.text.SimpleDateFormat;
 import java.util.List;
+import java.util.Map;
 import java.util.Scanner;
-
 import javax.annotation.CheckForNull;
 import javax.swing.JEditorPane;
 import javax.swing.JFileChooser;
@@ -51,7 +51,6 @@ import javax.swing.event.TreeSelectionListener;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeSelectionModel;
-
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.core.util.CloseableIterator;
@@ -62,6 +61,8 @@ import org.sonar.scanner.protocol.output.ScannerReport.Changesets.Changeset;
 import org.sonar.scanner.protocol.output.ScannerReport.Component;
 import org.sonar.scanner.protocol.output.ScannerReport.Issue;
 import org.sonar.scanner.protocol.output.ScannerReport.Metadata;
+import org.sonar.scanner.protocol.output.ScannerReport.Metadata.Plugin;
+import org.sonar.scanner.protocol.output.ScannerReport.Metadata.QProfile;
 import org.sonar.scanner.protocol.output.ScannerReportReader;
 
 public class ScannerReportViewerApp {
@@ -97,6 +98,10 @@ public class ScannerReportViewerApp {
   private JEditorPane scmEditor;
   private JScrollPane activeRuleTab;
   private JEditorPane activeRuleEditor;
+  private JScrollPane qualityProfileTab;
+  private JEditorPane qualityProfileEditor;
+  private JScrollPane pluginTab;
+  private JEditorPane pluginEditor;
   private JScrollPane cpdTextBlocksTab;
   private JEditorPane cpdTextBlocksEditor;
 
@@ -189,6 +194,8 @@ public class ScannerReportViewerApp {
     updateTitle();
     loadComponents();
     updateActiveRules();
+    updateQualityProfiles();
+    updatePlugins();
   }
 
   private void loadComponents() {
@@ -263,7 +270,7 @@ public class ScannerReportViewerApp {
       }
     }
   }
-  
+
   private void updateDuplications(Component component) {
     duplicationEditor.setText("");
     if (reader.hasCoverage(component.getRef())) {
@@ -349,6 +356,28 @@ public class ScannerReportViewerApp {
     }
   }
 
+  private void updateQualityProfiles() {
+    qualityProfileEditor.setText("");
+
+    StringBuilder builder = new StringBuilder();
+    for (Map.Entry<String, QProfile> qp : metadata.getQprofilesPerLanguage().entrySet()) {
+      builder.append(qp.getKey()).append(":\n").append(qp.getValue()).append("\n\n");
+
+    }
+    qualityProfileEditor.setText(builder.toString());
+  }
+
+  private void updatePlugins() {
+    pluginEditor.setText("");
+
+    StringBuilder builder = new StringBuilder();
+    for (Map.Entry<String, Plugin> p : metadata.getPluginsByKey().entrySet()) {
+      builder.append(p.getKey()).append(":\n").append(p.getValue()).append("\n\n");
+
+    }
+    pluginEditor.setText(builder.toString());
+  }
+
   private void updateHighlighting(Component component) {
     highlightingEditor.setText("");
     try (CloseableIterator<ScannerReport.SyntaxHighlightingRule> it = reader.readComponentSyntaxHighlighting(component.getRef())) {
@@ -387,7 +416,7 @@ public class ScannerReportViewerApp {
         scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), changeset + "\n", null);
         index++;
       }
-      
+
       scmEditor.getDocument().insertString(scmEditor.getDocument().getEndPosition().getOffset(), "\n", null);
       int line = 1;
       for (Integer idx : changesetIndexByLine) {
@@ -506,12 +535,24 @@ public class ScannerReportViewerApp {
     activeRuleEditor = new JEditorPane();
     activeRuleTab.setViewportView(activeRuleEditor);
 
+    qualityProfileTab = new JScrollPane();
+    tabbedPane.addTab("Quality Profiles", null, qualityProfileTab, null);
+
+    qualityProfileEditor = new JEditorPane();
+    qualityProfileTab.setViewportView(qualityProfileEditor);
+
+    pluginTab = new JScrollPane();
+    tabbedPane.addTab("Plugins", null, pluginTab, null);
+
+    pluginEditor = new JEditorPane();
+    pluginTab.setViewportView(pluginEditor);
+
     cpdTextBlocksTab = new JScrollPane();
     tabbedPane.addTab("CPD Text Blocks", null, cpdTextBlocksTab, null);
-    
+
     cpdTextBlocksEditor = new JEditorPane();
     cpdTextBlocksTab.setViewportView(cpdTextBlocksEditor);
-    
+
     treeScrollPane = new JScrollPane();
     treeScrollPane.setPreferredSize(new Dimension(200, 400));
     splitPane.setLeftComponent(treeScrollPane);