From efdfba9cd13de86e4dec932a1d49ea0755f6051d Mon Sep 17 00:00:00 2001 From: Kory Gill Date: Tue, 8 Dec 2015 20:54:10 -0800 Subject: [PATCH 1/2] Improve post-build command, fix spelling mistakes. --- Engine/Generic/AvoidCmdletGeneric.cs | 4 +- Engine/Generic/AvoidParameterGeneric.cs | 4 +- Engine/Generic/ILogger.cs | 2 +- Engine/Generic/IScriptRule.cs | 2 +- Engine/Generic/SourceType.cs | 2 +- Engine/PSScriptAnalyzer.psd1 | 2 +- Engine/ScriptAnalyzer.cs | 2 +- Engine/VariableAnalysis.cs | 2 +- Engine/VariableAnalysisBase.cs | 12 +- Engine/about_PSScriptAnalyzer.help.txt | 2 +- Rules/AvoidAlias.cs | 2 +- Rules/AvoidDefaultTrueValueSwitchParameter.cs | 2 +- Rules/AvoidEmptyCatchBlock.cs | 2 +- Rules/AvoidPositionalParameters.cs | 2 +- Rules/AvoidShouldContinueWithoutForce.cs | 2 +- Rules/AvoidUserNameAndPasswordParams.cs | 2 +- Rules/AvoidUsingPlainTextForPassword.cs | 2 +- Rules/ScriptAnalyzerBuiltinRules.csproj | 232 +++++++++--------- Rules/UseDeclaredVarsMoreThanAssignments.cs | 2 +- 19 files changed, 141 insertions(+), 141 deletions(-) diff --git a/Engine/Generic/AvoidCmdletGeneric.cs b/Engine/Generic/AvoidCmdletGeneric.cs index 5546295bf..b23d85679 100644 --- a/Engine/Generic/AvoidCmdletGeneric.cs +++ b/Engine/Generic/AvoidCmdletGeneric.cs @@ -24,7 +24,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic public abstract class AvoidCmdletGeneric : IScriptRule { /// - /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis. + /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis. /// /// The script's ast /// The name of the script file being analyzed @@ -38,7 +38,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) List 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; diff --git a/Engine/Generic/AvoidParameterGeneric.cs b/Engine/Generic/AvoidParameterGeneric.cs index b61835056..2f108b07d 100644 --- a/Engine/Generic/AvoidParameterGeneric.cs +++ b/Engine/Generic/AvoidParameterGeneric.cs @@ -23,7 +23,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic public abstract class AvoidParameterGeneric : IScriptRule { /// - /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis. + /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis. /// /// The script's ast /// The name of the script file being analyzed @@ -35,7 +35,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all CommandAsts. IEnumerable 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) diff --git a/Engine/Generic/ILogger.cs b/Engine/Generic/ILogger.cs index 9f0adac0a..8b620e018 100644 --- a/Engine/Generic/ILogger.cs +++ b/Engine/Generic/ILogger.cs @@ -34,7 +34,7 @@ public interface ILogger string GetName(); /// - /// GetDescription: Retrives the description of the logger. + /// GetDescription: Retrieves the description of the logger. /// /// The description of the logger string GetDescription(); diff --git a/Engine/Generic/IScriptRule.cs b/Engine/Generic/IScriptRule.cs index 15bafbe87..df7de53fa 100644 --- a/Engine/Generic/IScriptRule.cs +++ b/Engine/Generic/IScriptRule.cs @@ -25,7 +25,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic public interface IScriptRule : IRule { /// - /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the anaylsis. + /// AnalyzeScript: Analyzes the given Ast and returns DiagnosticRecords based on the analysis. /// /// The script's ast /// The name of the script file being analyzed diff --git a/Engine/Generic/SourceType.cs b/Engine/Generic/SourceType.cs index dfff87f2a..df8e49843 100644 --- a/Engine/Generic/SourceType.cs +++ b/Engine/Generic/SourceType.cs @@ -23,7 +23,7 @@ public enum SourceType : uint Builtin = 0, /// - /// MANAGED: Indicates the script analyzer rule is contirbuted as a managed rule. + /// MANAGED: Indicates the script analyzer rule is contributed as a managed rule. /// Managed = 1, diff --git a/Engine/PSScriptAnalyzer.psd1 b/Engine/PSScriptAnalyzer.psd1 index c68e1d647..00f513f22 100644 --- a/Engine/PSScriptAnalyzer.psd1 +++ b/Engine/PSScriptAnalyzer.psd1 @@ -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' diff --git a/Engine/ScriptAnalyzer.cs b/Engine/ScriptAnalyzer.cs index 2c5c5ea80..c0e685c40 100644 --- a/Engine/ScriptAnalyzer.cs +++ b/Engine/ScriptAnalyzer.cs @@ -888,7 +888,7 @@ public Dictionary> CheckRuleExtension(string[] path, PathIn } } - // Resloves relative paths. + // Resolves relative paths. try { for (int i = 0; i < validModPaths.Count; i++) diff --git a/Engine/VariableAnalysis.cs b/Engine/VariableAnalysis.cs index 314457ec3..de45e92e9 100644 --- a/Engine/VariableAnalysis.cs +++ b/Engine/VariableAnalysis.cs @@ -133,7 +133,7 @@ private void ProcessParameters(IEnumerable parameters) } /// - /// Used to analyze scriptbloct, functionmemberast or functiondefinitionast + /// Used to analyze scriptblock, functionmemberast or functiondefinitionast /// /// /// diff --git a/Engine/VariableAnalysisBase.cs b/Engine/VariableAnalysisBase.cs index f1d40ca66..eb7f3182d 100644 --- a/Engine/VariableAnalysisBase.cs +++ b/Engine/VariableAnalysisBase.cs @@ -552,7 +552,7 @@ internal static Block[] SetDominators(Block entry, List 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) @@ -828,14 +828,14 @@ internal static Tuple, Dictionary, Dictionary 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; } @@ -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(); diff --git a/Engine/about_PSScriptAnalyzer.help.txt b/Engine/about_PSScriptAnalyzer.help.txt index a20df5e5d..43bf6e88c 100644 --- a/Engine/about_PSScriptAnalyzer.help.txt +++ b/Engine/about_PSScriptAnalyzer.help.txt @@ -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 diff --git a/Rules/AvoidAlias.cs b/Rules/AvoidAlias.cs index 5e9626923..1b3e05779 100644 --- a/Rules/AvoidAlias.cs +++ b/Rules/AvoidAlias.cs @@ -35,7 +35,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all CommandAsts. IEnumerable 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; diff --git a/Rules/AvoidDefaultTrueValueSwitchParameter.cs b/Rules/AvoidDefaultTrueValueSwitchParameter.cs index ee5c60a44..c170308a4 100644 --- a/Rules/AvoidDefaultTrueValueSwitchParameter.cs +++ b/Rules/AvoidDefaultTrueValueSwitchParameter.cs @@ -36,7 +36,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all ParamAsts. IEnumerable paramAsts = ast.FindAll(testAst => testAst is ParameterAst, true); - // Iterrates all ParamAsts and check if any are switch. + // Iterates all ParamAsts and check if any are switch. foreach (ParameterAst paramAst in paramAsts) { if (paramAst.Attributes.Any(attr => attr.TypeName.GetReflectionType() == typeof(System.Management.Automation.SwitchParameter)) diff --git a/Rules/AvoidEmptyCatchBlock.cs b/Rules/AvoidEmptyCatchBlock.cs index 6ee312d76..41b1bd45a 100644 --- a/Rules/AvoidEmptyCatchBlock.cs +++ b/Rules/AvoidEmptyCatchBlock.cs @@ -35,7 +35,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all CommandAsts. IEnumerable foundAsts = ast.FindAll(testAst => testAst is CatchClauseAst, true); - // Iterrates all CatchClauseAst and check the statements count. + // Iterates all CatchClauseAst and check the statements count. foreach (Ast foundAst in foundAsts) { CatchClauseAst catchAst = (CatchClauseAst)foundAst; diff --git a/Rules/AvoidPositionalParameters.cs b/Rules/AvoidPositionalParameters.cs index 9744096bf..02a375ff4 100644 --- a/Rules/AvoidPositionalParameters.cs +++ b/Rules/AvoidPositionalParameters.cs @@ -35,7 +35,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all CommandAsts. IEnumerable 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; diff --git a/Rules/AvoidShouldContinueWithoutForce.cs b/Rules/AvoidShouldContinueWithoutForce.cs index 42996c990..a9025827d 100644 --- a/Rules/AvoidShouldContinueWithoutForce.cs +++ b/Rules/AvoidShouldContinueWithoutForce.cs @@ -37,7 +37,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all ParamAsts. IEnumerable funcAsts = ast.FindAll(testAst => testAst is FunctionDefinitionAst, true); - // Iterrates all ParamAsts and check if there are any force. + // Iterates all ParamAsts and check if there are any force. foreach (FunctionDefinitionAst funcAst in funcAsts) { IEnumerable paramAsts = funcAst.FindAll(testAst => testAst is ParameterAst, true); diff --git a/Rules/AvoidUserNameAndPasswordParams.cs b/Rules/AvoidUserNameAndPasswordParams.cs index 4fd643d46..a0b4aec87 100644 --- a/Rules/AvoidUserNameAndPasswordParams.cs +++ b/Rules/AvoidUserNameAndPasswordParams.cs @@ -50,7 +50,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) // Finds all ParamAsts. IEnumerable paramAsts = funcAst.FindAll(testAst => testAst is ParameterAst, true); - // Iterrates all ParamAsts and check if their names are on the list. + // Iterates all ParamAsts and check if their names are on the list. foreach (ParameterAst paramAst in paramAsts) { var psCredentialType = paramAst.Attributes.FirstOrDefault(paramAttribute => diff --git a/Rules/AvoidUsingPlainTextForPassword.cs b/Rules/AvoidUsingPlainTextForPassword.cs index 4586b27e0..766aa78ee 100644 --- a/Rules/AvoidUsingPlainTextForPassword.cs +++ b/Rules/AvoidUsingPlainTextForPassword.cs @@ -39,7 +39,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) List passwords = new List() {"Password", "Passphrase", "Cred", "Credential"}; - // Iterrates all ParamAsts and check if their names are on the list. + // Iterates all ParamAsts and check if their names are on the list. foreach (ParameterAst paramAst in paramAsts) { TypeInfo paramType = (TypeInfo) paramAst.StaticType; diff --git a/Rules/ScriptAnalyzerBuiltinRules.csproj b/Rules/ScriptAnalyzerBuiltinRules.csproj index 0908618ea..ded1db911 100644 --- a/Rules/ScriptAnalyzerBuiltinRules.csproj +++ b/Rules/ScriptAnalyzerBuiltinRules.csproj @@ -1,117 +1,117 @@ - - - - Debug - AnyCPU - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E} - Library - false - Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules - - - - - - - - - - - False - ..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Strings.resx - - - - - - - - - - - - - - - - - - - - - - - {f4bde3d0-3eef-4157-8a3e-722df7adef60} - ScriptAnalyzerEngine - - - - - Designer - ResXFileCodeGenerator - Strings.Designer.cs - - - - - - - - mkdir "$(SolutionDir)$(SolutionName)" -copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)" - + + + + Debug + AnyCPU + {C33B6B9D-E61C-45A3-9103-895FD82A5C1E} + Library + false + Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules + + + + + + + + + + + False + ..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Strings.resx + + + + + + + + + + + + + + + + + + + + + + + {f4bde3d0-3eef-4157-8a3e-722df7adef60} + ScriptAnalyzerEngine + + + + + Designer + ResXFileCodeGenerator + Strings.Designer.cs + + + + + + + + if not exist "$(SolutionDir)$(SolutionName)" mkdir "$(SolutionDir)$(SolutionName)" +copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)" + \ No newline at end of file diff --git a/Rules/UseDeclaredVarsMoreThanAssignments.cs b/Rules/UseDeclaredVarsMoreThanAssignments.cs index afc47410e..e00538fd3 100644 --- a/Rules/UseDeclaredVarsMoreThanAssignments.cs +++ b/Rules/UseDeclaredVarsMoreThanAssignments.cs @@ -87,7 +87,7 @@ public IEnumerable AnalyzeScript(Ast ast, string fileName) { assignments.Remove(varKey); } - //Check if variable belongs to PowerShell builtin variables + //Check if variable belongs to PowerShell built-in variables if (Helper.Instance.HasSpecialVars(varKey)) { assignments.Remove(varKey); From 3735e375f777f430dbb537e93874ffb633acd5bb Mon Sep 17 00:00:00 2001 From: Kory Gill Date: Wed, 9 Dec 2015 11:54:20 -0800 Subject: [PATCH 2/2] Fix post-build in both csproj files. --- Engine/ScriptAnalyzerEngine.csproj | 227 ++++++++++++------------ Rules/ScriptAnalyzerBuiltinRules.csproj | 6 +- 2 files changed, 118 insertions(+), 115 deletions(-) diff --git a/Engine/ScriptAnalyzerEngine.csproj b/Engine/ScriptAnalyzerEngine.csproj index 3e0b3ce67..46c607751 100644 --- a/Engine/ScriptAnalyzerEngine.csproj +++ b/Engine/ScriptAnalyzerEngine.csproj @@ -1,114 +1,115 @@ - - - - Debug - AnyCPU - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60} - Library - false - Microsoft.Windows.PowerShell.ScriptAnalyzer - v4.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - Microsoft.Windows.PowerShell.ScriptAnalyzer - - - - - - - - - - False - ..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - Strings.resx - - - - - - - - - - - - ResXFileCodeGenerator - Strings.Designer.cs - - - - - - - - - - - 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" - + + + + Debug + AnyCPU + {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60} + Library + false + Microsoft.Windows.PowerShell.ScriptAnalyzer + v4.5 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + Microsoft.Windows.PowerShell.ScriptAnalyzer + + + + + + + + + + False + ..\..\..\..\..\..\fbl_srv2_ci_mgmt.binaries.amd64chk\monad\System.Management.Automation.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + True + Strings.resx + + + + + + + + + + + + ResXFileCodeGenerator + Strings.Designer.cs + + + + + + + + + + + + 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" + \ No newline at end of file diff --git a/Rules/ScriptAnalyzerBuiltinRules.csproj b/Rules/ScriptAnalyzerBuiltinRules.csproj index ded1db911..73ca65257 100644 --- a/Rules/ScriptAnalyzerBuiltinRules.csproj +++ b/Rules/ScriptAnalyzerBuiltinRules.csproj @@ -111,7 +111,9 @@ - if not exist "$(SolutionDir)$(SolutionName)" mkdir "$(SolutionDir)$(SolutionName)" -copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)" + + if not exist "$(SolutionDir)$(SolutionName)" mkdir "$(SolutionDir)$(SolutionName)" + copy /y "$(TargetPath)" "$(SolutionDir)$(SolutionName)" + \ No newline at end of file