Skip to content

Commit 039cfda

Browse files
author
Kapil Borle
committed
Use IsModuleScript from helper
1 parent 563c0a2 commit 039cfda

File tree

2 files changed

+2
-20
lines changed

2 files changed

+2
-20
lines changed

Rules/AvoidGlobalAliases.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
3333
records = new List<DiagnosticRecord>();
3434
this.fileName = fileName;
3535

36-
if (IsScriptModule())
36+
if (fileName != null && Helper.IsModuleScript(fileName))
3737
{
3838
ast.Visit(this);
3939
}
@@ -95,15 +95,6 @@ private bool IsNewAliasCmdlet(CommandAst commandAst)
9595
return false;
9696
}
9797

98-
/// <summary>
99-
/// Determines if analyzing a script module.
100-
/// </summary>
101-
/// <returns>True is file name ends with ".psm1"</returns>
102-
private bool IsScriptModule()
103-
{
104-
return fileName.EndsWith(".psm1");
105-
}
106-
10798
public string GetCommonName()
10899
{
109100
return string.Format(CultureInfo.CurrentCulture, Strings.AvoidGlobalAliasesCommonName);

Rules/AvoidGlobalFunctions.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
3333
records = new List<DiagnosticRecord>();
3434
this.fileName = fileName;
3535

36-
if (IsScriptModule())
36+
if (fileName != null && Helper.IsModuleScript(fileName))
3737
{
3838
ast.Visit(this);
3939
}
@@ -66,15 +66,6 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
6666
}
6767
#endregion
6868

69-
/// <summary>
70-
/// Determines if analyzing a script module.
71-
/// </summary>
72-
/// <returns>True is file name ends with ".psm1"</returns>
73-
private bool IsScriptModule()
74-
{
75-
return fileName.EndsWith(".psm1");
76-
}
77-
7869
public string GetCommonName()
7970
{
8071
return string.Format(CultureInfo.CurrentCulture, Strings.AvoidGlobalFunctionsCommonName);

0 commit comments

Comments
 (0)