Skip to content

Commit 1b15e84

Browse files
author
quoctruong
committed
Fix UseDeclaredVarsMoreThanAssignment not recognizing script variables
1 parent 98e8d3a commit 1b15e84

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Rules/UseDeclaredVarsMoreThanAssignments.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
5454
foreach (VariableExpressionAst assignmentVarAst in assingmentVarAsts)
5555
{
5656
//Ignore if variable is global or environment variable
57-
if (!Helper.Instance.IsVariableGlobalOrEnvironment(assignmentVarAst, ast))
57+
if (!Helper.Instance.IsVariableGlobalOrEnvironment(assignmentVarAst, ast)
58+
&& !assignmentVarAst.VariablePath.IsScript)
5859
{
5960
if (!assignments.ContainsKey(assignmentVarAst.VariablePath.UserPath))
6061
{
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
$declaredVars = "Declared Vars"
2-
Write-Ouput $declaredVars
2+
Write-Ouput $declaredVars
3+
$script:thisshouldnotraiseerrors = "this should not raise errors"

0 commit comments

Comments
 (0)