Skip to content

[Question] Retrieve all Configurable rules #823

Closed

Description

I try to retrieve all configurable rule with this code, but the 'AvoidAlias' rule is missing, should not this rule be of the ConfigurableRule type ?

$sb= {dir}
#Force Dll Loading
Invoke-ScriptAnalyzer -ScriptDefinition $sb.ast

$BuiltinRules= [System.AppDomain]::CurrentDomain.GetAssemblies()|? location -match 'Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules'
$BuiltinRules.GetTypes()|? {$_.IsSubclassOf([Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.ConfigurableRule])}

Activity

  1. bergmeister commented on Dec 2, 2017

    @bergmeister
    Collaborator

    The correct and easier way to retrieve all rules is Get-ScriptAnalyzerRule.
    The alias name that you are looking for is PSAvoidUsingCmdletAliases, therefore you can retrive it using Get-ScriptAnalyzerRule -Name PSAvoidUsingCmdletAliases
    I don't understand your question about ConfigurableRule type. Can you please elaborate in case this answer has not solved your question please.

  2. LaurentDardenne commented on Dec 4, 2017

    @LaurentDardenne
    Author

    I don't understand your question about ConfigurableRule type.
    Ok.

    1-The AvoidAlias class should they not be inherited from the class ConfigurableRule ?
    2-Today Get-ScriptAnalyzerRule can not filter configurable rules. The documentation says 'Rule' and 'Severity' but not if the rule is configurable.

  3. bergmeister commented on Dec 4, 2017

    @bergmeister
    Collaborator

    Aha, I see now what you mean. Yes, I think you are right that the rule should probably inherit from ConfigurableRule but filtering configurable rules in Get-ScriptAnalyzer sounds more like a new (but useful) feature to me.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions