Skip to content

Fix matches and psversiontable not recognized by variableanalysis #241

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

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Engine/SpecialVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ internal class SpecialVars
internal const string PSScriptRoot = "PSScriptRoot";
internal const string PSCommandPath = "PSCommandPath";
internal const string ExecutionContext = "ExecutionContext";
internal const string Matches = "Matches";
internal const string PSVersionTable = "PSVersionTable";

internal static readonly string[] InitializedVariables;

Expand Down Expand Up @@ -63,7 +65,9 @@ static SpecialVars()
MyInvocation,
PSScriptRoot,
PSCommandPath,
ExecutionContext
ExecutionContext,
Matches,
PSVersionTable
};
internal static readonly Type[] AutomaticVariableTypes = new Type[]
{
Expand All @@ -76,7 +80,9 @@ static SpecialVars()
/* MyInvocation */ typeof(InvocationInfo),
/* PSScriptRoot */ typeof(string),
/* PSCommandPath */ typeof(string),
/* ExecutionContext */ typeof(EngineIntrinsics),
/* ExecutionContext */ typeof(EngineIntrinsics),
/* Matches */ typeof(System.Collections.Hashtable),
/* PSVersionTable */ typeof(System.Collections.Hashtable)
};


Expand Down
5 changes: 5 additions & 0 deletions Tests/Rules/AvoidGlobalOrUnitializedVarsNoViolations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function Test {

$a = 3;

"hi there!" -match "hi" | Out-Null;
$matches[0];

$PSVersionTable;

if ($true) {
$a = 4;
$c = 3;
Expand Down