From 505399719681aaaa275479bd2ed81bf317bf0376 Mon Sep 17 00:00:00 2001 From: Yuting Chen Date: Wed, 8 Apr 2015 16:10:55 -0700 Subject: [PATCH 1/2] Change rule strict to information --- Rules/ProvideCommentHelp.cs | 2 +- Rules/ProvideVerboseMessage.cs | 2 +- Rules/ReturnCorrectTypesForDSCFunctions.cs | 12 ++++++------ Rules/UseIdenticalMandatoryParametersDSC.cs | 2 +- Rules/UseIdenticalParametersDSC.cs | 4 ++-- Rules/UseStandardDSCFunctionsInResource.cs | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Rules/ProvideCommentHelp.cs b/Rules/ProvideCommentHelp.cs index 15f82fd7a..e65193518 100644 --- a/Rules/ProvideCommentHelp.cs +++ b/Rules/ProvideCommentHelp.cs @@ -56,7 +56,7 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun DiagnosticRecords.Add( new DiagnosticRecord( string.Format(CultureInfo.CurrentCulture, Strings.ProvideCommentHelpError, funcAst.Name), - funcAst.Extent, GetName(), DiagnosticSeverity.Strict, fileName)); + funcAst.Extent, GetName(), DiagnosticSeverity.Information, fileName)); } } diff --git a/Rules/ProvideVerboseMessage.cs b/Rules/ProvideVerboseMessage.cs index 736b76ba1..6faec0730 100644 --- a/Rules/ProvideVerboseMessage.cs +++ b/Rules/ProvideVerboseMessage.cs @@ -65,7 +65,7 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun if (!hasVerbose) { DiagnosticRecords.Add(new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ProvideVerboseMessageErrorFunction, funcAst.Name), - funcAst.Extent, GetName(), DiagnosticSeverity.Strict, fileName)); + funcAst.Extent, GetName(), DiagnosticSeverity.Information, fileName)); } return AstVisitAction.Continue; diff --git a/Rules/ReturnCorrectTypesForDSCFunctions.cs b/Rules/ReturnCorrectTypesForDSCFunctions.cs index 288cd10d5..64fc6af58 100644 --- a/Rules/ReturnCorrectTypesForDSCFunctions.cs +++ b/Rules/ReturnCorrectTypesForDSCFunctions.cs @@ -49,7 +49,7 @@ item is TypeDefinitionAst foreach (Tuple outputType in outputTypes) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReturnCorrectTypesForSetTargetResourceFunctionsDSCError), - outputType.Item2.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + outputType.Item2.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } else @@ -73,7 +73,7 @@ item is TypeDefinitionAst else { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReturnCorrectTypesForGetTestTargetResourceFunctionsDSCResourceError, - func.Name, returnTypes[func.Name], type), outputType.Item2.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + func.Name, returnTypes[func.Name], type), outputType.Item2.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } @@ -116,7 +116,7 @@ item is TypeDefinitionAst if (!String.Equals(funcAst.Name, "Set") && !Helper.Instance.AllCodePathReturns(funcAst)) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.NotAllCodePathReturnsDSCFunctionsError, funcAst.Name, dscClass.Name), - funcAst.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + funcAst.Extent, GetName(), DiagnosticSeverity.Information, fileName); } if (String.Equals(funcAst.Name, "Set")) @@ -127,7 +127,7 @@ item is TypeDefinitionAst if (ret.Pipeline != null) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReturnCorrectTypesForSetFunctionsDSCError, dscClass.Name), - funcAst.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + funcAst.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } @@ -143,7 +143,7 @@ item is TypeDefinitionAst { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReturnCorrectTypesForDSCFunctionsNoTypeError, funcAst.Name, dscClass.Name, returnTypes[funcAst.Name]), - ret.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + ret.Extent, GetName(), DiagnosticSeverity.Information, fileName); } string typeName = Helper.Instance.GetTypeFromReturnStatementAst(funcAst, ret, classes); @@ -161,7 +161,7 @@ item is TypeDefinitionAst { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.ReturnCorrectTypesForDSCFunctionsWrongTypeError, funcAst.Name, dscClass.Name, returnTypes[funcAst.Name], typeName), - ret.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + ret.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } diff --git a/Rules/UseIdenticalMandatoryParametersDSC.cs b/Rules/UseIdenticalMandatoryParametersDSC.cs index 9f4b086fa..f91619482 100644 --- a/Rules/UseIdenticalMandatoryParametersDSC.cs +++ b/Rules/UseIdenticalMandatoryParametersDSC.cs @@ -86,7 +86,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName { List functionsNotContainingParam = expectedTargetResourceFunctionNames.Except(mandatoryParameters[paramName]).ToList(); yield return new DiagnosticRecord(string.Format(CultureInfo.InvariantCulture, Strings.UseIdenticalMandatoryParametersDSCError, paramName, string.Join(", ", functionsNotContainingParam.ToArray())), - ast.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + ast.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } diff --git a/Rules/UseIdenticalParametersDSC.cs b/Rules/UseIdenticalParametersDSC.cs index 01c3aacc1..853ee8d5d 100644 --- a/Rules/UseIdenticalParametersDSC.cs +++ b/Rules/UseIdenticalParametersDSC.cs @@ -48,7 +48,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName if (funcParamAsts.Count() != funcParamAsts2.Count()) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError), - firstFunc.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + firstFunc.Extent, GetName(), DiagnosticSeverity.Information, fileName); } foreach (ParameterAst paramAst in funcParamAsts) @@ -62,7 +62,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName || !CompareParamAsts(paramAst, paramNames[paramAst.Name.VariablePath.UserPath])) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError), - paramAst.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + paramAst.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } diff --git a/Rules/UseStandardDSCFunctionsInResource.cs b/Rules/UseStandardDSCFunctionsInResource.cs index 35b0dd9a9..bf97a4cf1 100644 --- a/Rules/UseStandardDSCFunctionsInResource.cs +++ b/Rules/UseStandardDSCFunctionsInResource.cs @@ -49,7 +49,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.CurrentCultureIgnoreCase)) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInResourceError, expectedTargetResourceFunctionName), - ast.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + ast.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } @@ -80,7 +80,7 @@ item is TypeDefinitionAst if (!functions.Any(function => String.Equals(resourceFunctionName, (function as FunctionMemberAst).Name))) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInClassError, resourceFunctionName), - dscClass.Extent, GetName(), DiagnosticSeverity.Strict, fileName); + dscClass.Extent, GetName(), DiagnosticSeverity.Information, fileName); } } } From 4ed486167944464332154d5a8d5943972f3d9f26 Mon Sep 17 00:00:00 2001 From: Yuting Chen Date: Wed, 8 Apr 2015 16:20:29 -0700 Subject: [PATCH 2/2] add missing files --- Engine/Commands/InvokeScriptAnalyzerCommand.cs | 2 +- Engine/Generic/DiagnosticRecord.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Engine/Commands/InvokeScriptAnalyzerCommand.cs b/Engine/Commands/InvokeScriptAnalyzerCommand.cs index 56e3c2d05..b31bf7187 100644 --- a/Engine/Commands/InvokeScriptAnalyzerCommand.cs +++ b/Engine/Commands/InvokeScriptAnalyzerCommand.cs @@ -77,7 +77,7 @@ public string[] IncludeRule /// /// IncludeRule: Array of the severity types to be enabled. /// - [ValidateSet("Warning", "Error", "Strict", IgnoreCase = true)] + [ValidateSet("Warning", "Error", "Information", IgnoreCase = true)] [Parameter(Mandatory = false)] [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] public string[] Severity diff --git a/Engine/Generic/DiagnosticRecord.cs b/Engine/Generic/DiagnosticRecord.cs index b4e069cd0..732777025 100644 --- a/Engine/Generic/DiagnosticRecord.cs +++ b/Engine/Generic/DiagnosticRecord.cs @@ -98,9 +98,9 @@ public DiagnosticRecord(string message, IScriptExtent extent, string ruleName, D public enum DiagnosticSeverity : uint { /// - /// STRICT: This diagnostic is trivial, but may be useful. + /// Information: This diagnostic is trivial, but may be useful. /// - Strict = 0, + Information = 0, /// /// WARNING: This diagnostic may cause a problem or does not follow PowerShell's recommended guidelines.