View Issue Details

IDProjectCategoryView StatusLast Update
0018592MMW 5Generalpublic2022-09-14 14:33
Reporterdrakinite Assigned To 
PriorityurgentSeveritytweakReproducibilityN/A
Status assignedResolutionopen 
Product Version5.0.3 
Target Version5.2 
Summary0018592: Remove unused methods from mminit and actions?
DescriptionAlmost 300 lines of code are dedicated to sscanf, I assume from Alexandru Marasteanu's ssprintf-js method. However, it is completely unused and it would be beneficial to clean up unused methods in mminit.js.

Additional unused methods, which we may wish to remove on a case-by-case basis:
- window.isLetterChar
- window.invalidateLayoutCache
- window.debugObject [though this one should likely stay]
- window.newElement [This one seems useful; is there any reason we aren't using it?]
- window.getOffsetRect
- window.getFrameRenderDuration [also should likely stay]


- uitools.getCanEdit is defined in both mminit.js and actions.js; one should be deleted
- uitools.getCanDelete is also defined in both mminit and actions
- uitools.ripCD
TagsNo tags attached.
Fixed in build

Activities

jiri

2021-12-02 10:30

administrator   ~0066220

Makes me think about a generic solution to code coverage and testing -- i.e. a way how to identify useless code and how to identify code that isn't covered by regression testing. Seems that https://github.com/istanbuljs/nyc is the standard for js, but it's usage isn't straightforward due to the way how js is loaded by MM5. I wonder whether we could use 'nyc instrument' for our js code folder and then use the result for coverage testing? Assigning to Petr in case he finds a trick how to do it. In case it'd be too complex, forget it and let's just remove the manually identified code by Jordan (which we should do regardless of the nyc results).

Ludek

2021-12-02 12:50

developer   ~0066221

Last edited: 2021-12-02 12:51

Are we really sure that the code isn't actually used (e.g. by addons/scripts) ?

drakinite

2022-05-18 06:43

developer   ~0068152

After double checking, I've taken a few methods off the original list:

Not sure why I thought these weren't used before:
- window.adjustImgAR: Used in a few RemovedScripts and referenced in Covers.pas
- window.addDialogContent: Used inside a bunch of built-in Plugins

Exposing a local function which does get a lot of use inside actions.js:
- uitools.activateLayout
- uitools.notLocalMediaListSelected
- uitools.getCurrentDataSource

Exposes a local variable which *is* modified, even if it's not used anywhere -- so we might as well keep it just in case
- window.isUsedTab
- window.isUsedShift

Called externally from native code:
- uitools.prepareWindowAsVideoPlayer
- window.alertInetException
- uitools.hideProgressWindow

Of those that are left, I'm certain they're not used in any internal code & confident that they wouldn't be used in any addons. They're not documented anywhere, and they're quite obscure internal methods at that.