Unused variables and/or functions

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Unused variables and/or functions

Post by PsCustomObject »

Hello,

more often than not I work with large script files (3k+ lines) so it can happen during maintenance and/or updates to the script that some variables previousely declared are not sued anymore, it would be great if PowerShell Studio would give me a way to highlighty all unused variables and/or functions so that code can be cleaned up.

I know I can setup some pre-flight checks for this but would love to have it directly in the editor.

Thanks in advance for considering this.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Unused variables and/or functions

Post by davidc »

Have you tried the PSScriptAnalayzer module? It performs validates tests on scripts. Once installed, you can trigger it from PowerShell Studio (Tools->Validation->Analyze Script) or automatically when you run a script.
David
SAPIEN Technologies, Inc.
User avatar
PsCustomObject
Posts: 137
Last visit: Thu Mar 28, 2024 3:34 am

Re: Unused variables and/or functions

Post by PsCustomObject »

Thanks David,

yep I'm aware of the module, even if I will admit never used within PSS which I will remediate soon, what I was referring was something more "real time".

More often than not I don't run scripts from within PSS for a variety of reasons, so having red/green/blue squiggly underlines would be a real time saver for me, what I usually do is copying/pasting code to Visual Studio Code which does this natively.

I can live without the feature as PSS already saves me TONS of time when coding but avoid the extra step would be great addition :-)
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Unused variables and/or functions

Post by davidc »

Thank you for the feedback. We will see what we can do.
David
SAPIEN Technologies, Inc.
This topic is 6 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked