Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoCorrectAliases replaces "process {" with "Get-Process {" #3261

Closed
DEberhardt opened this issue Mar 29, 2021 · 6 comments
Closed

autoCorrectAliases replaces "process {" with "Get-Process {" #3261

DEberhardt opened this issue Mar 29, 2021 · 6 comments
Labels
Area-Script Analysis Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@DEberhardt
Copy link

Issue Type: Bug

Hello,

first, I don't know whether this setting is due to the Extension or VsCode itself. Please advise if this needs to be raised in the VsCode repo.

This issue does not occur with the default setting for Auto-Correcting Aliases:

 // Replaces aliases with their aliased name.
 "powershell.codeFormatting.autoCorrectAliases": false,

I have autoCorrectAliases set to TRUE and I love this feature :)

This happens under very specific circumstances, i.E. when code-Errors are present.

I have an advanced script with BEGIN/PROCESS/END block and during changing the description of a Parameter for example, the syntax is incomplete resulting in the code being read differently (usually this is an open comment with ' or " (when replacing them with the other or adding emphasis within the comment).

my process block function name gets replaced with Get-Process resulting the whole Script to be unusable.

Get-Alias process
Get-Alias : This command cannot find a matching alias because an alias with the name 'process' does not exist.
At line:1 char:1
+ Get-Alias process
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (process:String) [Get-Alias], ItemNotFoundException
    + FullyQualifiedErrorId : ItemNotFoundException,Microsoft.PowerShell.Commands.GetAliasCommand

Process.exe is an executable, but no substitute for Get-Process...

Can this replacement please be excluded?

Extension version: 2021.2.1
VS Code version: Code 1.54.3 (2b9aebd5354a3629c3aba0a5f5df49f43d6689f8, 2021-03-15T10:55:45.459Z)
OS version: Windows_NT x64 10.0.19042

System Info
Item Value
CPUs Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 x 3600)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.87GB (17.19GB free)
Process Argv --crash-reporter-id efc3d77d-4b9d-44d6-894f-bd5aee3260eb
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspyt653:30270858
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry914:30276682
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythonvsnew554cf:30280384
pythontbcf:30265426
pythonvspyt943cf:30280190
openwsldoc:30280162
vscoresta800cf:30279782
vspre833:30267464
pythonptprofiler:30281270
vshan820:30276952

@ghost ghost added the Needs: Triage Maintainer attention needed! label Mar 29, 2021
@DEberhardt DEberhardt changed the title autoCorrectAliases replaces process word autoCorrectAliases replaces "process {" with "Get-Process {" Mar 29, 2021
@rjmholt
Copy link
Contributor

rjmholt commented Mar 29, 2021

Duplicate of PowerShell/PSScriptAnalyzer#1402

@rjmholt rjmholt marked this as a duplicate of PowerShell/PSScriptAnalyzer#1402 Mar 29, 2021
@SydneyhSmith SydneyhSmith removed the Needs: Triage Maintainer attention needed! label May 4, 2021
@andyleejordan
Copy link
Member

Hi @DEberhardt, the latest release of the extension comes with PSScriptAnalyzer v1.20.0, which should no longer erroneously highlight a process block as an error like this. Can you verify for us? Thanks!

@andyleejordan andyleejordan added Area-Script Analysis Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us! labels Sep 13, 2021
@DEberhardt
Copy link
Author

Hello,
thank you for the feedback, I just checked and I am on v1.20.0

Get-module PSScriptAnalyzer -ListAvailable

    Directory: C:\Users\David\.vscode\extensions\ms-vscode.powershell-2021.9.0\modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.20.0     PSScriptAnalyzer                    {Get-ScriptAnalyzerRule, Invoke-ScriptAnalyzer, Invoke-Formatter}

and though it is always hard to prove non-existence of something, I think I managed to do so:
image

Thank you for fixing this one, it has annoyed me greatly.
Hope this conveys my gratitude 😎
image

thanks,
David

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 14, 2021
@DEberhardt
Copy link
Author

#please-close

@andyleejordan
Copy link
Member

Shaka. When the walls fell. 👍

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Fix Verification Please verify the fix for us! Needs: Maintainer Attention Maintainer attention needed! labels Sep 14, 2021
@DEberhardt
Copy link
Author

More like, "Shaka. When the bug is squashed" 😸

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 14, 2021
@andyleejordan andyleejordan removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Script Analysis Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
None yet
Development

No branches or pull requests

4 participants