-
Notifications
You must be signed in to change notification settings - Fork 394
Add PSProvideDefaultParameterValue Rule #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PSProvideDefaultParameterValue Rule #174
Conversation
Per @rkeithhill suggestion in #133
Getting "Object reference not set to an instance of an object error" when running test, but seems to complete successfully. Need to investigate error.
…d inside function
@@ -65,13 +65,16 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) | |||
|
|||
HashSet<string> paramVariables = new HashSet<string>(); | |||
|
|||
if (isDscResourceFile && targetResourcesFunctions.Contains(funcAst.Name, StringComparer.OrdinalIgnoreCase)) | |||
// don't raise the rules for variables in the param block. | |||
if (funcAst.Body != null && funcAst.Body.ParamBlock != null && funcAst.Body.ParamBlock.Parameters != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't raise this error for param block, I think you can remove the checking for whether this is a DSC resource file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in 2528ca6
Thanks @GoodOlClint for the new rule. Changes look good to me. |
Thanks for your contributions GoodOlClint. Your changes are good and the build went well. We will merge the fixes. |
Add PSProvideDefaultParameterValue Rule
Per suggestions in #133 Added new rule for parameters and modified PSAvoidUninitializedVariable rule to ignore variables defined in either the function arguments or a param block.