View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0018592 | MMW 5 | General | public | 2021-11-28 00:48 | 2022-09-14 14:33 |
Reporter | drakinite | Assigned To | |||
Priority | urgent | Severity | tweak | Reproducibility | N/A |
Status | assigned | Resolution | open | ||
Product Version | 5.0.3 | ||||
Target Version | 5.2 | ||||
Summary | 0018592: Remove unused methods from mminit and actions? | ||||
Description | Almost 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 | ||||
Tags | No tags attached. | ||||
Fixed in build | |||||
|
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). |
|
Are we really sure that the code isn't actually used (e.g. by addons/scripts) ? |
|
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. |