Skip to content

PowerShell: Non-standard verb causes squiggly lines throughout entire function #132

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

Closed
pcgeek86 opened this issue Apr 1, 2016 · 16 comments
Labels
Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!

Comments

@pcgeek86
Copy link
Contributor

pcgeek86 commented Apr 1, 2016

  • VSCode Version: 0.10.13-insider
  • OS Version: Windows 10 Version 1511

Steps to Reproduce:

  1. Install PowerShell Extension
  2. Write a function that uses an "unapproved" verb
  3. Notice the excessive squiggly lines

@daviwil

image

Cheers,
Trevor Sullivan
https://trevorsullivan.net
https://twitter.com/pcgeek86

microsoft/vscode#4816

@rkeithhill
Copy link
Contributor

Which version of the extension are you using? I can't duplicate this with 0.5.0. There was an update to PSScriptAnalyzer to address this issue for a few rules (using approved verb was one of those). That updated version of PSScriptAnalyzer got pulled into the 0.4.1 release. So with 0.4.1 and higher, you shouldn't see this issue.

@daviwil
Copy link
Contributor

daviwil commented Apr 3, 2016

I was speaking to Trevor about this on the original Microsoft/vscode issue, we confirmed that he's using 0.5.0. That's really confusing because like you say, this issue has been fixed for a while now. In this case it seems like the old PSScriptAnalyzer rules assembly is being used but I'm not sure how that's even possible...

@daviwil daviwil added this to the Backlog milestone Apr 3, 2016
@rkeithhill
Copy link
Contributor

@pcgeek86 Can you repro the problem and then grab the handle SysInternals tool. Open an elevated prompt and run handle.exe Microsoft.Windows.PowerShell.ScriptAnalyzer and post the output here.

That will tell us the path of the ScriptAnalyzer dll that is loaded into the PSES host. It would also help to only have one VSCode instance running when you do this. Thanks.

@pcgeek86
Copy link
Contributor Author

pcgeek86 commented Apr 4, 2016

@rkeithhill @daviwil Here you go folks -- any thoughts?

image

image

@dsolodow
Copy link
Contributor

dsolodow commented Apr 5, 2016

I'm able to re-produce it as well;
Windows 10 build 14295 x64
Code 0.10.11
PowerShell extension 0.5.0

C:\Users\Damien.vscode\extensions\ms-vscode.PowerShell-0.5.0\bin\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll
C:\Users\Damien.vscode\extensions\ms-vscode.PowerShell-0.5.0\bin\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll

@rkeithhill
Copy link
Contributor

OK I can repro it now. BTW as soon as I put one blank line before this function definition, we start getting back the correct extent from PSScriptAnalyzer. Weird, bizarre and quite strange also.

@pcgeek86
Copy link
Contributor Author

pcgeek86 commented Apr 5, 2016

@rkeithhill Nice -- glad the repro worked out. /cc @dsolodow

@daviwil
Copy link
Contributor

daviwil commented Apr 5, 2016

Seems to be a bug in the rule, I can repro it also if I define the function at the very top of the file without a newline before it. Nice catch Trevor and Damien! I've filed an issue (PowerShell/PSScriptAnalyzer#492) so the PSScriptAnalyzer team can take a look.

@daviwil
Copy link
Contributor

daviwil commented Apr 7, 2016

@kapilmb has already got a fix prepared for this issue: PowerShell/PSScriptAnalyzer#495. It'll be in the next PSScriptAnalyzer update. I'll see if we can sync that up with the next VS Code extension release.

I'll keep this bug open until we verify that it works on our end for the next release.

@rkeithhill rkeithhill added the Needs: Fix Verification Please verify the fix for us! label May 4, 2016
@rkeithhill rkeithhill modified the milestones: 0.6.0, Backlog May 4, 2016
@daviwil
Copy link
Contributor

daviwil commented May 11, 2016

Still waiting on a new PSScriptAnalyzer update before this issue can be fixed. I'm going to bump this to 0.7.0 under the condition that 0.7.0 will come out soon after 0.6.0 and be primarily focused on a couple of PSScriptAnalyzer-related improvements.

@daviwil daviwil modified the milestones: 0.7.0, 0.6.0 May 11, 2016
@ian-moore
Copy link

I have this problem too but with a different analyzer warning, I'm not sure if it's related or maybe I don't understand the rule?

image

@daviwil
Copy link
Contributor

daviwil commented Jun 14, 2016

@kapilmb do you know if the ShouldProcess rule has also been fixed with the extent checking that doesn't make it mark the whole file?

@rkeithhill
Copy link
Contributor

rkeithhill commented Jun 15, 2016

@ian-moore Is this the first function in the file? If so, as a workaround, put a blank line before the function. You also see to have a file encoding issue as indicated by the ? in diamond character before the [CmdletBinding] attribute.

@kapilmb
Copy link

kapilmb commented Jun 15, 2016

This appears to be PSShouldProcess rule violation. As of now, the violation extent of this rule marks the entire function :( - https://github.com/PowerShell/PSScriptAnalyzer/blob/development/Rules/UseShouldProcessCorrectly.cs#L67

@ian-moore
Copy link

I'm not exactly sure what I updated today, but I no longer receive the warning, even before removing the invalid character. Thanks for the help though!

@daviwil daviwil modified the milestones: 0.7.0, Backlog Aug 18, 2016
@daviwil
Copy link
Contributor

daviwil commented Dec 6, 2016

This one has been fixed for a while, just forgot to close the bug!

@daviwil daviwil closed this as completed Dec 6, 2016
@daviwil daviwil modified the milestone: Backlog May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Fix Verification Please verify the fix for us!
Projects
None yet
Development

No branches or pull requests

6 participants