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
This commit is contained in:
Philippe Herlin
2005-05-10 21:49:29 +00:00
parent f0979d5979
commit b3f1abb853
9 changed files with 47 additions and 23 deletions

View File

@ -30,6 +30,7 @@ import java.util.ResourceBundle;
* @see name.herlin.command.CommandProcessor for more details on processor. * @see name.herlin.command.CommandProcessor for more details on processor.
*/ */
public abstract class AbstractProcessableCommand implements Command { public abstract class AbstractProcessableCommand implements Command {
// @PMD:REVIEWED:SingularField: by Herlin on 10/05/05 23:24
private CommandProcessor commandProcessor; private CommandProcessor commandProcessor;
/** /**

View File

@ -53,6 +53,7 @@ public class DefaultCommandProcessor implements CommandProcessor {
/** /**
* @see name.herlin.command.CommandProcessor#waitCommandToFinish(name.herlin.command.AbstractProcessableCommand) * @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 { public void waitCommandToFinish(final AbstractProcessableCommand aCommand) throws CommandException {
// Do nothing because a default command executes synchronously // Do nothing because a default command executes synchronously
// So when this method is executed the command has already terminated // So when this method is executed the command has already terminated

View File

@ -32,7 +32,7 @@ import java.util.ResourceBundle;
* the framework default command processor. * the framework default command processor.
*/ */
public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy { 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(); private final Map registeredCommandProcessors = new Hashtable();
/** /**
@ -55,7 +55,7 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy
} }
if (aProcessor == null) { if (aProcessor == null) {
aProcessor = this.defaultCommandProcessor; aProcessor = DEFAULT_COMMAND_PROCESSOR;
} }
return aProcessor; return aProcessor;
@ -70,7 +70,7 @@ public class DefaultCommandProcessorStrategy implements CommandProcessorStrategy
CommandProcessor aProcessor = null; CommandProcessor aProcessor = null;
try { try {
final String processorClassName = (String) registeredCommandProcessors.get(aCommand.getName()); final String processorClassName = (String) this.registeredCommandProcessors.get(aCommand.getName());
if (processorClassName != null) { if (processorClassName != null) {
final Class clazz = Class.forName(processorClassName); final Class clazz = Class.forName(processorClassName);
aProcessor = (CommandProcessor) clazz.newInstance(); aProcessor = (CommandProcessor) clazz.newInstance();

View File

@ -57,6 +57,9 @@ import org.eclipse.ui.ResourceWorkingSetFilter;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.1 2005/05/07 13:32:04 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * Fix some PMD violations
@ -233,16 +236,15 @@ public class BaseVisitor {
final String ruleName = tail.substring(0, tail.indexOf(':')); final String ruleName = tail.substring(0, tail.indexOf(':'));
pendingReviews.push(ruleName); pendingReviews.push(ruleName);
findLine = true; findLine = true;
} else if (!comment && findLine) { } else if (!comment && findLine && !line.equals("") && !line.startsWith("//")) {
if (!line.equals("") && !line.startsWith("//")) { findLine = false;
findLine = false; while (!pendingReviews.empty()) {
while (!pendingReviews.empty()) { // @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops:
// @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops: by Herlin on 01/05/05 18:36 // by Herlin on 01/05/05 18:36
final Review review = new Review(); final Review review = new Review();
review.ruleName = (String) pendingReviews.pop(); review.ruleName = (String) pendingReviews.pop();
review.lineNumber = lineNumber; review.lineNumber = lineNumber;
reviewsList.add(review); reviewsList.add(review);
}
} }
} }
} }

View File

@ -72,6 +72,9 @@ import org.eclipse.jdt.core.JavaCore;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.1 2005/05/07 13:32:04 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * Fix some PMD violations
@ -321,6 +324,7 @@ public class ReviewCodeCmd extends AbstractDefaultCommand {
return fVisitChildren; return fVisitChildren;
} }
// @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:46
public boolean visit(final IResourceDelta delta) { public boolean visit(final IResourceDelta delta) {
count++; count++;
return true; return true;

View File

@ -59,6 +59,9 @@ import org.eclipse.core.runtime.Status;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.1 2005/05/07 13:32:04 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * Fix some PMD violations
@ -101,6 +104,7 @@ public class RunnableCommandProcessor implements CommandProcessor, IWorkspaceRun
/** /**
* @see name.herlin.command.CommandProcessor#waitCommandToFinish(name.herlin.command.AbstractProcessableCommand) * @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 { public void waitCommandToFinish(final AbstractProcessableCommand aCommand) throws CommandException {
// do noting // do noting
} }
@ -110,6 +114,7 @@ public class RunnableCommandProcessor implements CommandProcessor, IWorkspaceRun
* @param monitor * @param monitor
* @throws CoreException * @throws CoreException
*/ */
// @PMD:REVIEWED:UnusedFormalParameter: by Herlin on 10/05/05 23:48
public void run(final IProgressMonitor monitor) throws CoreException { public void run(final IProgressMonitor monitor) throws CoreException {
try { try {
this.command.execute(); this.command.execute();

View File

@ -47,6 +47,9 @@ import org.eclipse.core.resources.IProject;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.2 2005/05/07 13:32:04 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * Fix some PMD violations
@ -60,7 +63,11 @@ import org.eclipse.core.resources.IProject;
*/ */
public class ModelFactory { public class ModelFactory {
private static final ModelFactory SELF = new 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(); private final Map projectPropertiesModels = new HashMap();
// @PMD:REVIEWED:SingularField: by Herlin on 10/05/05 23:42
private final PreferencesModel preferencesModel = new PreferencesModelImpl(); private final PreferencesModel preferencesModel = new PreferencesModelImpl();
/** /**

View File

@ -74,6 +74,9 @@ import org.eclipse.ui.dialogs.PropertyPage;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.16 2005/05/07 13:32:04 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * 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 static final Log log = LogFactory.getLog("net.sourceforge.pmd.eclipse.properties.PMDPropertyPage");
private PMDPropertyPageController controller; private PMDPropertyPageController controller;
private PMDPropertyPageBean model; private PMDPropertyPageBean model;
private IProject project;
private Button enablePMDButton; private Button enablePMDButton;
protected TableViewer availableRulesTableViewer; protected TableViewer availableRulesTableViewer;
private IWorkingSet selectedWorkingSet; private IWorkingSet selectedWorkingSet;
@ -155,14 +157,14 @@ public class PMDPropertyPage extends PropertyPage implements PMDConstants {
protected Control createContents(final Composite parent) { protected Control createContents(final Composite parent) {
log.info("PMD properties editing requested"); log.info("PMD properties editing requested");
this.controller = new PMDPropertyPageController(this.getShell()); this.controller = new PMDPropertyPageController(this.getShell());
this.project = (IProject) this.getElement().getAdapter(IProject.class); final IProject project = (IProject) this.getElement().getAdapter(IProject.class);
this.controller.setProject(this.project); this.controller.setProject(project);
this.model = controller.getPropertyPageBean(); this.model = controller.getPropertyPageBean();
Composite composite = null; Composite composite = null;
noDefaultAndApplyButton(); noDefaultAndApplyButton();
if ((this.project.isAccessible()) && (this.model != null)) { if ((project.isAccessible()) && (this.model != null)) {
composite = new Composite(parent, SWT.NONE); composite = new Composite(parent, SWT.NONE);
final GridLayout layout = new GridLayout(); final GridLayout layout = new GridLayout();

View File

@ -68,6 +68,9 @@ import org.eclipse.ui.progress.IProgressService;
* @version $Revision$ * @version $Revision$
* *
* $Log$ * $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 * Revision 1.5 2005/05/07 13:32:05 phherlin
* Continuing refactoring * Continuing refactoring
* Fix some PMD violations * Fix some PMD violations
@ -91,7 +94,6 @@ public class PMDPropertyPageController implements IRunnableWithProgress, PMDCons
private final Shell shell; private final Shell shell;
private IProject project; private IProject project;
private PMDPropertyPageBean propertyPageBean; private PMDPropertyPageBean propertyPageBean;
private ProjectPropertiesModel projectPropertiesModel;
private boolean rebuildNeeded; private boolean rebuildNeeded;
/** /**
@ -132,13 +134,13 @@ public class PMDPropertyPageController implements IRunnableWithProgress, PMDCons
if (this.propertyPageBean == null) { if (this.propertyPageBean == null) {
try { try {
this.projectPropertiesModel = ModelFactory.getFactory().getProperiesModelForProject(this.project); final ProjectPropertiesModel model = ModelFactory.getFactory().getProperiesModelForProject(this.project);
this.propertyPageBean = new PMDPropertyPageBean(); this.propertyPageBean = new PMDPropertyPageBean();
this.propertyPageBean.setPmdEnabled(this.projectPropertiesModel.isPmdEnabled()); this.propertyPageBean.setPmdEnabled(model.isPmdEnabled());
this.propertyPageBean.setProjectWorkingSet(this.projectPropertiesModel.getProjectWorkingSet()); this.propertyPageBean.setProjectWorkingSet(model.getProjectWorkingSet());
this.propertyPageBean.setProjectRuleSet(this.projectPropertiesModel.getProjectRuleSet()); this.propertyPageBean.setProjectRuleSet(model.getProjectRuleSet());
this.propertyPageBean.setRuleSetStoredInProject(this.projectPropertiesModel.isRuleSetStoredInProject()); this.propertyPageBean.setRuleSetStoredInProject(model.isRuleSetStoredInProject());
} catch (ModelException e) { } catch (ModelException e) {
PMDPlugin.getDefault().showError(e.getMessage(), e); PMDPlugin.getDefault().showError(e.getMessage(), e);
} }