-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Adding -AllStats Switch parameter for Measure-Object cmdlet #7220
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
Conversation
Adding -AllStats Switch parameter for Measure-Object cmdlet, Issue #6278
Code factor fixes
Code factor fix
|
@iSazonov I'm not able to understand this Code factor issue. |
| private bool _measureSum; | ||
|
|
||
| /// <summary> | ||
| /// Sets all generic parameters to true and returns all the statitics. |
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.
Spelling of "statistics".
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.
oops, that was a typo.
| return; | ||
| } | ||
|
|
||
| if (_allStats) |
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.
This should go into the BeginProcessing{} block, since it only needs to be run once.
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.
@PaulHigin Thanks, Added the same.
Changes as per review comments.
Code factor fix.
| $testNumbers = 1,1,2,4,5,6 | ||
| $actual = $testNumbers | Measure-Object -AllStats | ||
|
|
||
| $actual.Average | Should -Not -BeNullOrEmpty |
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.
These Should statements should be testing for numeric values, not string values.
Take a look at the test "Measure-Object with ScriptBlock properties should work". You can use the same range and results for this test.
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.
@dantraMSFT Thanks, changed the same. But the StandardDeviation is always a decimal value and cannot be asserted with int data type, hence excluded.
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.
@kvprasoon: I suggest you at least verify it is populated, such as comparing it's ToString() value against the expected string value (2.13697605664328); otherwise, its not completely verified.
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.
@dantraMSFT Done..
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.
Thanks @kvprasoon, that looks good.
PaulHigin
left a comment
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.
LGTM
| /// <summary> | ||
| /// Does the begin part of the cmdlet. | ||
| /// </summary> | ||
| protected override void BeginProcessing() |
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.
Actually, you should call the base class implementation, base.BeginProcessing(), here.
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.
Done
Review comment changes
Adding assertion for StandardDeviationin unitMeasure-Object test
|
@kvprasoon Please fix one CodeFactor issue and I'll merge. |
|
@kvprasoon I believe what it is looking for is something like... Gets or sets the value indicating if all statistics should be returned. |
Code factor issue fix.
|
@dantraMSFT Great, it worked. |
|
Reopen the PR to restart CIs. |
|
@iSazonov CI got failed again... |
|
@kvprasoon Thanks for your contribution! |
Adding -AllStats Switch parameter for Measure-Object cmdlet, Issue #6278
PR Summary
Adding
-AllStatsparameter forMeasure-Objectcmdlet based on the Issue #6278 .PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.-Allparameter #6278[feature]if the change is significant or affects feature tests