Skip to content

Adding -AllStats Switch parameter for Measure-Object cmdlet - #7220

Merged
Ilya (iSazonov) merged 8 commits into
PowerShell:masterfrom
kvprasoon:master
Jul 9, 2018
Merged

Adding -AllStats Switch parameter for Measure-Object cmdlet#7220
Ilya (iSazonov) merged 8 commits into
PowerShell:masterfrom
kvprasoon:master

Conversation

@kvprasoon

@kvprasoon PRASOON KARUNAN V (kvprasoon) commented Jul 1, 2018

Copy link
Copy Markdown
Contributor

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

PRASOON KARUNAN V (kvprasoon) commented Jul 1, 2018

Copy link
Copy Markdown
Contributor Author

Ilya (@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@kvprasoon PRASOON KARUNAN V (kvprasoon) Jul 2, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Paul Higinbotham (@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

Copy link
Copy Markdown
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.

@kvprasoon PRASOON KARUNAN V (kvprasoon) Jul 3, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dan Travison (@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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PRASOON KARUNAN V (@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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks PRASOON KARUNAN V (@kvprasoon), that looks good.

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

PRASOON KARUNAN V (@kvprasoon) Please fix one CodeFactor issue and I'll merge.

@iSazonov Ilya (iSazonov) self-assigned this Jul 6, 2018
@dantraMSFT

Copy link
Copy Markdown
Contributor

PRASOON KARUNAN V (@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
Copy Markdown
Contributor Author

Dan Travison (@dantraMSFT) Great, it worked.

@iSazonov

Copy link
Copy Markdown
Collaborator

Reopen the PR to restart CIs.

@kvprasoon

Copy link
Copy Markdown
Contributor Author

Ilya (@iSazonov) CI got failed again...

@iSazonov
Ilya (iSazonov) merged commit 9dcfddd into PowerShell:master Jul 9, 2018
@iSazonov

Copy link
Copy Markdown
Collaborator

PRASOON KARUNAN V (@kvprasoon) Thanks for your contribution!

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
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