Bug 466859 - Commands set their results in their constructors
Summary: Commands set their results in their constructors
Status: NEW
Alias: None
Product: Papyrus
Classification: Modeling
Component: Others (show other bugs)
Version: 1.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-08 11:41 EDT by Christian Damus CLA
Modified: 2015-05-08 11:41 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Damus CLA 2015-05-08 11:41:14 EDT
Mars M7 - found in inspection of FindBugs problems

Many (but not all) of the GMF-style commands in Papyrus set CommandResults in their constructors.  Commands are not supposed to have results until they have been executed, except for special instances like the IdentityCommand or UnexecutableCommand that are reused and don't do anything.  Otherwise, the result cannot be valid or useful until the command has been executed.  The usual practice is just to return the result from the doExecute() method, which all of these commands in Papyrus do anyways.

A search that may well have missed some cases:

org.eclipse.papyrus.infra.gmfdiag.common
CommonDeferredCreateConnectionViewCommand.java (2 matches)
76: setResult(CommandResult.newOKCommandResult()); 
105: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 

org.eclipse.papyrus.uml.diagram.clazz
AssociationDiamonViewCreateCommand.java
73: setResult(CommandResult.newOKCommandResult(semanticAdapter));  
DependencyDiamonViewCreateCommand.java
72: setResult(CommandResult.newOKCommandResult(semanticAdapter));  

org.eclipse.papyrus.uml.diagram.communication
CustomMessageSemanticCreateCommand.java
79: setResult(CommandResult.newOKCommandResult(this.semanticAdapter)); 
CustomMessageViewCreateCommand.java
105: setResult(CommandResult.newOKCommandResult(semanticViewApdater)); 
DiagramShortCutCreationViewCommand.java
57: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 

org.eclipse.papyrus.uml.diagram.component
LollipopToRectangleCommand.java
63: setResult(CommandResult.newOKCommandResult(semanticAdapter));  
RectangleToLollipopCommand.java
62: setResult(CommandResult.newOKCommandResult(semanticAdapter)); 
DependencyDiamonViewCreateCommand.java
77: setResult(CommandResult.newOKCommandResult(semanticAdapter)); 

org.eclipse.papyrus.uml.diagram.composite
CollaborationUseFromTypeCreateCommand.java
50: setResult(CommandResult.newOKCommandResult(semanticAdapter));  
PropertyPartFromTypeCreateCommand.java
49: setResult(CommandResult.newOKCommandResult(semanticAdapter)); 

org.eclipse.papyrus.uml.diagram.deployment
DependencyDiamonViewCreateCommand.java
84: setResult(CommandResult.newOKCommandResult(semanticAdapter)); 

org.eclipse.papyrus.uml.diagram.profile
AssociationDiamondViewCreateCommand.java
94: setResult(CommandResult.newOKCommandResult(semanticAdapter));  
CustomMetaClassCreateCommand.java
84: setResult(CommandResult.newOKCommandResult(viewDescriptor));  
DependencyDiamondViewCreateCommand.java
100: setResult(CommandResult.newOKCommandResult(semanticAdapter));  

org.eclipse.papyrus.uml.diagram.sequence
CreateGateViewCommand.java
78: setResult(CommandResult.newOKCommandResult(resultAdapter));  

org.eclipse.papyrus.uml.diagram.statemachine
CustomCompositeStateSetBoundsCommand.java
51: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomCompositeStateWithDefaultRegionCreateNodeCommand.java
50: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomFirstRegionInCompositeStateCreateElementCommand.java
66: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomFirstRegionInStateMachineCreateElementCommand.java
61: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomRegionCreateElementCommand.java
63: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomRegionMoveCommand.java
53: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomRegionResizeCommand.java
49: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomStateMachineResizeCommand.java
55: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomStateMachineSetBoundsCommand.java
49: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomStateMachineWithDefaultRegionCreateNodeCommand.java
50: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomStateResizeCommand.java
58: setResult(CommandResult.newOKCommandResult(viewDescriptor)); 
CustomVertexCreateElementCommand.java
71: setResult(CommandResult.newOKCommandResult(viewDescriptor));