From b3f1abb8530aef390616fc8db061a9b6833fabbe Mon Sep 17 00:00:00 2001 From: Philippe Herlin Date: Tue, 10 May 2005 21:49:29 +0000 Subject: [PATCH] Fix new violations detected by PMD 3.1 git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3491 51baf565-9d33-0410-a72c-fc3788e3496d --- .../command/AbstractProcessableCommand.java | 1 + .../command/DefaultCommandProcessor.java | 1 + .../DefaultCommandProcessorStrategy.java | 6 ++--- .../pmd/eclipse/cmd/BaseVisitor.java | 22 ++++++++++--------- .../pmd/eclipse/cmd/ReviewCodeCmd.java | 4 ++++ .../eclipse/cmd/RunnableCommandProcessor.java | 5 +++++ .../pmd/eclipse/model/ModelFactory.java | 7 ++++++ .../eclipse/properties/PMDPropertyPage.java | 10 +++++---- .../properties/PMDPropertyPageController.java | 14 +++++++----- 9 files changed, 47 insertions(+), 23 deletions(-) diff --git a/pmd-eclipse/src/name/herlin/command/AbstractProcessableCommand.java b/pmd-eclipse/src/name/herlin/command/AbstractProcessableCommand.java index 7cf6bc971a..6f4fa66d38 100644 --- a/pmd-eclipse/src/name/herlin/command/AbstractProcessableCommand.java +++ b/pmd-eclipse/src/name/herlin/command/AbstractProcessableCommand.java @@ -30,6 +30,7 @@ import java.util.ResourceBundle; * @see name.herlin.command.CommandProcessor for more details on processor. */ public abstract class AbstractProcessableCommand implements Command { + // @PMD:REVIEWED:SingularField: by Herlin on 10/05/05 23:24 private CommandProcessor commandProcessor; /** diff --git a/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessor.java b/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessor.java index 8fd4275a6e..5aad1c4686 100644 --- a/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessor.java +++ b/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessor.java @@ -53,6 +53,7 @@ public class DefaultCommandProcessor implements CommandProcessor { /** * @see name.herlin.command.CommandProcessor#waitCommandToFinish(name.herlin.command.AbstractProcessableCommand) */ + // @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:30 public void waitCommandToFinish(final AbstractProcessableCommand aCommand) throws CommandException { // Do nothing because a default command executes synchronously // So when this method is executed the command has already terminated diff --git a/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessorStrategy.java b/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessorStrategy.java index f1873f5b8c..326bdd22e8 100644 --- a/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessorStrategy.java +++ b/pmd-eclipse/src/name/herlin/command/DefaultCommandProcessorStrategy.java @@ -32,7 +32,7 @@ import java.util.ResourceBundle; * the framework default command processor. */ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy { - private final CommandProcessor defaultCommandProcessor = new DefaultCommandProcessor(); + private static final CommandProcessor DEFAULT_COMMAND_PROCESSOR = new DefaultCommandProcessor(); private final Map registeredCommandProcessors = new Hashtable(); /** @@ -55,7 +55,7 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy } if (aProcessor == null) { - aProcessor = this.defaultCommandProcessor; + aProcessor = DEFAULT_COMMAND_PROCESSOR; } return aProcessor; @@ -70,7 +70,7 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy CommandProcessor aProcessor = null; try { - final String processorClassName = (String) registeredCommandProcessors.get(aCommand.getName()); + final String processorClassName = (String) this.registeredCommandProcessors.get(aCommand.getName()); if (processorClassName != null) { final Class clazz = Class.forName(processorClassName); aProcessor = (CommandProcessor) clazz.newInstance(); diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/BaseVisitor.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/BaseVisitor.java index fe83f4d4db..3dd7b71e3c 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/BaseVisitor.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/BaseVisitor.java @@ -57,6 +57,9 @@ import org.eclipse.ui.ResourceWorkingSetFilter; * @version $Revision$ * * $Log$ + * Revision 1.2 2005/05/10 21:49:26 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.1 2005/05/07 13:32:04 phherlin * Continuing refactoring * Fix some PMD violations @@ -233,16 +236,15 @@ public class BaseVisitor { final String ruleName = tail.substring(0, tail.indexOf(':')); pendingReviews.push(ruleName); findLine = true; - } else if (!comment && findLine) { - if (!line.equals("") && !line.startsWith("//")) { - findLine = false; - while (!pendingReviews.empty()) { - // @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops: by Herlin on 01/05/05 18:36 - final Review review = new Review(); - review.ruleName = (String) pendingReviews.pop(); - review.lineNumber = lineNumber; - reviewsList.add(review); - } + } else if (!comment && findLine && !line.equals("") && !line.startsWith("//")) { + findLine = false; + while (!pendingReviews.empty()) { + // @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops: + // by Herlin on 01/05/05 18:36 + final Review review = new Review(); + review.ruleName = (String) pendingReviews.pop(); + review.lineNumber = lineNumber; + reviewsList.add(review); } } } diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/ReviewCodeCmd.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/ReviewCodeCmd.java index 42c3f226d0..c1798c33bf 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/ReviewCodeCmd.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/ReviewCodeCmd.java @@ -72,6 +72,9 @@ import org.eclipse.jdt.core.JavaCore; * @version $Revision$ * * $Log$ + * Revision 1.2 2005/05/10 21:49:18 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.1 2005/05/07 13:32:04 phherlin * Continuing refactoring * Fix some PMD violations @@ -321,6 +324,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand { return fVisitChildren; } + // @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:46 public boolean visit(final IResourceDelta delta) { count++; return true; diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/RunnableCommandProcessor.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/RunnableCommandProcessor.java index c61ff07119..779f884587 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/RunnableCommandProcessor.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/cmd/RunnableCommandProcessor.java @@ -59,6 +59,9 @@ import org.eclipse.core.runtime.Status; * @version $Revision$ * * $Log$ + * Revision 1.2 2005/05/10 21:49:26 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.1 2005/05/07 13:32:04 phherlin * Continuing refactoring * Fix some PMD violations @@ -101,6 +104,7 @@ public class RunnableCommandProcessor implements CommandProcessor, IWorkspaceRun /** * @see name.herlin.command.CommandProcessor#waitCommandToFinish(name.herlin.command.AbstractProcessableCommand) */ + // @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:46 public void waitCommandToFinish(final AbstractProcessableCommand aCommand) throws CommandException { // do noting } @@ -110,6 +114,7 @@ public class RunnableCommandProcessor implements CommandProcessor, IWorkspaceRun * @param monitor * @throws CoreException */ + // @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:48 public void run(final IProgressMonitor monitor) throws CoreException { try { this.command.execute(); diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/model/ModelFactory.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/model/ModelFactory.java index e4df9eb9bf..42cb287c35 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/model/ModelFactory.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/model/ModelFactory.java @@ -47,6 +47,9 @@ import org.eclipse.core.resources.IProject; * @version $Revision$ * * $Log$ + * Revision 1.3 2005/05/10 21:49:29 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.2 2005/05/07 13:32:04 phherlin * Continuing refactoring * Fix some PMD violations @@ -60,7 +63,11 @@ import org.eclipse.core.resources.IProject; */ public class ModelFactory { private static final ModelFactory SELF = new ModelFactory(); + + // @PMD:REVIEWED:SingularField: by Herlin on 10/05/05 23:42 private final Map projectPropertiesModels = new HashMap(); + + // @PMD:REVIEWED:SingularField: by Herlin on 10/05/05 23:42 private final PreferencesModel preferencesModel = new PreferencesModelImpl(); /** diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPage.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPage.java index 77f9e625bc..d4c56a7a7f 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPage.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPage.java @@ -74,6 +74,9 @@ import org.eclipse.ui.dialogs.PropertyPage; * @version $Revision$ * * $Log$ + * Revision 1.17 2005/05/10 21:49:27 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.16 2005/05/07 13:32:04 phherlin * Continuing refactoring * Fix some PMD violations @@ -141,7 +144,6 @@ public class PMDPropertyPage extends PropertyPage implements PMDConstants { private static final Log log = LogFactory.getLog("net.sourceforge.pmd.eclipse.properties.PMDPropertyPage"); private PMDPropertyPageController controller; private PMDPropertyPageBean model; - private IProject project; private Button enablePMDButton; protected TableViewer availableRulesTableViewer; private IWorkingSet selectedWorkingSet; @@ -155,14 +157,14 @@ public class PMDPropertyPage extends PropertyPage implements PMDConstants { protected Control createContents(final Composite parent) { log.info("PMD properties editing requested"); this.controller = new PMDPropertyPageController(this.getShell()); - this.project = (IProject) this.getElement().getAdapter(IProject.class); - this.controller.setProject(this.project); + final IProject project = (IProject) this.getElement().getAdapter(IProject.class); + this.controller.setProject(project); this.model = controller.getPropertyPageBean(); Composite composite = null; noDefaultAndApplyButton(); - if ((this.project.isAccessible()) && (this.model != null)) { + if ((project.isAccessible()) && (this.model != null)) { composite = new Composite(parent, SWT.NONE); final GridLayout layout = new GridLayout(); diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPageController.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPageController.java index 4f50ec141e..4280eba211 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPageController.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/properties/PMDPropertyPageController.java @@ -68,6 +68,9 @@ import org.eclipse.ui.progress.IProgressService; * @version $Revision$ * * $Log$ + * Revision 1.6 2005/05/10 21:49:29 phherlin + * Fix new violations detected by PMD 3.1 + * * Revision 1.5 2005/05/07 13:32:05 phherlin * Continuing refactoring * Fix some PMD violations @@ -91,7 +94,6 @@ public class PMDPropertyPageController implements IRunnableWithProgress, PMDCons private final Shell shell; private IProject project; private PMDPropertyPageBean propertyPageBean; - private ProjectPropertiesModel projectPropertiesModel; private boolean rebuildNeeded; /** @@ -132,13 +134,13 @@ public class PMDPropertyPageController implements IRunnableWithProgress, PMDCons if (this.propertyPageBean == null) { try { - this.projectPropertiesModel = ModelFactory.getFactory().getProperiesModelForProject(this.project); + final ProjectPropertiesModel model = ModelFactory.getFactory().getProperiesModelForProject(this.project); this.propertyPageBean = new PMDPropertyPageBean(); - this.propertyPageBean.setPmdEnabled(this.projectPropertiesModel.isPmdEnabled()); - this.propertyPageBean.setProjectWorkingSet(this.projectPropertiesModel.getProjectWorkingSet()); - this.propertyPageBean.setProjectRuleSet(this.projectPropertiesModel.getProjectRuleSet()); - this.propertyPageBean.setRuleSetStoredInProject(this.projectPropertiesModel.isRuleSetStoredInProject()); + this.propertyPageBean.setPmdEnabled(model.isPmdEnabled()); + this.propertyPageBean.setProjectWorkingSet(model.getProjectWorkingSet()); + this.propertyPageBean.setProjectRuleSet(model.getProjectRuleSet()); + this.propertyPageBean.setRuleSetStoredInProject(model.isRuleSetStoredInProject()); } catch (ModelException e) { PMDPlugin.getDefault().showError(e.getMessage(), e); }