Skip to content

Missing Documentation about Rules #155

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
2 tasks done
TBobsin opened this issue Jul 27, 2023 · 1 comment
Closed
2 tasks done

Missing Documentation about Rules #155

TBobsin opened this issue Jul 27, 2023 · 1 comment
Labels
issue-doc-idea Issue - request for new content needs-triage Waiting - Needs triage

Comments

@TBobsin
Copy link

TBobsin commented Jul 27, 2023

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Document new Get-Foo cmdlet" instead of "New cmdlet."

Module

PSScriptAnalyzer

Summary

Missing Description of PSUseDeclaredVarsMoreThanAssignments rules in PSScriptAnalyzerSettings.ps1.

I have tried to exclude one VarName from being marked.

Details

You could define Settings in PSScriptAnalyzerSettings.ps1

i tried to set an rule to exclude one Var but mark all other Var
but that is not working. And i found no description about PSUseDeclaredVarsMoreThanAssignments
This is what i have tried:

Rules = @{
    PSUseDeclaredVarsMoreThanAssignments = @(
        Whitelist = @('CMK_VERSION')
    )
}

Content Type

How-to

Proposed Title

PSUseDeclaredVarsMoreThanAssignments Rules

Related Articles

No response

@TBobsin TBobsin added issue-doc-idea Issue - request for new content needs-triage Waiting - Needs triage labels Jul 27, 2023
@michaeltlombardi
Copy link
Contributor

Thanks for filing this issue, @TBobsin!

If you're looking for the documentation for the rule, that's UseDeclaredVarsMoreThanAssignments. The documentation for suppressing rules is in the "Suppressing Rules" section of the Using PSScriptAnalyzer article.

Unfortunately, there's no way to suppress the UseDeclaredVarsMoreThanAssignments rule for a single variable. You can suppress the rule for a scriptblock or function with the snippet:

[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
    <#Rule ID#>  'PSUseDeclaredVarsMoreThanAssignments',
    <#Check ID#> $null,
    Justification = 'Reason for suppressing'
)]

Although the constructor for SuppressMessageAttribute includes a check ID, it's not used by the UseDeclaredVarsMoreThanAssignments rule in PSSA.

The following issues in the PSSA repository relate to this limitation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue-doc-idea Issue - request for new content needs-triage Waiting - Needs triage
Projects
None yet
Development

No branches or pull requests

2 participants