Skip to content

Get-ScriptBlockScope is defined but never used #2702

@nohwnd

Description

@nohwnd

Get-ScriptBlockScope is defined in src/functions/Pester.Scoping.ps1 (line 50) but has zero call sites anywhere in the repo (src, tests, docs). A repo-wide search returns only the definition itself.

It would be useful in Test-ParameterFilter (src/functions/Mock.ps1, ~L1225) where Set-ScriptBlockScope -ScriptBlock -SessionState is called. Today comes from .SessionState of Should -Invoke, which usually equals the session state to which the filter scriptblock is bound — but not always (e.g. authoring a filter in one session state and passing it to Should -Invoke invoked from another). Pulling the session state directly off the filter scriptblock via Get-ScriptBlockScope would handle that case.

Options:

  • Wire Get-ScriptBlockScope into Test-ParameterFilter (and any other place that should respect the scriptblock's own binding)
  • Or simply delete the unused function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions