aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-08-08 19:24:23 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-09-07 08:33:31 +0200
commitad5e52729d542dc2ee5fc7b4a90ced2f69eaed9b (patch)
tree9ac038e816ff771ba0fd00526be6d559393f5c99 /sonar-scanner-protocol
parent9da361bd859acacbbac3a7407802b34319861096 (diff)
downloadsonarqube-ad5e52729d542dc2ee5fc7b4a90ced2f69eaed9b.tar.gz
sonarqube-ad5e52729d542dc2ee5fc7b4a90ced2f69eaed9b.zip
Update scanner report viewer to show QP and plugins
Diffstat (limited to 'sonar-scanner-protocol')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java53
1 files changed, 47 insertions, 6 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
index e34e0421444..ed5accc8d00 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/viewer/ScannerReportViewerApp.java
@@ -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);