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

Using module incorrectly marked as wrong? #1599

Closed
PrzemyslawKlys opened this issue Nov 4, 2018 · 4 comments
Closed

Using module incorrectly marked as wrong? #1599

PrzemyslawKlys opened this issue Nov 4, 2018 · 4 comments
Labels
Area-Engine Issue-Bug A bug to squash.

Comments

@PrzemyslawKlys
Copy link
Contributor

System Details

System Details Output

### VSCode version: 1.28.2 7f3ce96ff4729c91352ae6def877e59c561f4850 x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 1.9.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.17763.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am using PSDsHook module. It's installed from PSGallery. It works fine. I use it as Import-Module and it doesn't bug out. I change it to using module PSDsHook and it works fine. However for VSCode it's a problem. It says module can't be found.

image

Since PSDsHook uses Classes it requires using module instead of standard Import-Module.

Expected Behaviour

Not marking everything red.

Actual Behaviour

Marking file on left as red, claiming it's an error.

Attached Logs

Follow the instructions in the troubleshooting docs
about capturing and sending logs.

@rjmholt
Copy link
Contributor

rjmholt commented Nov 5, 2018

Hi @PrzemyslawKlys, if you run PSScriptAnalyzer on this directly, do you get an error?

There should be an explanation of how to do that in our script analysis bug template.

@PrzemyslawKlys
Copy link
Contributor Author

PrzemyslawKlys commented Nov 5, 2018

PS C:\Support\GitHub\PSBlackListChecker\Ignore> Invoke-ScriptAnalyzer -Path '.\Evotec-RunMeReporting.ps1' -verbose -Settings PSGallery -Recurse
VERBOSE: Using settings file at C:\Users\pklys\.vscode\extensions\ms-vscode.powershell-1.9.0\modules\PSScriptAnalyzer\1.17.1\Settings\PSGallery.psd1.
VERBOSE: Performing the operation "Analyzing path with Recurse=True" on target "C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1".
VERBOSE: Performing the operation "Analyzing file C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1" on target "C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1".
VERBOSE: Analyzing file: C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1
VERBOSE: Running PSAvoidUsingCmdletAliases rule.
VERBOSE: Running PSAvoidDefaultValueSwitchParameter rule.
VERBOSE: Running PSAvoidUsingEmptyCatchBlock rule.
VERBOSE: Running PSAvoidGlobalVars rule.
VERBOSE: Running PSAvoidUsingPositionalParameters rule.
VERBOSE: Running PSReservedCmdletChar rule.
VERBOSE: Running PSReservedParams rule.
VERBOSE: Running PSAvoidUsingComputerNameHardcoded rule.
VERBOSE: Running PSAvoidUsingConvertToSecureStringWithPlainText rule.
VERBOSE: Running PSAvoidUsingUserNameAndPassWordParams rule.
VERBOSE: Running PSAvoidUsingInvokeExpression rule.
VERBOSE: Running PSAvoidUsingPlainTextForPassword rule.
VERBOSE: Running PSMissingModuleManifestField rule.
VERBOSE: Running PSAvoidUsingWMICmdlet rule.
VERBOSE: Running PSUseApprovedVerbs rule.
VERBOSE: Running PSUseCmdletCorrectly rule.
VERBOSE: Running PSUseDeclaredVarsMoreThanAssignments rule.
VERBOSE: Running PSUsePSCredentialType rule.
VERBOSE: Running PSUseShouldProcessForStateChangingFunctions rule.
VERBOSE: Running PSShouldProcess rule.
VERBOSE: Running PSUseSingularNouns rule.

or

PS C:\Support\GitHub\PSBlackListChecker\Ignore> Invoke-ScriptAnalyzer -Path '.\Evotec-RunMeReporting.ps1' -verbose
VERBOSE: Settings object could not be resolved.
VERBOSE: Performing the operation "Analyzing path with Recurse=False" on target "C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1".
VERBOSE: Performing the operation "Analyzing file C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1" on target "C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1".
VERBOSE: Analyzing file: C:\Support\GitHub\PSBlackListChecker\Ignore\Evotec-RunMeReporting.ps1
VERBOSE: Running PSAvoidDefaultValueForMandatoryParameter rule.
VERBOSE: Running PSAvoidDefaultValueSwitchParameter rule.
VERBOSE: Running PSAvoidUsingCmdletAliases rule.
VERBOSE: Running PSAvoidAssignmentToAutomaticVariable rule.
VERBOSE: Running PSAvoidGlobalAliases rule.
VERBOSE: Running PSAvoidGlobalFunctions rule.
VERBOSE: Running PSAvoidUsingEmptyCatchBlock rule.
VERBOSE: Running PSAvoidInvokingEmptyMembers rule.
VERBOSE: Running PSAvoidNullOrEmptyHelpMessageAttribute rule.
VERBOSE: Running PSReservedParams rule.
VERBOSE: Running PSAvoidGlobalVars rule.
VERBOSE: Running PSAvoidShouldContinueWithoutForce rule.
VERBOSE: Running PSAvoidUsingPositionalParameters rule.
VERBOSE: Running PSAvoidUsingUserNameAndPassWordParams rule.
VERBOSE: Running PSAvoidUsingConvertToSecureStringWithPlainText rule.
VERBOSE: Running PSAvoidUsingDeprecatedManifestFields rule.
VERBOSE: Running PSAvoidUsingInvokeExpression rule.
VERBOSE: Running PSAvoidUsingWriteHost rule.
VERBOSE: Running PSAvoidUsingWMICmdlet rule.
VERBOSE: Running PSPossibleIncorrectComparisonWithNull rule.
VERBOSE: Running PSPossibleIncorrectUsageOfAssignmentOperator rule.
VERBOSE: Running PSAvoidUsingPlainTextForPassword rule.
VERBOSE: Running PSAvoidUsingComputerNameHardcoded rule.
VERBOSE: Running PSMissingModuleManifestField rule.
VERBOSE: Running PSPossibleIncorrectUsageOfRedirectionOperator rule.
VERBOSE: Running PSReservedCmdletChar rule.
VERBOSE: Running PSProvideCommentHelp rule.
VERBOSE: Running PSUseCmdletCorrectly rule.
VERBOSE: Running PSUseCompatibleCmdlets rule.
VERBOSE: Running PSUseLiteralInitializerForHashtable rule.
VERBOSE: Running PSUseOutputTypeCorrectly rule.
VERBOSE: Running PSUsePSCredentialType rule.
VERBOSE: Running PSUseDeclaredVarsMoreThanAssignments rule.
VERBOSE: Running PSUseShouldProcessForStateChangingFunctions rule.
VERBOSE: Running PSUseSupportsShouldProcess rule.
VERBOSE: Running PSUseSingularNouns rule.
VERBOSE: Running PSUseBOMForUnicodeEncodedFile rule.
VERBOSE: Running PSUseUTF8EncodingForHelpFile rule.
VERBOSE: Running PSUseToExportFieldsInManifest rule.
VERBOSE: Running PSShouldProcess rule.
VERBOSE: Running PSUseApprovedVerbs rule.
VERBOSE: Running PSMisleadingBacktick rule.
VERBOSE: Running PSAvoidTrailingWhitespace rule.

Although I've never run this manually so not sure what to expect as an output.

image

PS C:\Support\GitHub\PSBlackListChecker> get-module psdshook -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.1.5      PSDsHook                            Invoke-PSDsHook

@rjmholt
Copy link
Contributor

rjmholt commented Nov 5, 2018

Hmmm looks like this might be on us. A using module problem is a parse-time error, so it will be reported by the parser and PSES deals with that.

I imagine what's happening is that parsing the script in memory in PSES doesn't find the module the way that executing the file does. We should look into it.

@PrzemyslawKlys
Copy link
Contributor Author

I think it works correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Engine Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

2 participants