Skip to content

UseShouldProcessCorrectly should analyze downstream function calls #608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
richardszalay opened this issue Aug 30, 2016 · 1 comment
Closed
Assignees

Comments

@richardszalay
Copy link

It's not uncommon to have a function that doesn't make use of ShouldProcess itself, but calls child functions that do. Here's an example:

function Outer
{
    [CmdletBinding(SupportsShouldProcess=$true)]
    param()

    Inner
}

function Inner
{
    [CmdletBinding(SupportsShouldProcess=$true)]
    param()

    if ($PSCmdlet.ShouldProcess("Inner"))
    {
        Write-Host "Process!"
    }
    else
    {
        Write-Host "Skipped!"
    }
}

Outer -WhatIf

UseShouldProcessCorrectly triggers in these scenarios, but arguably shouldn't since it runs as expected.

(It's quite possible that I've missed a standard convention here that makes this issue irrelevant, so feel free to correct me if that's the case)

@Jaykul
Copy link
Contributor

Jaykul commented Sep 4, 2016

How many times do we have to complain about this?

I'm sick of writing:

    [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess")] # Because PSSCriptAnalyzer can't see Set-Content...
    [CmdletBinding(SupportsShouldProcess)]

See #194 #283 #521

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

No branches or pull requests

3 participants