Hi, some more comments. I forgot to uniq the names of the functions so the actual number I find is 688.
Then Ludmila told me that my search process has a little problem which is that I don't consider functions that are not directly called but are passed as arguments (e.g. when using re.sub with a function). Apparently this is the case for BibRank which would explain the 35 "orphan" functions in the module. Finally Sam reminded me about WebSubmit which by design produces lots of orphan functions. So it seems that my title was a bit exagerated. Benoit. On Thu, Jul 15, 2010 at 11:03 AM, Benoit Thiell <[email protected]> wrote: > Hi, > > lately I've been wondering how many functions have been written over > the years and then been forgotten about but remain still in the > Invenio codebase. Here are the results of my research : > > In total, there are 7029 functions in Invenio. 5770 of these functions > have unique names. Please note that my research was basic and I > considered that one name is one function. So my numbers are probably a > bit off. Doing it right (i.e. analyze the imports for each module) > would take me more than the 20 minutes I spent on the problem. > > Searching for all the function names was straightforward as it is > possible to do it with grep. Then I concatenated all the code of > Invenio in one gigantic file. Some cleaning allowed me to bring the > size of the file to around 70.000 interesting lines. Using only one > file is more efficient as I can use grep on one file only instead of > using a recursive grep that would have taken ages. > > Finally I looked for each function name in the code and saw if it is > used (i.e if not preceded by 'def '). I found 721 orphan functions. > > That is a pretty big number as it represents a bit more than 10% of > the functions in Invenio. Probably a part of these functions is meant > to be orphan (e.g. __str__() functions are used for manual debugging > only) but some if these functions could be discarded. > > Advantages would be: > * faster install. > * no pylint errors because of dusty old code. > * easier code reading. > > Of course there are also some inconvenience as people might have > developed code relying on some currently unused functions. > > Benoit. > > PS: Attached is a file containing all the orphan functions I found. > > PPS: Here is a breakdown of the number of orphan functions per module: > > bibcatalog 2 > bibcheck 1 > bibcirculation 49 > bibclassify 6 > bibconvert 9 > bibedit 16 > bibexport 2 > bibformat 60 > bibharvest 11 > bibindex 14 > bibknowledge 6 > bibmatch 1 > bibmerge 4 > bibrank 35 > bibsched 9 > bibupload 5 > elmsubmit 33 > miscutil 67 > webaccess 25 > webalert 9 > webbasket 26 > webcomment 10 > webjournal 39 > webmessage 9 > websearch 34 > websession 18 > webstat 7 > webstyle 43 > websubmit 172 >

