From 12c5faef8594e33c84822adc40f209b5a2fbee9f Mon Sep 17 00:00:00 2001 From: Brian Remedios Date: Sat, 25 Oct 2008 22:41:39 +0000 Subject: [PATCH] typos & minor optimizations git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6674 51baf565-9d33-0410-a72c-fc3788e3496d --- .../runtime/cmd/AbstractDefaultCommand.java | 2 +- .../pmd/eclipse/runtime/cmd/BaseVisitor.java | 21 ++++++++++--------- .../runtime/cmd/DetectCutAndPasteCmd.java | 4 ++-- .../eclipse/runtime/cmd/RenderReportCmd.java | 2 +- .../eclipse/runtime/cmd/ReviewCodeCmd.java | 4 ++-- .../cmd/ReviewResourceForRuleCommand.java | 4 +--- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java index 6e17511053..84bfbfa8e3 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java @@ -222,7 +222,7 @@ public abstract class AbstractDefaultCommand extends AbstractProcessableCommand } /** - * deletegate method for monitor.isCanceled() + * delegate method for monitor.isCanceled() * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled */ protected boolean isCanceled() { diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java index c93de54759..0619cc7d3e 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java @@ -48,6 +48,7 @@ import net.sourceforge.pmd.eclipse.plugin.PMDPlugin; import net.sourceforge.pmd.eclipse.runtime.preferences.IPreferences; import net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties; import net.sourceforge.pmd.eclipse.runtime.properties.PropertiesException; +import net.sourceforge.pmd.util.NumericConstants; import org.apache.log4j.Logger; import org.eclipse.core.resources.IFile; @@ -335,7 +336,7 @@ public class BaseVisitor { } else { Integer counter = violationsCounter.get(violation.getRule()); if (counter == null) { - counter = new Integer(0); + counter = NumericConstants.ZERO; violationsCounter.put(violation.getRule(), counter); } @@ -352,7 +353,7 @@ public class BaseVisitor { markerSet.add(getMarkerInfo(violation, fTask ? PMDRuntimeConstants.PMD_TASKMARKER : PMDRuntimeConstants.PMD_MARKER)); } */ - violationsCounter.put(violation.getRule(), new Integer(counter.intValue() + 1)); + violationsCounter.put(violation.getRule(), Integer.valueOf(counter.intValue() + 1)); log.debug("Adding a violation for rule " + violation.getRule().getName() + " at line " + violation.getBeginLine()); } else { @@ -448,38 +449,38 @@ public class BaseVisitor { values.add(violation.getDescription()); attributeNames.add(IMarker.LINE_NUMBER); - values.add(new Integer(violation.getBeginLine())); + values.add(Integer.valueOf(violation.getBeginLine())); attributeNames.add(PMDRuntimeConstants.KEY_MARKERATT_LINE2); - values.add(new Integer(violation.getEndLine())); + values.add(Integer.valueOf(violation.getEndLine())); attributeNames.add(PMDRuntimeConstants.KEY_MARKERATT_RULENAME); values.add(violation.getRule().getName()); attributeNames.add(PMDRuntimeConstants.KEY_MARKERATT_PRIORITY); - values.add(new Integer(violation.getRule().getPriority().getPriority())); + values.add(Integer.valueOf(violation.getRule().getPriority().getPriority())); switch (violation.getRule().getPriority().getPriority()) { case 1: attributeNames.add(IMarker.PRIORITY); - values.add(new Integer(IMarker.PRIORITY_HIGH)); + values.add(Integer.valueOf(IMarker.PRIORITY_HIGH)); case 2: attributeNames.add(IMarker.SEVERITY); - values.add(new Integer(IMarker.SEVERITY_ERROR)); + values.add(Integer.valueOf(IMarker.SEVERITY_ERROR)); break; case 5: attributeNames.add(IMarker.SEVERITY); - values.add(new Integer(IMarker.SEVERITY_INFO)); + values.add(Integer.valueOf(IMarker.SEVERITY_INFO)); break; case 3: attributeNames.add(IMarker.PRIORITY); - values.add(new Integer(IMarker.PRIORITY_HIGH)); + values.add(Integer.valueOf(IMarker.PRIORITY_HIGH)); case 4: default: attributeNames.add(IMarker.SEVERITY); - values.add(new Integer(IMarker.SEVERITY_WARNING)); + values.add(Integer.valueOf(IMarker.SEVERITY_WARNING)); break; } diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java index 3619a74343..35e7f8b9fd 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java @@ -105,9 +105,9 @@ public class DetectCutAndPasteCmd extends AbstractDefaultCommand { final List files = findFiles(); if (files.size() == 0) { - PMDPlugin.getDefault().logInformation("No files found to specified language."); + PMDPlugin.getDefault().logInformation("No files found for specified language."); } else { - PMDPlugin.getDefault().logInformation("Found " + files.size() + " files to the specified language. Performing CPD."); + PMDPlugin.getDefault().logInformation("Found " + files.size() + " files for the specified language. Performing CPD."); } setStepsCount(files.size()); beginTask("Finding suspect Cut And Paste", getStepsCount()*2); diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportCmd.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportCmd.java index 4f30a3171b..ff187239eb 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportCmd.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/RenderReportCmd.java @@ -77,7 +77,7 @@ public class RenderReportCmd extends AbstractDefaultCommand { /** * Table containing the renderers indexed by the file name. */ - private HashMap renderers = new HashMap(); + private Map renderers = new HashMap(); /** * Default Constructor diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java index e84fdd112a..218b2e9edf 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCodeCmd.java @@ -120,7 +120,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand { this.pmdDuration = 0; // Lancer PMD - if (this.resources.size() == 0) { + if (this.resources.isEmpty()) { beginTask("PMD Checking...", getStepsCount()); processResourceDelta(); } else { @@ -251,7 +251,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand { final IResourceRuleFactory ruleFactory = workspace.getRuleFactory(); ISchedulingRule rule = null; - if (this.resources.size() == 0) { + if (this.resources.isEmpty()) { rule = ruleFactory.markerRule(this.resourceDelta.getResource().getProject()); } else { ISchedulingRule rules[] = new ISchedulingRule[this.resources.size()]; diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java index 322a38ffe8..1d0b166226 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/src/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewResourceForRuleCommand.java @@ -123,9 +123,7 @@ public class ReviewResourceForRuleCommand extends AbstractDefaultCommand { final IFile file = (IFile) resource.getAdapter(IFile.class); beginTask("PMD Checking for specific rule...", 1); - if (file != null - && file.getFileExtension() != null - && file.getFileExtension().equals("java")) { + if (file != null && "java".equals(file.getFileExtension())) { final RuleSet ruleSet = new RuleSet(); ruleSet.addRule(rule); final PMDEngine pmdEngine = getPmdEngineForProject(project);