minor cleanup
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7387 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
1 parent
4260e6aed6
commit
eb42fcb7a0
3 files changed
+14
-9
No files matched your search
@@ -30,6 +30,8 @@ import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
import net.sourceforge.pmd.renderers.AbstractRenderer;
|
||||
import net.sourceforge.pmd.renderers.Renderer;
|
||||
import net.sourceforge.pmd.util.IOUtil;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
import net.sourceforge.pmd.util.datasource.DataSource;
|
||||
import net.sourceforge.pmd.util.datasource.FileDataSource;
|
||||
import net.sourceforge.pmd.util.log.AntLogHandler;
|
||||
@@ -199,15 +201,14 @@ public class PMDTask extends Task {
|
||||
ruleSetFactory.setClassLoader(configuration.getClassLoader());
|
||||
try {
|
||||
// This is just used to validate and display rules. Each thread will create its own ruleset
|
||||
RuleSets rules;
|
||||
ruleSetFactory.setMinimumPriority(configuration.getMinimumPriority());
|
||||
ruleSetFactory.setWarnDeprecated(true);
|
||||
String ruleSets = configuration.getRuleSets();
|
||||
if (ruleSets != null) {
|
||||
if (StringUtil.isNotEmpty(ruleSets)) {
|
||||
// Substitute env variables/properties
|
||||
configuration.setRuleSets(getProject().replaceProperties(ruleSets));
|
||||
}
|
||||
rules = ruleSetFactory.createRuleSets(configuration.getRuleSets());
|
||||
RuleSets rules = ruleSetFactory.createRuleSets(configuration.getRuleSets());
|
||||
ruleSetFactory.setWarnDeprecated(false);
|
||||
logRulesUsed(rules);
|
||||
} catch (RuleSetNotFoundException e) {
|
||||
@@ -280,6 +281,7 @@ public class PMDTask extends Task {
|
||||
PrintWriter printWriter = new PrintWriter(strWriter);
|
||||
pmde.getCause().printStackTrace(printWriter);
|
||||
log(strWriter.toString(), Project.MSG_VERBOSE);
|
||||
IOUtil.closeQuietly(printWriter);
|
||||
}
|
||||
if (pmde.getCause() != null && pmde.getCause().getMessage() != null) {
|
||||
log(pmde.getCause().getMessage(), Project.MSG_VERBOSE);
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
|
||||
import net.sourceforge.pmd.lang.java.ast.Comment;
|
||||
import net.sourceforge.pmd.lang.rule.properties.BooleanProperty;
|
||||
import net.sourceforge.pmd.lang.rule.properties.StringMultiProperty;
|
||||
import net.sourceforge.pmd.util.CollectionUtil;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
/**
|
||||
@@ -136,7 +137,8 @@ public class CommentContentRule extends AbstractCommentRule {
|
||||
}
|
||||
|
||||
public boolean hasDissallowedTerms() {
|
||||
return getProperty(DISSALLOWED_TERMS_DESCRIPTOR).length > 0;
|
||||
String[] terms = getProperty(DISSALLOWED_TERMS_DESCRIPTOR);
|
||||
return CollectionUtil.isNotEmpty(terms);
|
||||
}
|
||||
|
||||
public String dysfunctionReason() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
|
||||
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
|
||||
import net.sourceforge.pmd.lang.rule.properties.StringMultiProperty;
|
||||
import net.sourceforge.pmd.util.CollectionUtil;
|
||||
|
||||
/**
|
||||
* The loose package coupling Rule can be used to ensure coupling outside of
|
||||
@@ -32,10 +33,10 @@ import net.sourceforge.pmd.lang.rule.properties.StringMultiProperty;
|
||||
*/
|
||||
public class LoosePackageCouplingRule extends AbstractJavaRule {
|
||||
|
||||
private static final StringMultiProperty PACKAGES_DESCRIPTOR = new StringMultiProperty("packages", "Restricted packages",
|
||||
public static final StringMultiProperty PACKAGES_DESCRIPTOR = new StringMultiProperty("packages", "Restricted packages",
|
||||
new String[] {}, 1.0f, ',');
|
||||
|
||||
private static final StringMultiProperty CLASSES_DESCRIPTOR = new StringMultiProperty("classes", "Allowed classes",
|
||||
public static final StringMultiProperty CLASSES_DESCRIPTOR = new StringMultiProperty("classes", "Allowed classes",
|
||||
new String[] {}, 2.0f, ',');
|
||||
|
||||
// The package of this source file
|
||||
@@ -122,11 +123,11 @@ public class LoosePackageCouplingRule extends AbstractJavaRule {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean checksNothing() {
|
||||
|
||||
return getProperty(PACKAGES_DESCRIPTOR).length == 0 &&
|
||||
getProperty(CLASSES_DESCRIPTOR).length == 0 ;
|
||||
return
|
||||
CollectionUtil.isEmpty(getProperty(PACKAGES_DESCRIPTOR)) &&
|
||||
CollectionUtil.isEmpty(getProperty(CLASSES_DESCRIPTOR)) ;
|
||||
}
|
||||
|
||||
public String dysfunctionReason() {
|
||||
|
||||
Reference in new issue
Block a user