LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
SteveChandler

Delete Dead Code

Status: New

Inspired by Altenbach's excellent idea to Bleach Dead Code and X's idea for Unconnected Function Terminal Detection

 

In addition to this I would like the option to just delete the dead code.

 

Before:

Example_VI_BD.png

 

 

After:

Case structure removed since it has a constant wired to the selector, addition removed because it's output goes nowhere.

 

Example_VI_BD.png

 

 

=====================
LabVIEW 2012


7 Comments
tst
Knight of NI Knight of NI
Knight of NI

I don't think this is a good idea, mainly for safety reasons - deleting code is the kind of thing which I prefer to do explicitly. Showing us where the dead code is (ideally with a list we can go through) should make it easy enough to clean it up manually.

 

Of course, LV already does this automatically, but only when compiling, which doesn't affect the original code.


___________________
Try to take over the world!
SteveChandler
Trusted Enthusiast

Well it is something that would have to be done with consideration. There is always undo and source control. Removing the dead code is something that you would have to explicitly do. Like the option to remove broken wires it would be something that you would need to think about. There is the idea to remove broken wires by selection which is in development. Removing dead code in a selection would probably be a good addition to this.

=====================
LabVIEW 2012


dthor
Active Participant

I think this could be useful. Definitely need to use with caution though. Also, would code inside a Diagram Disable Structure be considered dead? I don't think it should.

SteveChandler
Trusted Enthusiast

Code in a diagram disable structure is in Purgatory. It is not alive and it is not dead. It should be left alone. Good call!

 

This would mostly be useful when code is inherited from someone and you want to refactor it. It would also be useful for when the code is complete and ready for release. I wouldn't expect to use it much during development but I would like to have it available when I do want it.

=====================
LabVIEW 2012


altenbach
Knight of NI

It could be useful.

When developing algorithms, I often have many extra indicators and small transformation feeding them to aid in debugging and see intermediary results (e.g. transposed 2D arrays, charts of several bundled values, formatted tables of 2D numerics, etc.) Once I am happy, I typically delete the temporary indicators, leaving me with related dead code that I need to hunt down and delete manually. It would be cool to have that removal automated.

 

If we have a dead code indication (e.g. bleached) as suggested in my idea you quoted, maybe there could be a "right-click...remove all dead code" option. I would probably use it. 😉

SteveChandler
Trusted Enthusiast
Yes! I would prefer the right click on bleached code to remove it over removing from a selection. I still would like to have the option to globally remove all from a VI.
=====================
LabVIEW 2012


JCC_(SK)
Active Participant

Maybe good enough will be select/mark unused code and after that developer should decide what we want to do wit this code.

 

It is nice idea to by implemented by VI Scripting 🙂