Skip to content

Commit

Permalink
Release 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nanguoqiang committed Mar 14, 2023
1 parent 1b993be commit 7f85d15
Show file tree
Hide file tree
Showing 12 changed files with 294 additions and 14 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ You can filter the issues by the following categories:
* Resolution
* Resolved
* Unresolved

* Severity
* Blocker
* Critical
* Major
* Minor
* Info

## Contributing

Expand Down
7 changes: 6 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ Project级别设置主要包含:
* 解决
* 已解决
* 未解决

* 严重程度
* 阻断
* 严重
* 主要
* 次要
* 提示

## 如何贡献

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'

group 'com.yujunyang'
version '0.2.2'
version '0.2.3'

sourceCompatibility = 1.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ public void log(String formattedMessage, Level level) {
report.getVulnerabilityCount(),
report.getDuplicatedBlocksCount(),
report.getSecurityHotSpotCount());
problemCacheService.setSeverityStats(
report.getBlockerCount(),
report.getCriticalCount(),
report.getMajorCount(),
report.getMinorCount(),
report.getInfoCount());
return report;
});

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/yujunyang/intellij/plugin/sonar/core/Report.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class Report {
private CopyOnWriteArraySet<String> ignoreRules;
private int ignoreIssueCount;

private int blockerCount, criticalCount, majorCount, minorCount, infoCount;

public Report(@NotNull Project project, @NotNull File reportDir) {
this.project = project;
this.reportDir = reportDir;
Expand Down Expand Up @@ -157,6 +159,26 @@ private void analyze() {
break;
}

switch (reportIssue.getSeverity()) {
case BLOCKER:
blockerCount++;
break;
case CRITICAL:
criticalCount++;
break;
case MAJOR:
majorCount++;
break;
case MINOR:
minorCount++;
break;
case INFO:
infoCount++;
break;
default:
//do nothing
}

if (ignoreIssue) {
ignoreRules.add(issueRuleKey);
MessageBusManager.publishLogToEDT(project, String.format("Rule[%s] type[%s] 暂未被报告解析程序支持, 展示的报告中将忽略此类型相关问题, 在后续插件更新中可能会增加支持", issueRuleKey, rule.getType()), LogOutput.Level.ERROR);
Expand Down Expand Up @@ -296,4 +318,25 @@ private List<RulesSearchResponse.Rule> getRules() {
// }
// return rule;
}

public int getBlockerCount() {
return blockerCount;
}

public int getCriticalCount() {
return criticalCount;
}

public int getMajorCount() {
return majorCount;
}

public int getMinorCount() {
return minorCount;
}

public int getInfoCount() {
return infoCount;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public class IssuesDisplayControlPanel extends JBPanel {
private JBLabel unresolvedCountLabel;
private JBLabel updatedFilesCountLabel;
private JBLabel notUpdatedFilesCountLabel;
private JBLabel blockerCountLabel;
private JBLabel criticalCountLabel;
private JBLabel majorCountLabel;
private JBLabel minorCountLabel;
private JBLabel infoCountLabel;

public IssuesDisplayControlPanel(Project project) {
this.project = project;
Expand All @@ -64,6 +69,19 @@ public IssuesDisplayControlPanel(Project project) {
private void init() {
setLayout(new SampleVerticalScrollLayout());

add(Box.createVerticalStrut(5));
addTitleLabel(ResourcesLoader.getString("toolWindow.report.displayControl.severityTitle"));
blockerCountLabel = createCountLabel("0");
addControlItemPanel("severity.blocker", blockerCountLabel, "BLOCKER");
criticalCountLabel = createCountLabel("0");
addControlItemPanel("severity.critical", criticalCountLabel, "CRITICAL");
majorCountLabel = createCountLabel("0");
addControlItemPanel("severity.major", majorCountLabel, "MAJOR");
minorCountLabel = createCountLabel("0");
addControlItemPanel("severity.minor", minorCountLabel, "MINOR");
infoCountLabel = createCountLabel("0");
addControlItemPanel("severity.info", infoCountLabel, "INFO");

addTitleLabel(ResourcesLoader.getString("toolWindow.report.displayControl.issueTypeTitle"));
bugCountLabel = createCountLabel("0");
addControlItemPanel("issueType.bug", bugCountLabel, "BUG");
Expand Down Expand Up @@ -104,6 +122,13 @@ public void refresh() {
notUpdatedFilesCountLabel.setText(String.valueOf(problemCacheService.getNotUpdatedFilesIssueCount()));
resolvedCountLabel.setText(String.valueOf(problemCacheService.getFixedIssueCount()));
unresolvedCountLabel.setText(String.valueOf(problemCacheService.getUnresolvedIssueCount()));

blockerCountLabel.setText(String.valueOf(problemCacheService.getUnresolvedIssueCount()));
blockerCountLabel.setText(String.valueOf(problemCacheService.getBlockerCount()));
criticalCountLabel.setText(String.valueOf(problemCacheService.getCriticalCount()));
majorCountLabel.setText(String.valueOf(problemCacheService.getMajorCount()));
minorCountLabel.setText(String.valueOf(problemCacheService.getMinorCount()));
infoCountLabel.setText(String.valueOf(problemCacheService.getInfoCount()));
}

public void reset() {
Expand All @@ -116,7 +141,12 @@ public void reset() {
updatedFilesCountLabel,
notUpdatedFilesCountLabel,
resolvedCountLabel,
unresolvedCountLabel).forEach(label -> {
unresolvedCountLabel,
blockerCountLabel,
criticalCountLabel,
majorCountLabel,
minorCountLabel,
infoCountLabel).forEach(label -> {
label.setText("0");
cancelHighlight((JBPanel)(label.getParent()));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class IssuesPanel extends JBPanel {
private IssuesDisplayControlPanel issuesDisplayControlPanel;
private JBPanel listPanelParent;
private CardLayout listPanelParentLayout;
private SearchPanel searchPanel;

public IssuesPanel(Project project) {
this.project = project;
Expand All @@ -58,6 +59,9 @@ private void init() {
setLayout(new BorderLayout());
setSize(300, 300);

searchPanel = new SearchPanel(project);
add(searchPanel, BorderLayout.NORTH);

displayControlScrollPane = new JBScrollPane();
displayControlScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
displayControlScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
Expand Down Expand Up @@ -112,8 +116,10 @@ public void refresh() {

private void filter() {
listScrollPane.getVerticalScrollBar().setValue(0);
ProblemCacheService problemCacheService = ProblemCacheService.getInstance(project);
problemCacheService.doFilterIssues();
issueListPanel.refresh();
if (ProblemCacheService.getInstance(project).getFilteredIssues().size() > 0) {
if (problemCacheService.getFilteredIssues().size() > 0) {
listPanelParentLayout.show(listPanelParent, "ISSUES_LIST");
} else {
listPanelParentLayout.show(listPanelParent, "ISSUES_EMPTY");
Expand All @@ -125,5 +131,6 @@ private void filter() {
public void reset() {
issuesDisplayControlPanel.reset();
issueListPanel.reset();
searchPanel.reset();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.yujunyang.intellij.plugin.sonar.gui.toolwindow;

import com.google.common.base.Splitter;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.ui.components.JBBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBPanel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.JBUI;
import com.yujunyang.intellij.plugin.sonar.messages.MessageBusManager;
import com.yujunyang.intellij.plugin.sonar.service.ProblemCacheService;
import org.apache.commons.lang3.StringUtils;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.Set;

public class SearchPanel extends JBPanel {

private final Project project;

private JBTextField searchField;

private JButton searchButton;

public SearchPanel(Project project) {
this.project = project;
setLayout(new BorderLayout());
init();
}

private void init() {
JBBox horizontalBox = JBBox.createHorizontalBox();
horizontalBox.setBorder(JBUI.Borders.empty(2, 5));

horizontalBox.add(new JBLabel("RuleKey: "));

searchField = new JBTextField("");
searchField.getEmptyText().setText("Example:S112 S3518");
horizontalBox.add(searchField);

searchButton = new JButton(AllIcons.Actions.Search);
horizontalBox.add(searchButton);

searchField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
searchButton.doClick();
}
}
});

searchButton.addActionListener(actionEvent -> {
Set<String> ruleKeys = ProblemCacheService.getInstance(project).getRuleKeys();
ruleKeys.clear();
String ruleKey = searchField.getText();
if (StringUtils.isNoneBlank(ruleKey)) {
Splitter.on(" ")
.omitEmptyStrings()
.trimResults()
.split(ruleKey.toUpperCase())
.forEach(ruleKeys::add);
}
MessageBusManager.publishIssueFilter(project);
});

add(horizontalBox, BorderLayout.CENTER);
}

public void reset() {
searchField.setText("");
}
}
Loading

0 comments on commit 7f85d15

Please sign in to comment.