PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.87k stars 378 forks source link

`Get-ScriptAnalyzerRule` default list view shows no value for property "Name" #2010

Closed o-l-a-v closed 4 months ago

o-l-a-v commented 4 months ago

Before submitting a bug report:

Steps to reproduce

Get-ScriptAnalyzerRule -Name 'PSUseCorrectCasing' | Format-List

Expected behavior

PS > Get-ScriptAnalyzerRule -Name 'PSUseCorrectCasing' | Format-List

Name        : PSUseCorrectCasing
Severity    : Information
Description : For better readability and consistency, use the exact casing of the cmdlet/function/parameter.
SourceName  : PS

PS >

Actual behavior

PS > Get-ScriptAnalyzerRule -Name 'PSUseCorrectCasing' | Format-List

Name        : 
Severity    : Information
Description : For better readability and consistency, use the exact casing of the cmdlet/function/parameter.
SourceName  : PS

PS >

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.3
PSEdition                      Core
GitCommitId                    7.4.3
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0ร”ร‡ยช}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.22.0
1.22.0

If selecting all properties with format list:

PS > Get-ScriptAnalyzerRule -Name 'PSUseCorrectCasing' | Format-List -Property '*'

RuleName         : PSUseCorrectCasing
CommonName       : Use exact casing of cmdlet/function/parameter name.
Description      : For better readability and consistency, use the exact casing of the cmdlet/function/parameter.
SourceType       : Builtin
SourceName       : PS
Severity         : Information
ImplementingType : Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.UseCorrectCasing

PS >
liamjpeters commented 4 months ago

Hey @o-l-a-v ๐Ÿ‘‹,

This looks to be an issue with the format file definition, which outlines the default type definition of RuleInfo. It is referencing a Name property - which does not exist on the type.

https://github.com/PowerShell/PSScriptAnalyzer/blob/ae898e7662eae1d40611ffae959f680fb5793b9e/Engine/ScriptAnalyzer.types.ps1xml#L73-L91

I've put together a PR to update this to RuleName. This results in the below:

image

Thanks for flagging this! ๐Ÿ™‚