Skip to content

Separate private and public functions #9

Open

Description

@jdhitsolutions

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.

Activity

  1. MathieuBuisson commented on Oct 12, 2017

    @MathieuBuisson
    Owner

    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.

  2. jdhitsolutions commented on Oct 12, 2017

    @jdhitsolutions
    Author

    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.

  3. MathieuBuisson commented on Oct 13, 2017

    @MathieuBuisson
    Owner

    Hi Jeffery,

    Yes, I'm gonna go with a property named Exported and a boolean value.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions