shawnlaffan / biodiverse

A tool for the spatial analysis of diversity
http://shawnlaffan.github.io/biodiverse/
GNU General Public License v3.0
75 stars 19 forks source link

code - remove camel case #417

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Need to change all uses of camel case in the code to use underscore format.

Original issue reported on code.google.com by shawnlaffan on 13 Nov 2013 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by shawnlaffan on 13 Nov 2013 at 3:44

GoogleCodeExporter commented 9 years ago

Original comment by shawnlaffan on 13 Nov 2013 at 3:49

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r1993.

renamed all camelCase variables in BasedataImport.pm

Original comment by arthurga...@gmail.com on 15 Nov 2013 at 12:57

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2026.

Renamed camelCase variables in BasedataImport.pm, CellPopup.pm, Dendrogram.pm, 
Grid.pm

Original comment by arthurga...@gmail.com on 21 Nov 2013 at 1:51

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2027.

Renamed camelCase variables in GUIManager.pm, PhylogenyImport.pm, 
MatrixGrid.pm, MatrixImport.pm, Popup.pm, Overlays.pm

Original comment by arthurga...@gmail.com on 21 Nov 2013 at 2:10

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2028.

Renamed camelCase variables in Clustering.pm, CalculationsTree.pm, Labels.pm, 
Outputs.pm, Spatial.pm

Original comment by arthurga...@gmail.com on 21 Nov 2013 at 4:29

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2029.

Renamed $buttonIDs to $button_IDs in Project.pm

Original comment by arthurga...@gmail.com on 21 Nov 2013 at 4:31

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2030.

Removed the extra space at the start of line 1 that broke the program.

Original comment by arthurga...@gmail.com on 21 Nov 2013 at 7:08

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2032.

Renamed camelCase variables in Spatial.pm, Tree,pm, SpatialParams.pm, 
Matrix.pm, BaseData.pm, TreeNode.pm, Index.pm, BaseStruct.pm, Randomise.pm, 
Cluster.pm, Common,pm

Original comment by arthurga...@gmail.com on 22 Nov 2013 at 3:26

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2033.

Renamed camelCase variables in Indices.pm, Matrix_Indices.pm, 
Numeric_Labels.pm, Phylogenetic.pm, Base.pm. This completes camelCase removal 
for all files in /lib/Biodiverse.

Original comment by arthurga...@gmail.com on 22 Nov 2013 at 3:38

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2034.

Fixed a refactoring error in Base.pm that broke the program. Removed a 
camelCase variable in Indices.pm that we missed.

Original comment by arthurga...@gmail.com on 22 Nov 2013 at 3:54

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Verified and correct.  

Original comment by shawnlaffan on 22 Nov 2013 at 5:03

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2036.

Merge changes onto trunk.
Had to resolve one conflict since to issue #418 shifted the SpatialParams file 
contents into SpatialConditions.  All else went smoothly.  

Original comment by shawnlaffan on 22 Nov 2013 at 6:00

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2037.

Add mergeinfo.  

Original comment by shawnlaffan on 22 Nov 2013 at 6:02

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2038.

Added to /xt the camelFinder.pl script I used to seek out all camelCase 
variable declarations. Removed camelCases in GDM_Input.pm, bench_numd.pl, 
num_dissim_using_listutil.pl.

Original comment by arthurga...@gmail.com on 22 Nov 2013 at 9:20

GoogleCodeExporter commented 9 years ago
Looks like there are no camelCase callbacks in the glade file, so we should be 
able to de-camel the GUI libs without worrying about glade mismatches.

Checked using a recursive search with this regex.  It matches any sub 
declaration, sub reference, or the "METHOD => '" strings in the Callbacks.pm 
generator hashes.  

(?:(?:sub\s+)|&|(?:METHOD\s*=>\s*'))([a-z]+(?:[A-Z][a-z]+)+)

It also allows us to use a find and replace approach to do things en masse 
assuming only Biodiverse subs are camelCase.  

A more stringent approach would find all the camelCase sub declarations and run 
a find and replace for each one in turn.

Original comment by shawnlaffan on 24 Nov 2013 at 10:08

GoogleCodeExporter commented 9 years ago
Actually, the more stringent approach is needed because it is simpler to handle 
multiHumpedCamelCase names using a script approach.

https://metacpan.org/pod/String::CamelCase has an approach which could be 
hacked or added using a /e modifier to run code in the regex replacement on $2, 
after we capture the leading text.  

match:
((?:sub\s+)|&|(?:METHOD\s*=>\s*'))([a-z]+(?:[A-Z][a-z]+){3}([A-Z][a-z]+)\b

replace:
$1$2_\L$3\E

Unfortunately Komodo appears not to support lower casing of matches since it 
uses python, which subs for this purpose.  

Original comment by shawnlaffan on 24 Nov 2013 at 10:38

GoogleCodeExporter commented 9 years ago
And now having tried using a one liner developed from 
http://blogs.msdn.com/b/steverowe/archive/2008/11/26/using-perl-for-mass-in-plac
e-editing.aspx , it is probably best to work explicitly, avoiding repetitions 
and manually handling the humps.  

Original comment by shawnlaffan on 24 Nov 2013 at 11:13

GoogleCodeExporter commented 9 years ago
Under Cygwin for one hump:

perl -pi.bak -e 
's/((?:sub\s+)|&|(?:METHOD\s*=>\s*))([a-z]+)([A-Z][a-z]+)\b/$1\L$2_$3\E/g' 
`find . -name '*.pm'`

Does not catch the methods properly (some sort of bash escape problem with the 
\'), but they are in the one file so easy to handle.

Original comment by shawnlaffan on 24 Nov 2013 at 11:14

GoogleCodeExporter commented 9 years ago
Need to also check for pre-existing non-camelcase subs.  

For example, Biodiverse::Project has init_models and initModels.  This needs to 
be sorted out.  Possibly the original is redundant.  

Original comment by shawnlaffan on 24 Nov 2013 at 11:21

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2039.

Script to find camel case sub names and check if they are already declared in 
that package.  
Does not find usages of fully qualified names (&Package::Name::subname).

Original comment by shawnlaffan on 25 Nov 2013 at 1:15

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2040.

Comment out redundant sub which clashes with soon-to-be-changed camel case 
variant.  

Original comment by shawnlaffan on 25 Nov 2013 at 1:16

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2041.

Change getWidget to get_widget.  It is a method name, so not clash with 
pre-existing calls to gtk version.  
Also remove old init_mo0dels sub.  

Original comment by shawnlaffan on 25 Nov 2013 at 2:28

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2042.

Add script used to find camelCase sub names.  
Could add option to do the editing as well...

Original comment by shawnlaffan on 25 Nov 2013 at 2:29

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2043.

Add option to apply changes to the files.  
Simplify the variable name conversion process.

Original comment by shawnlaffan on 25 Nov 2013 at 3:43

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2044.

Change all sub names to non-camel case.  Had to do some by hand since the 
script missed them.  
Script and other searches now find no such subs, but there are probably one or 
two lurking in the system.

Original comment by shawnlaffan on 25 Nov 2013 at 3:45

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2045.

Update the GUI script, and one of the test scripts.  

Original comment by shawnlaffan on 25 Nov 2013 at 3:55

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2046.

Merge changes across to the trunk.  
Had to clean up a few conflicts due to later changes on trunk, so need to 
rebase the branch.  

Original comment by shawnlaffan on 25 Nov 2013 at 4:29

GoogleCodeExporter commented 9 years ago
Branch issue_417_remove_camelCase needs to be rebased on trunk, but merge is 
throwing errors about revisions not previously merged.  
The simplest approach is to delete this branch.  Any new changes can be done on 
a new branch.  
That said, this issue is close to being closed barring any cleanup.

Original comment by shawnlaffan on 25 Nov 2013 at 4:35

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2047.

Rename camelFinder.pl to camel_varname_finder.pl to suit /xt folder's 
underscore naming style.

Original comment by arthurga...@gmail.com on 25 Nov 2013 at 7:10

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2048.

Remove old camelFinder.pl.

Original comment by arthurga...@gmail.com on 25 Nov 2013 at 7:32

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2049.

Edit Glade callback (missed that one in the search)

Original comment by shawnlaffan on 26 Nov 2013 at 6:07

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2050.

More clean up. 

Original comment by shawnlaffan on 26 Nov 2013 at 7:03

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2051.

Put the syntax check button back.  It was erroneously deleted in the conflict 
edit process.  

Original comment by shawnlaffan on 26 Nov 2013 at 7:19

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2055.

Found some more.  

Original comment by shawnlaffan on 28 Nov 2013 at 8:39

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r2114.

Fix an errant camel case call.  

Original comment by shawnlaffan on 6 Feb 2014 at 3:03

GoogleCodeExporter commented 9 years ago
Take ownership. 

Original comment by shawnlaffan on 6 Feb 2014 at 4:33

GoogleCodeExporter commented 9 years ago
Mark issue as fixed.  
A search adding fully qualified sub names (Foo::Bar::camelCaseSub) to the regex 
found nothing.  

Original comment by shawnlaffan on 6 Feb 2014 at 4:40

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2182.

Original comment by shawnlaffan on 6 Mar 2014 at 3:12