Skip to content
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
4 changes: 2 additions & 2 deletions Engine/Generic/AvoidCmdletGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
public abstract class AvoidCmdletGeneric : IScriptRule
{
/// <summary>
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis.
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis.
/// </summary>
/// <param name="ast">The script's ast</param>
/// <param name="fileName">The name of the script file being analyzed</param>
Expand All @@ -38,7 +38,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)

List<String> cmdletNameAndAliases = Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.Instance.CmdletNameAndAliases(GetCmdletName());

// Iterrates all CommandAsts and check the command name.
// Iterates all CommandAsts and check the command name.
foreach (CommandAst cmdAst in commandAsts)
{
if (cmdAst.GetCommandName() == null) continue;
Expand Down
4 changes: 2 additions & 2 deletions Engine/Generic/AvoidParameterGeneric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
public abstract class AvoidParameterGeneric : IScriptRule
{
/// <summary>
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis.
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis.
/// </summary>
/// <param name="ast">The script's ast</param>
/// <param name="fileName">The name of the script file being analyzed</param>
Expand All @@ -35,7 +35,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
// Finds all CommandAsts.
IEnumerable<Ast> commandAsts = ast.FindAll(testAst => testAst is CommandAst, true);

// Iterrates all CommandAsts and check the condition.
// Iterates all CommandAsts and check the condition.
foreach (CommandAst cmdAst in commandAsts)
{
if (CommandCondition(cmdAst) && cmdAst.CommandElements != null)
Expand Down
2 changes: 1 addition & 1 deletion Engine/Generic/ILogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface ILogger
string GetName();

/// <summary>
/// GetDescription: Retrives the description of the logger.
/// GetDescription: Retrieves the description of the logger.
/// </summary>
/// <returns>The description of the logger</returns>
string GetDescription();
Expand Down
2 changes: 1 addition & 1 deletion Engine/Generic/IScriptRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
public interface IScriptRule : IRule
{
/// <summary>
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis.
/// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis.
/// </summary>
/// <param name="ast">The script's ast</param>
/// <param name="fileName">The name of the script file being analyzed</param>
Expand Down
2 changes: 1 addition & 1 deletion Engine/Generic/SourceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum SourceType : uint
Builtin = 0,

/// <summary>
/// MANAGED: Indicates the script analyzer rule is contirbuted as a managed rule.
/// MANAGED: Indicates the script analyzer rule is contributed as a managed rule.
/// </summary>
Managed = 1,

Expand Down
2 changes: 1 addition & 1 deletion Engine/PSScriptAnalyzer.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CompanyName = 'Microsoft Corporation'
Copyright = '(c) Microsoft Corporation 2015. All rights reserved.'

# Description of the functionality provided by this module
Description = 'PSScriptAnalyzer provides script analysis and checks for potential code defects in the scripts by applying a group of builtin or customized rules on the scripts being analyzed.'
Description = 'PSScriptAnalyzer provides script analysis and checks for potential code defects in the scripts by applying a group of built-in or customized rules on the scripts being analyzed.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
Expand Down
2 changes: 1 addition & 1 deletion Engine/ScriptAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ public Dictionary<string, List<string>> CheckRuleExtension(string[] path, PathIn
}
}

// Resloves relative paths.
// Resolves relative paths.
try
{
for (int i = 0; i < validModPaths.Count; i++)
Expand Down
227 changes: 114 additions & 113 deletions Engine/ScriptAnalyzerEngine.csproj
Original file line number Diff line number Diff line change
@@ -1,114 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}</ProjectGuid>
<OutputType>Library</OutputType>
<NoStandardLibraries>false</NoStandardLibraries>
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\GetScriptAnalyzerRuleCommand.cs" />
<Compile Include="Commands\InvokeScriptAnalyzerCommand.cs" />
<Compile Include="Generic\AvoidCmdletGeneric.cs" />
<Compile Include="Generic\AvoidParameterGeneric.cs" />
<Compile Include="Generic\SuppressedRecord.cs" />
<Compile Include="Generic\DiagnosticRecord.cs" />
<Compile Include="Generic\ExternalRule.cs" />
<Compile Include="Generic\IDSCResourceRule.cs" />
<Compile Include="Generic\IExternalRule.cs" />
<Compile Include="Generic\ILogger.cs" />
<Compile Include="Generic\IRule.cs" />
<Compile Include="Generic\IScriptRule.cs" />
<Compile Include="Generic\ITokenRule.cs" />
<Compile Include="Generic\LoggerInfo.cs" />
<Compile Include="Generic\RuleInfo.cs" />
<Compile Include="Generic\RuleSuppression.cs" />
<Compile Include="Generic\RuleSeverity.cs" />
<Compile Include="Generic\SkipNamedBlock.cs" />
<Compile Include="Generic\SkipTypeDefinition.cs" />
<Compile Include="Generic\SourceType.cs" />
<Compile Include="Helper.cs" />
<Compile Include="IOutputWriter.cs" />
<Compile Include="Loggers\WriteObjectsLogger.cs" />
<Compile Include="SafeDirectoryCatalog.cs" />
<Compile Include="ScriptAnalyzer.cs" />
<Compile Include="SpecialVars.cs" />
<Compile Include="Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="VariableAnalysis.cs" />
<Compile Include="VariableAnalysisBase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="PSScriptAnalyzer.psd1" />
<None Include="ScriptAnalyzer.format.ps1xml" />
<None Include="ScriptAnalyzer.types.ps1xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="about_PSScriptAnalyzer.help.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
<ProjectExtensions>
<VisualStudio AllowExistingFolder="true" />
</ProjectExtensions>
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)$(SolutionName)"
copy /y "$(ProjectDir)\*.ps1xml" "$(SolutionDir)$(SolutionName)"
copy /y "$(ProjectDir)\*.psd1" "$(SolutionDir)$(SolutionName)"
mkdir "$(SolutionDir)$(SolutionName)\Configurations"
copy /y "$(ProjectDir)\Configurations\*.psd1" "$(SolutionDir)$(SolutionName)\Configurations"
copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)"
mkdir "$(SolutionDir)$(SolutionName)\en-US"
copy /y "$(ProjectDir)\about_*.help.txt" "$(SolutionDir)$(SolutionName)\en-US"
copy /y "$(ProjectDir)\*Help.xml" "$(SolutionDir)$(SolutionName)\en-US"</PostBuildEvent>
</PropertyGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}</ProjectGuid>
<OutputType>Library</OutputType>
<NoStandardLibraries>false</NoStandardLibraries>
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>Microsoft.Windows.PowerShell.ScriptAnalyzer</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\GetScriptAnalyzerRuleCommand.cs" />
<Compile Include="Commands\InvokeScriptAnalyzerCommand.cs" />
<Compile Include="Generic\AvoidCmdletGeneric.cs" />
<Compile Include="Generic\AvoidParameterGeneric.cs" />
<Compile Include="Generic\SuppressedRecord.cs" />
<Compile Include="Generic\DiagnosticRecord.cs" />
<Compile Include="Generic\ExternalRule.cs" />
<Compile Include="Generic\IDSCResourceRule.cs" />
<Compile Include="Generic\IExternalRule.cs" />
<Compile Include="Generic\ILogger.cs" />
<Compile Include="Generic\IRule.cs" />
<Compile Include="Generic\IScriptRule.cs" />
<Compile Include="Generic\ITokenRule.cs" />
<Compile Include="Generic\LoggerInfo.cs" />
<Compile Include="Generic\RuleInfo.cs" />
<Compile Include="Generic\RuleSuppression.cs" />
<Compile Include="Generic\RuleSeverity.cs" />
<Compile Include="Generic\SkipNamedBlock.cs" />
<Compile Include="Generic\SkipTypeDefinition.cs" />
<Compile Include="Generic\SourceType.cs" />
<Compile Include="Helper.cs" />
<Compile Include="IOutputWriter.cs" />
<Compile Include="Loggers\WriteObjectsLogger.cs" />
<Compile Include="SafeDirectoryCatalog.cs" />
<Compile Include="ScriptAnalyzer.cs" />
<Compile Include="SpecialVars.cs" />
<Compile Include="Strings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
<Compile Include="VariableAnalysis.cs" />
<Compile Include="VariableAnalysisBase.cs" />
</ItemGroup>
<ItemGroup>
<None Include="PSScriptAnalyzer.psd1" />
<None Include="ScriptAnalyzer.format.ps1xml" />
<None Include="ScriptAnalyzer.types.ps1xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="about_PSScriptAnalyzer.help.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
<ProjectExtensions>
<VisualStudio AllowExistingFolder="true" />
</ProjectExtensions>
<PropertyGroup>
<PostBuildEvent>
if not exist "$(SolutionDir)$(SolutionName)" mkdir "$(SolutionDir)$(SolutionName)"
copy /y "$(ProjectDir)*.ps1xml" "$(SolutionDir)$(SolutionName)"
copy /y "$(ProjectDir)*.psd1" "$(SolutionDir)$(SolutionName)"
if not exist "$(SolutionDir)$(SolutionName)\Configurations" mkdir "$(SolutionDir)$(SolutionName)\Configurations"
copy /y "$(ProjectDir)Configurations\*.psd1" "$(SolutionDir)$(SolutionName)\Configurations"
copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)"
if not exist "$(SolutionDir)$(SolutionName)\en-US" mkdir "$(SolutionDir)$(SolutionName)\en-US"
copy /y "$(ProjectDir)about_*.help.txt" "$(SolutionDir)$(SolutionName)\en-US"
copy /y "$(ProjectDir)*Help.xml" "$(SolutionDir)$(SolutionName)\en-US"</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Engine/VariableAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private void ProcessParameters(IEnumerable<ParameterAst> parameters)
}

/// <summary>
/// Used to analyze scriptbloct, functionmemberast or functiondefinitionast
/// Used to analyze scriptblock, functionmemberast or functiondefinitionast
/// </summary>
/// <param name="ast"></param>
/// <returns></returns>
Expand Down
12 changes: 6 additions & 6 deletions Engine/VariableAnalysisBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ internal static Block[] SetDominators(Block entry, List<Block> Blocks)

Block dom = block._predecessors[0];

// Get first proccessed node
// Get first processed node
foreach (var pred in block._predecessors)
{
if (dominators[pred.PostOrder] != null)
Expand Down Expand Up @@ -828,14 +828,14 @@ internal static Tuple<Dictionary<string, VariableAnalysisDetails>, Dictionary<st
}
}

// Initialize variables in internaldictionary to undetermined
// Initialize variables in internal dictionary to undetermined
foreach (var key in InternalVariablesDictionary.Keys.ToList())
{
InternalVariablesDictionary[key].Constant = Undetermined.UndeterminedConstant;
InternalVariablesDictionary[key].Type = typeof(Undetermined);
}

// Initialze DefinedBlock of phi function. If it is null then that phi function is not initialized;
// Initialize DefinedBlock of phi function. If it is null then that phi function is not initialized;
foreach (var block in blocks)
{
foreach (var phi in block.Phis)
Expand Down Expand Up @@ -956,7 +956,7 @@ internal static Tuple<Dictionary<string, VariableAnalysisDetails>, Dictionary<st
{
CommandExpressionAst cmeAst = assigned._rightAst as CommandExpressionAst;
MemberExpressionAst memAst = (cmeAst != null) ? (cmeAst.Expression as MemberExpressionAst) : null;
// Don't handle the this case because this is handled in assignmenttarget
// Don't handle the this case because this is handled in assignment target

if (memAst != null && memAst.Expression is VariableExpressionAst)
{
Expand Down Expand Up @@ -2042,7 +2042,7 @@ public object VisitNamedAttributeArgument(NamedAttributeArgumentAst namedAttribu
/// <returns></returns>
public object VisitParameter(ParameterAst parameterAst)
{
// Nothing to do now, we've already allocated parameters in the first pass looking for all variable naems.
// Nothing to do now, we've already allocated parameters in the first pass looking for all variable names.
System.Diagnostics.Debug.Assert(false, "Code is unreachable");
return null;
}
Expand Down Expand Up @@ -2812,7 +2812,7 @@ public object VisitBinaryExpression(BinaryExpressionAst binaryExpressionAst)
// left operand is always evaluated, visit it's expression in the current block.
binaryExpressionAst.Left.Visit(this.Decorator);

// The right operand is condtionally evaluated. We aren't generating any code here, just
// The right operand is conditionally evaluated. We aren't generating any code here, just
// modeling the flow graph, so we just visit the right operand in a new block, and have
// both the current and new blocks both flow to a post-expression block.
var targetBlock = new Block();
Expand Down
2 changes: 1 addition & 1 deletion Engine/about_PSScriptAnalyzer.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ RUNNING SCRIPT ANALYZER ON AN EXISTING SCRIPT, MODULE OR DSC RESOURCE
see if the output is "manageable". If it isn't, then you will want to "ease
into" things by starting with the most serious violations first - errors.

You may be temtped to use the Invoke-ScriptAnalyzer command's Severity
You may be tempted to use the Invoke-ScriptAnalyzer command's Severity
parameter with the argument Error to do this - don't. This will run every
built-in rule and then filter the results during output. The more rules the
script analyzer runs, the longer it will take to analyze a file. You can
Expand Down
2 changes: 1 addition & 1 deletion Rules/AvoidAlias.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
// Finds all CommandAsts.
IEnumerable<Ast> foundAsts = ast.FindAll(testAst => testAst is CommandAst, true);

// Iterrates all CommandAsts and check the command name.
// Iterates all CommandAsts and check the command name.
foreach (Ast foundAst in foundAsts)
{
CommandAst cmdAst = (CommandAst)foundAst;
Expand Down
Loading