diff --git a/pmd/etc/build.xml b/pmd/etc/build.xml
index 1c188e3131..af4387860b 100644
--- a/pmd/etc/build.xml
+++ b/pmd/etc/build.xml
@@ -57,10 +57,10 @@
-
-
-
-
+
+
+
+
diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt
index dd6632602d..aa19dbda9b 100644
--- a/pmd/etc/changelog.txt
+++ b/pmd/etc/changelog.txt
@@ -3,10 +3,11 @@ Added numbering to the HTMLRenderer; thx to Luke Francl for the code.
Fixed bug 672742 - grammar typo was hosing up ASTConstructorDeclaration which was hosing up UseSingletonRule
Fixed bug 674393 - OnlyOneReturn rule no longer counts returns that are inside anonymous inner classes as being inside the containing method. Thx to C. Lamont Gilbert for the bug report.
Fixed bug 674420 - AvoidReassigningParametersRule no longer counts parameter field reassignment as a violation. Thx to C. Lamont Gilbert for the bug report.
-Fixed bug 673662 - The Ant task's "failOnError" attribute works again.
+Fixed bug 673662 - The Ant task's "failOnError" attribute works again. Changed the semantics of this attribute, though, so it fails the build if errors occurred. A new attribute 'failOnRuleViolation' serves the purpose of stopping the build if rule violations are found.
Fixed bug 676340 - Symbol table now creates new scope level when it encounters a switch statement. See the bug for code details; generally, this bug would have triggered runtime exceptions on certain blocks of code.
Fixed bug in OverrideBothEqualsAndHashcodeRule - it no longer bails out with a NullPtrException on interfaces that declare a method signature "equals(Object)". Thx to Don Leckie for catching that.
Added an optional Ant task formatter attribute 'isReportFilePathAbsolute'. Thx to Andriy Rozeluk for the feedback.
+Added an optional Ant task attribute 'failOnRuleViolation'. This stops the build if any rule violations are found.
January 22, 2003 - 1.02:
Added new rules: ImportFromSamePackageRule, SwitchDensityRule, NullAssignmentRule, UnusedModifierRule, ForLoopShouldBeWhileLoopRule
diff --git a/pmd/etc/doing_the_next_pmd_release.txt b/pmd/etc/doing_the_next_pmd_release.txt
index e8a416b8fc..6aa62d1fc5 100644
--- a/pmd/etc/doing_the_next_pmd_release.txt
+++ b/pmd/etc/doing_the_next_pmd_release.txt
@@ -1,4 +1,14 @@
-UPDATE THE ANT XDOCS WITH isReportFilePathAbsolute ATTRIBUTE!
+
+
+
+>>>>>>>>>>>>> UPDATE THE ANT XDOCS WITH isReportFilePathAbsolute ATTRIBUTE!
+
+
+
+>>>>>>>>>>>>> UPDATE THE ANT XDOCS WITH failOnRuleViolation ATTRIBUTE!
+
+
+
Move rulesets/tmp.xml somewhere else
diff --git a/pmd/src/net/sourceforge/pmd/Report.java b/pmd/src/net/sourceforge/pmd/Report.java
index cfd17647e7..521d7a6380 100644
--- a/pmd/src/net/sourceforge/pmd/Report.java
+++ b/pmd/src/net/sourceforge/pmd/Report.java
@@ -16,9 +16,21 @@ import java.util.TreeSet;
public class Report {
+ public static class ProcessingError {
+ private String msg;
+ private String file;
+ public ProcessingError(String msg, String file) {
+ this.msg = msg;
+ this.file = file;
+ }
+ public String getMsg() {return msg;}
+ public String getFile() {return file;}
+ }
+
private Set violations = new TreeSet(new RuleViolation.RuleViolationComparator());
private Set metrics = new HashSet();
private List listeners = new ArrayList();
+ private List errors = new ArrayList();
public void addListener(ReportListener listener) {
listeners.add(listener);
@@ -39,7 +51,11 @@ public class Report {
listener.metricAdded( metric );
}
}
-
+
+ public void addError(ProcessingError error) {
+ errors.add(error);
+ }
+
public boolean hasMetrics() {
return !metrics.isEmpty();
}
@@ -56,6 +72,10 @@ public class Report {
return violations.iterator();
}
+ public Iterator errors() {
+ return errors.iterator();
+ }
+
public int size() {
return violations.size();
}
diff --git a/pmd/src/net/sourceforge/pmd/ant/PMDTask.java b/pmd/src/net/sourceforge/pmd/ant/PMDTask.java
index e0444c1b36..bae129f4de 100644
--- a/pmd/src/net/sourceforge/pmd/ant/PMDTask.java
+++ b/pmd/src/net/sourceforge/pmd/ant/PMDTask.java
@@ -66,6 +66,7 @@ public class PMDTask extends Task {
private boolean printToConsole;
private String ruleSetFiles;
private boolean failOnError;
+ private boolean failOnRuleViolation;
/**
* The end of line string for this machine.
@@ -76,8 +77,12 @@ public class PMDTask extends Task {
this.shortFilenames = value;
}
- public void setFailOnError(boolean failOnError) {
- this.failOnError = failOnError;
+ public void setFailOnError(boolean fail) {
+ this.failOnError = fail;
+ }
+
+ public void setFailOnRuleViolation(boolean fail) {
+ this.failOnRuleViolation = fail;
}
public void setVerbose(boolean verbose) {
@@ -125,10 +130,10 @@ public class PMDTask extends Task {
DirectoryScanner ds = fs.getDirectoryScanner(project);
String[] srcFiles = ds.getIncludedFiles();
for (int j=0; j");
}
+
+ // errors
+ for (Iterator i = report.errors(); i.hasNext();) {
+ Report.ProcessingError pe = (Report.ProcessingError)i.next();
+ buf.append(lineSep);
+ buf.append("', ">");
+ buf.append(attrs);
+ buf.append(lineSep);
+ buf.append("/>");
+ buf.append(lineSep);
+ }
+
buf.append("");
return buf.toString();
}