Skip to content

Conversation

@kvprasoon
Copy link
Contributor

@kvprasoon kvprasoon commented Jul 1, 2018

Adding -AllStats Switch parameter for Measure-Object cmdlet, Issue #6278

PR Summary

Adding -AllStats parameter for Measure-Object cmdlet based on the Issue #6278 .

PR Checklist

Adding -AllStats Switch parameter for Measure-Object cmdlet, Issue #6278
kvprasoon added 2 commits July 1, 2018 18:58
Code factor fixes
Code factor fix
@kvprasoon
Copy link
Contributor Author

kvprasoon commented Jul 1, 2018

@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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Spelling of "statistics".

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

@kvprasoon kvprasoon Jul 2, 2018

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.

kvprasoon added 2 commits July 3, 2018 00:24
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
Copy link
Contributor

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.

Copy link
Contributor Author

@kvprasoon kvprasoon Jul 3, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dantraMSFT Done..

Copy link
Contributor

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.

Copy link
Contributor

@PaulHigin PaulHigin left a 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()
Copy link
Contributor

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.

Copy link
Contributor Author

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
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 6, 2018

@kvprasoon Please fix one CodeFactor issue and I'll merge.

@iSazonov iSazonov self-assigned this Jul 6, 2018
@dantraMSFT
Copy link
Contributor

@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.
@kvprasoon
Copy link
Contributor Author

@dantraMSFT Great, it worked.

@iSazonov iSazonov closed this Jul 7, 2018
@iSazonov iSazonov reopened this Jul 7, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 7, 2018

Reopen the PR to restart CIs.

@kvprasoon
Copy link
Contributor Author

@iSazonov CI got failed again...

@iSazonov iSazonov merged commit 9dcfddd into PowerShell:master Jul 9, 2018
@iSazonov
Copy link
Collaborator

iSazonov commented Jul 9, 2018

@kvprasoon Thanks for your contribution!

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.

4 participants