Skip to content

False positive: "is implicitly aliasing 'Get-..\..\Target.ps1'" on file path? #1369

Closed
@ili101

Description

@ili101

Steps to reproduce

image
Create file/folder structure as how in the image:

  1. create "test" folder.
  2. create "Target.ps1" in it (can be empty).
  3. create file in 2 sub folders ".\sub\sub2\test.ps1" with & ..\..\Target.ps1
  4. open "test" folder in VSCode (if it already open then F1 > "Reload Window"

get false positive:

{
	"resource": "/c:/temp/sub/sub2/test.ps1",
	"owner": "_generated_diagnostic_collection_name_#3",
	"code": "PSAvoidUsingCmdletAliases",
	"severity": 4,
	"message": "'..\\..\\Target.ps1' is implicitly aliasing 'Get-..\\..\\Target.ps1' because it is missing the 'Get-' prefix. This can introduce possible problems and make scripts hard to maintain. Please consider changing command to its full name.",
	"source": "PSScriptAnalyzer",
	"startLineNumber": 1,
	"startColumn": 3,
	"endLineNumber": 1,
	"endColumn": 19
}

Environment data

PS C:\temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.5
PSEdition                      Core
GitCommitId                    7.0.0-preview.5
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}       
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\temp> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.3
1.18.1      
1.18.0      

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions