Skip to content

Commit 289ad93

Browse files
committed
Fix rule message
1 parent a23e3b1 commit 289ad93

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

PMD-Intellij.iml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module type="PLUGIN_MODULE" version="4">
3-
<component name="CheckStyle-IDEA-Module">
4-
<option name="configuration">
5-
<map />
6-
</option>
7-
</component>
83
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
94
<component name="NewModuleRootManager" inherit-compiler-output="true">
105
<exclude-output />
116
<content url="file://$MODULE_DIR$">
12-
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
137
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
8+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
149
</content>
1510
<orderEntry type="inheritedJdk" />
1611
<orderEntry type="sourceFolder" forTests="false" />
17-
<orderEntry type="library" name="pmd-6.27" level="project" />
12+
<orderEntry type="library" name="pmd-java-6.32.0" level="project" />
1813
</component>
1914
</module>

src/com/intellij/plugins/bodhi/pmd/PMDInvoker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public void run() {
172172
progress.setText("Running : " + rules[i] + " on " + files.size() + " file(s)");
173173

174174
//Create a result collector to get results
175-
PMDResultCollector collector = new PMDResultCollector(isCustomRuleSet);
175+
PMDResultCollector collector = new PMDResultCollector();
176176

177177
//Get the tree nodes from result collector
178178
List<DefaultMutableTreeNode> results = collector.getResults(files, rules[i], projectComponent);

src/com/intellij/plugins/bodhi/pmd/core/PMDResultCollector.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,12 @@ public class PMDResultCollector {
4747
private Map<String, DefaultMutableTreeNode> map;
4848
public static Report report;
4949

50-
//Whether we are using custom ruleset or not
51-
private boolean isCustomRuleSet;
52-
5350
/**
5451
* Creates an instance of PMDResultCollector.
5552
*
56-
* @param isCustomRuleSet Whether a custom rule has to be run
5753
*/
58-
public PMDResultCollector(boolean isCustomRuleSet) {
54+
public PMDResultCollector() {
5955
map = new HashMap<>();
60-
this.isCustomRuleSet = isCustomRuleSet;
6156
}
6257

6358
/**
@@ -152,9 +147,7 @@ public static String isValidRuleSet(String path) {
152147
if (rs.getRules().size() != 0) {
153148
return "";
154149
}
155-
} catch (RuleSetNotFoundException e) {
156-
return e.getMessage();
157-
} catch (RuntimeException e) {
150+
} catch (RuleSetNotFoundException | RuntimeException e) {
158151
return e.getMessage();
159152
}
160153
return "Invalid File";
@@ -201,10 +194,10 @@ public void renderFileViolations(Iterator<RuleViolation> violations) throws IOEx
201194
if (PMDResultCollector.report == null) {
202195
PMDResultCollector.report = new Report();
203196
}
204-
for (; violations.hasNext();) {
197+
while (violations.hasNext()) {
205198
RuleViolation iRuleViolation = violations.next();
206199
PMDResultCollector.report.addRuleViolation(iRuleViolation);
207-
String message = iRuleViolation.getRule().getName() + ": " + iRuleViolation.getRule().getMessage();
200+
String message = iRuleViolation.getRule().getName();
208201
DefaultMutableTreeNode node = map.get(message);
209202
if (node == null) {
210203
node = nodeFactory.createNode(shortMessage(message));

src/com/intellij/plugins/bodhi/pmd/handlers/PMDCheckinHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public ReturnResult beforeCheckin(@Nullable CommitExecutor executor,
116116

117117
private DefaultMutableTreeNode scanFiles(String ruleSet, PMDProjectComponent plugin) {
118118
DefaultMutableTreeNode result = null;
119-
PMDResultCollector collector = new PMDResultCollector(true);
119+
PMDResultCollector collector = new PMDResultCollector();
120120
List<File> files = new ArrayList<>(checkinProjectPanel.getFiles());
121121

122122
List<DefaultMutableTreeNode> ruleSetResults = collector.getResults(files, ruleSet, plugin);

0 commit comments

Comments
 (0)