Skip to content

Fix AvoidReservedParams does not work if function does not have cmdletbi... #22

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

Merged
merged 2 commits into from
Apr 10, 2015

Conversation

quoctruong
Copy link

AvoidReservedParams does not work if function does not have cmdlet binding attribute. Also the current implementation looks at the parameter first before the outer function (should be the other way round).

@yutingc
Copy link
Contributor

yutingc commented Apr 10, 2015

People can use reserved parameters on regular functions. This rule should only apply to cmdlets with [cmdletBinding()]

@@ -30,43 +30,38 @@ public class AvoidReservedParams : IScriptRule
public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName) {
if (ast == null) throw new ArgumentNullException(Strings.NullAstErrorMessage);

IEnumerable<Ast> paramAsts = ast.FindAll(testAst => testAst is ParameterAst, true);
Ast parentAst;
IEnumerable<Ast> funcAsts = ast.FindAll(item => item is FunctionDefinitionAst, true);

string paramName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initialize to null

@quoctruong
Copy link
Author

Update the check for cmdletbinding and initialize the string paramName

@yutingc
Copy link
Contributor

yutingc commented Apr 10, 2015

Looks good now. Thanks!

@raghushantha
Copy link
Member

looks good.. proceed with the merge. thanks

quoctruong pushed a commit that referenced this pull request Apr 10, 2015
Fix AvoidReservedParams does not work if function does not have cmdletbi...
@quoctruong quoctruong merged commit f18d564 into BugFixes Apr 10, 2015
@quoctruong
Copy link
Author

Thanks! Merged

@quoctruong quoctruong deleted the FixReservedParamBug branch April 10, 2015 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants