Skip to content

add validation for powershell scripts in CI#64987

Closed
jmarolf wants to merge 2 commits intodotnet:mainfrom
jmarolf:infrastructure/correctness-powershell
Closed

add validation for powershell scripts in CI#64987
jmarolf wants to merge 2 commits intodotnet:mainfrom
jmarolf:infrastructure/correctness-powershell

Conversation

@jmarolf
Copy link
Contributor

@jmarolf jmarolf commented Oct 25, 2022

No description provided.

@ghost ghost added the Area-Infrastructure label Oct 25, 2022
@jmarolf jmarolf force-pushed the infrastructure/correctness-powershell branch from 3ef4ee0 to 0558cb0 Compare October 26, 2022 16:05
@jmarolf jmarolf force-pushed the infrastructure/correctness-powershell branch from 0558cb0 to 3590b5e Compare October 26, 2022 16:13
@jmarolf
Copy link
Contributor Author

jmarolf commented Oct 26, 2022

tagging @jaredpar as I really need him to tell me if he thinks this has any value.

  • here is where I add the validation script
  • and here is where I resolve or suppress the warnings

We have the ability to write our own custom analyzers for this and if Jared knows of any mistakes we want to check for we could write and use those.

One of the downsides of unused variable analysis is that they only look in the scope the variable is declared in not the child scopes and we do a lot of magic "declare this variable before calling this function because I know that it expects them to exist".

[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'bootstrapConfiguration')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'buildServerLog')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'collectDumps')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'configuration')]
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about this rule. Many of these parameters are clearly used so why are we getting an unused diagnostc here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the "scope" they are declared in is just the try-catch which they are not used in. They are used in child scopes (i.e. other functions) implicitly. to remove this we would need to explicitly pass these to all the functions that consume them instead of assuming that they are defined in the parent scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for example:

$configuration is only read from implicitly in BuildSolution() and TestUsingRunTests(). We could instead explicitly pass it as an argument to both those functions if we wanted to get rid of the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants