PowerShell / PowerShell/PSScriptAnalyzer
Rule Idea: Pipeline Type Checking against Output
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
This is just a spitball idea to contribute feedback if it is maybe feasible, I might consider attempting a PR
Problem
Often when writing a pipeline you may pipe an incompatible type, and you won't find out until runtime.
Proposed solution
If the output type of a function can be explicitly determined by:
- Use the .OUTPUT comment based help section to define the output type of a function
- Take all explicit return keywords that explicitly cast to a type e.g.
return [MyType]@{}or can be simply derived from a typed variable e.g.$f = [MyType]::new();return $f
And the function being called either to or from meets the following criteria:
- Has strictly typed non-primitive parameter or ValueFromPipeline
Then we should be able to safely issue a warning or error stating something like "MyFunction expected [MyType] but is receiving [WrongType] via the pipeline" as a static analysis.
#Issues
- Easily castable types like string we have to exclude, they will basically always match
- Probably should support/detect explicit casts or interfaces
Prior Art
How JSDoc can be used to test for type safety in normally-untyped javascript.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue で説明されている出力型の候補ソース、パイプラインパラメータのチェック、キャストの例外、JSDoc の先行事例を確認します。実装前にアナライザーのエントリーポイントとスコープを定義します。完了の条件は、決定したアプローチで互換性のないパイプライン型を検出し、安全にキャスト可能な値を除外しつつ、明示的なキャストまたはインターフェースを処理できることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100