LabVIEW Idea Exchange

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

Run Code Cleanup profile (Nattify VI) on Save

Status: New

I think it would be a good idea to enable running code formatter, like Darren's Nattify VI, automatically when saving a VI. Currently, most IDEs have built-in formatting tools which promote a unified, clean code style, and programmers don't have to worry about it because the code is automatically cleaned up before saving. I think a similar function would be a great addition to LabVIEW.

 

In Visual Studio it is called "Run Code Cleanup profile on Save". You can also configure different profiles (different styles or flavors). This option would be nice to have.

 

It would be great if it were possible to reduce the amount of time spent cleaning up LabVIEW code while keeping the code in decent visual condition.

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
8 Comments
Mads
Active Participant

There is the diagram cleanup function...but 70% of the time it will make diagrams less readable than the original. So until that gets closer to 0% I would not want it to touch my code in an automated way. I mostly use it when I have written something small, quick and messy as a test which then ended up being production code after all. Then I try the diagram cleanup with a few different settings to see if it looks OK, or at least gives me a better starting point for a manual cleanup. If NI had the time and resources they could perhaps train an AI to produce something that people would find more readable, and we could have a threshold for when it should leave the code as is. If it could evaluate the existing code and found it OK (or found a key saying this diagram is approved by the developer as good enough) even though not as it would make it, it would leave the code as is.

bienieck
Active Participant

@Mads

The cleanup function you mentioned is completely different from what I have in mind. I was thinking about something like a configurable Nattify VI triggered by the save file event.

 

Right now plenty of people use either this or a set of other quick drops before hitting Ctrl+S (move to the origin, automatic FP cleanup, set icon, remove meaningless constant labels, disable structure auto size, etc). It means that the implementation of the idea I posted could simplify developer workflow.

 

Current diagram cleanup could be added as a step in the profile but I would not recommend that because of the reasons you described.

 

BTW I like the idea of AI-assisted BD cleanup. But that could be a subject for a new idea exchange thread I think.

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
BertMcMahan
Active Participant

A more generalized option might be to add some "IDE hooks" where you could configure custom VI's to run on Save, New, etc. Admittedly I can't think of much right now that I'd need other than what you suggested, but I bet someone out there could find something cool.

 

If this was settable per project and/or per user you could do some neat customizations.

ConnerP
Member

Are you aware of the VI Analyzer Toolkit? It doesn't do autofixes, but basically does linting notifications with customizable profiles. Here is an example of a tool to simplify running it, but you do have to remember to call it. https://felipekb.com/2020/07/08/vi-analyzer-and-git/

Taggart
Trusted Enthusiast

This is very high on my wishlist...

 

to @ConnerP you can create custom VI analyzer tests that do actually fix things...


Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Taggart
Trusted Enthusiast

To the point of an AI-assisted cleanup, it could be useful. But I don't think that is what you want. It really depends on what problem you are trying to solve.

 

If you look at Black in Python for example:

from the docs:

"By using Black, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.

Black makes code review faster by producing the smallest diffs possible. Blackened code looks the same regardless of the project you’re reading. Formatting becomes transparent after a while and you can focus on the content instead."

The thing AI is missing is determinism. It's not deterministic. Everytime you save it might completely rearrange your code. Imagine sorting through those diffs in Git. Probably not what you want.

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
ebs27
Member

Hi Michał!

 

Is this something you would be interested in seeing developed as an open source project with G Central? I am with the G Idea Exchange Committee and we are looking for new open source project ideas.

 

GIE recently got their own page on the NI Forums. If you're interested, would you be willing to repost there? We are moving current and future ideas over to the new forums page: https://forums.ni.com/t5/G-Idea-Exchange/idb-p/g-idea-exchange

 

Many thanks!

 

Eric Stach

bienieck
Active Participant

@Sam

The comment about determinism and that AI could reorganize the entire code is correct, but if you are at the early development stage, I think it is not a problem. At an early stage, AI could speed up work. At the stage of maintenance and bug fixes, the AI support mode should be turned off IMHO.

 

@Eric

How would this work? Would G Central implement a hook for saving in LabVIEW? Why are ideas moved in the first place?

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.