microsoft / PSRule

Validate infrastructure as code (IaC) and objects using PowerShell rules.
https://microsoft.github.io/PSRule/v2/
MIT License
395 stars 49 forks source link

Rule without a synopsis defined gets synopsis from rule above #214

Closed LaurentDardenne closed 5 years ago

LaurentDardenne commented 5 years ago

The 'keyword' Synopsis is not documented and the alias 'Description' is also a property of a PSRule instance. We have twice the same information.

And the last statement of this 'keyword' is duplicated on the rules that does not specify this 'keyword'.

$Path='C:\temp'
$File='Main.Rule.ps1'
@'
Write-warning "call Main"
# Synopsis: Test -dependsOn
Rule Test -dependsOn 'TestModule/Test.Rule.ps1/M1.Rule2' {
    Write-warning $Rule.RuleName
    $true
}

# No description
Rule Test2 -dependsOn 'MyModule/Test.Rule.ps1/M3.Rule0' {
    Write-warning $Rule.RuleName
    $true
}

# No description
Rule Test3 -dependsOn 'MyModule/Test.Rule.ps1/M3.Rule0' {
    Write-warning $Rule.RuleName
    $true
}
'@ > "$Path\$File"

get-psrule -path "$Path\$File" |Select-Object RuleName,Synopsis
# AVERTISSEMENT : call Main
# RuleName Synopsis
# -------- --------
# Test     Test -dependsOn
# Test2    Test -dependsOn
# Test3    Test -dependsOn

To define 'Synopsis' as a keyword would allow to declare this information in the body of the rule and not outside as a comment. This would also allow to find all the information via the AST. Or to declare on the keyword 'Rule' a parameter 'Synopsis' with an alias 'Description'.

LaurentDardenne commented 5 years ago

The 'keyword' Synopsis is not documented and the alias 'Description' is also a property of a PSRule instance. We have twice the same information.

I just read the change log for version 0.6

BernieWhite commented 5 years ago

@LaurentDardenne Thanks. Yes so Synopsis: is the preferred usage going forward so that it aligns to rule help.

Capturing a synopsis from a rule above is a bug.