PowerShell / PowerShell/PSScriptAnalyzer
Use proper output streams for messages output by PSScriptAnalyzer
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 414
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
This issue is a great example of why issue #193 should be approved and implemented.
Today if you run Invoke-ScriptAnalyzer on a moderate sized module recursively with the -Verbose switch, you get 38 verbose output messages per file in your module. For one of my modules that has 58 files (I put each function in its own file if the module is only small-to-medium in size), this results in 2204 verbose messages being sent to the console. These 2204 verbose messages are nothing but noise to me.
For each of the files that are processed, I get one verbose message that indicates a file is being analyzed and then I get 37 messages (one for each rule, so that will only grow over time) indicating that a rule is being processed for that file. Those should be progress messages, not verbose messages, and so they should be output using WriteProgress, not WriteVerbose. Verbose should be reserved for non-progress messages that provide some additional detail about what is happening behind the scenes -- some small amount of information that would be useful for the invoker to know if they want the additional detail, but that they don't see regularly. This is exactly why the PSProvideVerboseMessage rule needs to go away -- it encourages users to wrongly add verbose message output where there shouldn't be any.
The reason why I invoked Invoke-ScriptAnalyzer with -Verbose in the first place is because I wanted to see if it was writing a verbose message to the output stream when a rule is found but suppressed. It is not doing this, but that is a great example of the kind of output I would expect to be in a verbose stream for this command. This verbose output would not be noise, because it includes additional detail that is not visible by default (and rightly so) that would add value to a caller trying to figure out why a particular rule is not showing up in certain scenarios. This verbose output would also be highly useful to the community because it would allow them to catch scripts and/or modules that were a little too "suppress-happy", in which case they could inform the author about the error in their ways.
In summary, Invoke-ScriptAnalyzer should:
a) convert the current WriteVerbose calls that output what are really progress messages to the verbose stream to WriteProgress calls (this will also help wrt performance, so that end users see the progress as it is happening)
b) add WriteVerbose calls that output verbose messages indicating when a rule is suppressed, identifying the rule that is suppressed, the line/file where it would have been raised, and ideally the line/file where the attribute to suppress that rule was defined (the source of the suppression).
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Invoke-ScriptAnalyzer 開始,找出目前用於檔案和規則處理的 WriteVerbose 呼叫。檢視進度串流和 verbose 串流的處理方式,然後根據 issue 中所述的條件,確認要求的進度輸出和抑制細節。描述中沒有指定檔案或測試,因此找出相關的實作位置和測試位置也是工作的一部分。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp, powershell
- 領域
- cli, tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100