Skip to content

PSProvideDefaultParameterValue is always wrong. #362

Closed
@Jaykul

Description

@Jaykul

This rule should not exist at all

Function parameters are always automatically defined in the local scope and initialized by PowerShell to their default value (the equivalent of null -- which comes out as an empty string or a zero for numerical values, or a default struct, etc)

This happens even when they are part of an unused parameter set.

There is absolutely ZERO value, and nothing to be gained in setting them yourself -- unless you actually need them to default to something other than $null.

If anything, this should be warned against for performance reasons. Initializing a variable to it's default value is just extra work that accomplishes nothing. It might even make your script (infinitesimally) slower, whilst changing nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions