Bug #4926
closedExamine Kepler for duplicated Ptolemy code
0%
Description
There are a few files in Kepler that have Edward listed as an author.
I suspect that some of these are duplicated code from the Ptolemy II tree.
In the 2.0 release, I searched all the java files for Edward's name and
came up with this list:
bash-3.2$ find . -name "*.java" > /tmp/kj
bash-3.2$ cat /tmp/kj | grep -v ptolemy-8.0 | xargs grep "Edward A. Lee"
./actors-2.0/src/org/sdm/spa/CommandLineExec.java: * Contributor: Edward A. Lee
./actors-2.0/src/org/sdm/spa/gui/ShellInterpreter.java: * @author Edward A. Lee
./actors-2.0/src/org/sdm/spa/gui/ShellTextArea.java: * @author John Reekie, Christopher Hylands, Edward A. Lee
./actors-2.0/src/org/sdm/spa/gui/UserInteractiveShell.java: * This actor code is adopted from InteractiveShell.java by Edward A. Lee
./ecogrid-2.0/src/ptolemy/vergil/tree/PTree.java: @author Steve Neuendorffer and Edward A. Lee
./gui-2.0/src/org/kepler/gui/frame/CaseGraphFrame.java: @author Edward A. Lee
./gui-2.0/src/org/kepler/gui/frame/CaseGraphTableau.java: @author Edward A. Lee
./gui-2.0/src/org/kepler/gui/frame/KeplerGraphTableau.java: @author Based on GraphTableau by Steve Neuendorffer and Edward A. Lee
./gui-2.0/src/org/kepler/gui/frame/MultiCompositeGraphFrame.java: @author Edward A. Lee, Daniel Crawl
./gui-2.0/src/org/kepler/gui/frame/MultiCompositeTableau.java: @author Edward A. Lee, Daniel Crawl
./gui-2.0/src/org/kepler/gui/KeplerIconLoader.java: * @author Christopher Brooks, contributor: Edward A. Lee
./gui-2.0/src/org/kepler/gui/KeplerXMLIcon.java: * @author Steve Neuendorffer, John Reekie, Contributor: Edward A. Lee
./util-2.0/src/util/LineReader.java: * @author Edward A. Lee, Yuhong Xiong
bash-3.2$
Sean Riddle is in the process of fixing the PTree duplication.
To close this bug, each of the files should be examined and ideally, the
original class in Ptolemy be modified and the copy be removed or made much smaller.
In addition, to close this bug, if Edward is not listed in the history for the
file, then he should be removed as an author and added as a contributor.
Updated by Christopher Brooks over 12 years ago
./actors/src/org/sdm/spa/gui/ShellTextArea.java
has trivial differences from
ptolemy/gui/ShellTextArea.java, so I removed the duplicate version.
I checked for duplicates using cpd at http://pmd.sourceforge.net/cpd.html
and with a minimum token count of 500, I did not find anything too bad.
Note that cpd does point out duplicates in Ptolemy II itself.
To run cpd, I used
java -Xmx5000m -classpath 'lib/*:saxon9-dom.jar' net.sourceforge.pmd.cpd.CPD --minimum-tokens 500 --files ~/src/kepler --format net.sourceforge.pmd.cpd.XMLRenderer > kepler.xml
xsltproc etc/xslt/cpdhtml.xslt kepler.xml > kepler.html
I'm retargetting this to 2.5.0 so it can be checked again.
Updated by Christopher Brooks over 12 years ago
kepler/gui/src/org/kepler/gui/KeplerGraphFrame.java has lots of duplicated
code from BasicGraphFrame. I'm targeting 2.4.0 with this fix because
KeplerGraphFrame is at the core of Kepler and should at least be reviewed.
The problem is that bug fixes that appear in BasicGraphFrame will
not appear in KeplerGraphFrame.
Also, there are several files with the same class name in Kepler:
4 FileCopier.java
2 Util.java
2 SshSession.java
2 ServiceUtils.java
2 RepositoryLocations.java
2 OntologyCatalog.java
2 NameValuePair.java
2 KeplerMetadataExtractorTest.java
2 Kepler.java
2 JobManager.java
2 Initialize.java
2 Domain.java
2 CommandLine.java
2 BuildTest.java
These files appear in both Ptolemy and Kepler and should be reviewed
AboutAction.java
ArrayContains.java
ArrayRemoveElement.java
Attribute.java
BackwardCompatibility.java
Branch.java
CacheManager.java
CaseGraphFrame.java
CaseGraphTableau.java
ClassChanges.java
Constants.java
Constraint.java
DatabaseQuery.java
DirectoryListing.java
DocumentationAttribute.java
Entity.java
ExecuteCommands.java
ExtensionFileFilter.java
FileAttribute.java
HelloWorld.java
LineReader.java
Node.java
Pause.java
PortNameChanges.java
PropertyClassChanges.java
Repeat.java
Sequence.java
StringConst.java
SwingWorker.java
Tag.java
Test.java
Also, Kepler has ArrayAccumulator.java and Ptolemy has ArrayAccumulate.
Updated by Christopher Brooks over 12 years ago
I looked in to why KeplerGraphFrame has so much duplicated code
and it looks like Comad uses KeplerGraphFrameExtension
From the 2010-11-04 comment that added this class:
// "Added an extension for a different Drag and Drop behavior.
// Currently this is only activated in Comad. Once an Actor is
// dragged from the Library over another actor on the canvas it
// will replace this actor and Ports are reconeected. Also
// Parameter values are used for parameters of the new actor if
// they have the same name.
//
// If an actor is dragged over a link this actor will be inserted
// there. Currently this only works in Comad, where all actors
// have an "input" and one "output" port."
The right thing is to add these extension points to the ptII repository
and remove the duplicated code.
Updated by Ilkay Altintas over 12 years ago
This should be done for each release in the end. It shouldn't be released if it doesn't meet some metrics or criteria. A possible metric is to get rid of it all. It also makes it harder to test upgrades.
1. Go through the list and identify duplicate/deprecated actors. (CXH)
2. Evaluate each issue on a case basis and document the potential solution.
3. Add each as a separate bug for a potential release 2.4 or later.
Updated by Christopher Brooks over 12 years ago
Look for duplicate file names:
- Get all the .java files except the ptolemy ones
find . -name "*.java" | grep -v ptolemy/src > /tmp/kjnop
- Get all the ptolemy.java files
find ptolemy/src -name "*.java" > /tmp/pj
- Get the Kepler .java files
awk -F / '{print $NF}' /tmp/kjnop | sort > /tmp/kjnopl
- Get the Ptolemy .java files
awk -F / '{print $NF}' /tmp/pj | sort > /tmp/pjl
- Print any files in common, create a script to find them in the Kepler java files
comm -12 /tmp/kjnopl /tmp/pjl | awk '{print "grep /" $1 " /tmp/kjnop"}' > /tmp/doit
- Run the script
sh /tmp/doit | sort
These are to be ignored:
########
./actors/src/org/geon/DatabaseQuery.java
Ignore? Duplicate of ptolemy/src/ptolemy/actor/lib/database/DatabaseQuery.java
########
./actors/src/org/sdm/spa/actors/piw/viz/Sequence.java
Ignore: Undocumented file, seems to construct a gene sequence?
########
./actors/src/org/sdm/spa/Pause.java
Ignore: Name match with: ptolemy/src/ptolemy/domains/coroutine/lib/Pause.java
#####
./build-area/src/org/kepler/build/Branch.java
./build-area/src/org/kepler/build/modules/Node.java
./build-area/src/org/kepler/build/Tag.java
./build-area/src/org/kepler/build/Test.java
./build-area/src/org/kepler/build/util/ExecuteCommands.java
Ignore these, they are part of the build system.
######
./core/src/org/kepler/moml/DocumentationAttribute.java
Ignore. This is deprecated:
@deprecated Use ptolemy.vergil.basic.KeplerDocumentationAttribute instead.
######
./core/src/org/kepler/objectmanager/cache/CacheManager.java
./core/src/org/kepler/objectmanager/data/db/Attribute.java
./core/src/org/kepler/objectmanager/data/db/Constraint.java
./core/src/org/kepler/objectmanager/data/db/Entity.java
./core/src/org/kepler/sms/Constants.java
Ignore the above, the names are common enough
######
./gui/src/org/kepler/gui/AboutAction.java
Ignore. Matches ptolemy/src/ptolemy/backtrack/eclipse/plugin/actions/AboutAction.java
####
./io/src/org/kepler/io/DirectoryListing.java
./outreach/workflows/demos/getting-started/HelloWorld.java
Ignore.
I've submitted separate bugs for the non-ignored duplicates.
I've checked the Kepler tree for code that says Edward is the author
and it looks good:
bash-4.1$ cat /tmp/kjnop | xargs grep "Edward A. Lee"
./gui/src/org/kepler/gui/KeplerXMLIcon.java: * @author Chad Berkley, based on XMLIcon by Steve Neuendorffer, John Reekie, Contributor: Edward A. Lee
./gui/src/org/kepler/gui/frame/MultiCompositeGraphFrame.java: @author Daniel Crawl, Possibly based on CaseGraphFrame by Edward A. Lee.
./gui/src/org/kepler/gui/frame/CaseGraphFrame.java: @author Daniel Crawl, based on ptolemy.vergil.modal.CaseGraphFrame by Edward A. Lee
./gui/src/org/kepler/gui/frame/CaseGraphTableau.java: @author Daniel Crawl, based on ptolemy.vergil.modal.CaseGraphFrame by Edward A. Lee
./gui/src/org/kepler/gui/frame/MultiCompositeTableau.java: @author Daniel Crawl, Possibly based on CaseGraphTableau by Edward A. Lee.
./gui/src/org/kepler/gui/frame/KeplerGraphTableau.java: @author Based on GraphTableau by Steve Neuendorffer and Edward A. Lee
./gui/src/org/kepler/gui/KeplerIconLoader.java: * @author Christopher Brooks, contributor: Edward A. Lee
./actors/src/org/sdm/spa/gui/UserInteractiveShell.java: * This actor code is adopted from InteractiveShell.java by Edward A. Lee
./actors/src/org/sdm/spa/Pause.java: * ptolemy.actor.lib.Stop actor code by Edward A. Lee.
./actors/src/org/sdm/spa/Pause.java: * @author Ilkay Altintas, Contributors: Edward A. Lee and Christopher Brooks.
./actors/src/org/sdm/spa/CommandLineExec.java: * Contributor: Edward A. Lee
grep: ./actors/src/org/resurgence/actor/.#FileCopier.java: No such file or directory
./util/src/util/LineReader.java: * @author Efrat Jaeger, based on LineReader by Edward A. Lee, Yuhong Xiong
I'm closing this because we have other bugs and opening a new bug for 2.5.0