PowerShell / PowerShell/PSScriptAnalyzer
PSUseOutputTypeCorrectly complains "... type is not declared in the OutputType attribute" even though it is
オープン
まだ誰も着手していません。
Area - Rules
Issue - Bug
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Steps to reproduce
PSScriptAnalyzer is complaining about a missing OutputType attribute, even though I did set it correctly.
See PSScriptAnalyzer CI comment under my commits: https://github.com/jantari/LSUClient/commit/a6c2fcc1622aa221d0be73debb4a97baea7b36b5
Easiest way to reproduce is test with my exact file:
mkdir test-pssa
curl.exe "https://raw.githubusercontent.com/jantari/LSUClient/develop/public/Install-LSUpdate.ps1" -o .\test-pssa\Install-LSUpdate.ps1
Import-Module PSScriptAnalyzer -RequiredVersion 1.20.0 # Latest
Invoke-ScriptAnalyzer -Path .\test-pssa -ExcludeRule PSAvoidTrailingWhitespace -Recurse -Verbose
Expected behavior
PSScriptAnalyzer should have no complaints.
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseOutputTypeCorrectly Information Install-LS 93 The cmdlet 'Install-LSUpdate' returns an object of type
Update.ps1 'PackageInstallResult' but this type is not declared in the
OutputType attribute.
PSUseOutputTypeCorrectly Information Install-LS 125 The cmdlet 'Install-LSUpdate' returns an object of type
Update.ps1 'PackageInstallResult' but this type is not declared in the
OutputType attribute.
Environment data
Issue is reproducible under both:
> $PSVersionTable
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.22538
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.20.0
1.19.1
and:
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22538.1000
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22538.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
1.20.0
1.19.1
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンクされた再現手順の Install-LSUpdate.ps1 と、PSScriptAnalyzer 1.20.0 を使用する Invoke-ScriptAnalyzer でレポートを再現します。PSUseOutputTypeCorrectly ルールを調査し、推論された PackageInstallResult の出力と宣言された OutputType を比較します。93 行目と 125 行目の誤検出の診断が表示されなくなり、有効な警告が引き続き検出されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100