PSCodeHealth
PSCodeHealth copied to clipboard
Separate private and public functions
In using v0.2.7, Invoke-PSCodehealth is detecting all functions, but it treats them the same. There's nothing wrong with detecting all the functions, but they should be identified as private or public (i.e. exported module member). That way if in an html report I see a private function with no help, I'm not concerned about that. But I would hope that there are a few lines of comments that explain the function which shouldn't be considered a penalty on function length per our other issue.
In the PerFunction section, added a column indicating if the function is exported or not. That would be helpful.
Hi Jeffery,
This applies only to modules, but yes, knowing whether a function is public or private is useful information. I'm going to investigate how to implement that.
By the way, how do think this property should be named ? Visibility ?
I think it would still be useful to check private function for help, at least to populate the Per Function Information table but private functions without help could be excluded from the FunctionsWithoutHelp property of the report.
As a relevant sidenote, there is no compliance rule for the FunctionsWithoutHelp metric because, as the docs say :
There is no compliance rule for this metric because it is highly dependent on the total number of functions, and arguably, on the number of public functions.
In other words PSCodeHealth tells the number of functions without help but doesn't tell if it's good or bad.
If we don't count private function in this metric, I guess it would be a good idea to rename it to PublicFunctionsWithoutHelp to make that clear.
And then, having a compliance rule on this PublicFunctionsWithoutHelp metric would make sense.
Thanks a lot for your feedback.
Since now you seem to be getting a list of all functions, you should also be able to use Get-Command to discover the exported functions and compare. You could use Visibility and Private/Public or Exported with True/False. The functions without help metric should be limited to exported functions.
Hi Jeffery,
Yes, I'm gonna go with a property named Exported and a boolean value.