Relax PSScriptAnalyzer rules for tests/ folder
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
調査の方向性
.github/workflows/analysis.yml から開始し、既存の Invoke-ScriptAnalyzer と SARIF のアップロードのステップを確認します。modules/ に対する PSGallery の解析は維持し、列挙された除外を適用した tests/ 用の別のパスを追加して、results.sarif を生成する前に両方の結果セットを結合します。テスト専用のヘルパーに関する警告が除外され、ワークフローが引き続き SARIF をアップロードすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Background
I've bumped into PSScriptAnalyzer / GitHub code-scanning warnings on files in the tests/ folder a couple of times when writing test helpers that start with verbs that (in a public API) have some conventions around then (like New). These rules aren't really applicable to test code. A recent example: a test helper named New-Frame tripped PSUseShouldProcessForStateChangingFunctions because New is an approved state-changing verb, so the analyzer expects the function to support -WhatIf/-Confirm.
These are linter conventions meant for exported, public cmdlets, not for test scaffolding. The tests/ folder isn't part of our public API, so applying the full PSGallery ruleset there generates noise (and a review-bot comment on every PR that adds such a helper).
Where these come from
The warnings are produced by the analysis workflow in .github/workflows/analysis.yml:
```powershell
Invoke-ScriptAnalyzer -Path . -Recurse -Settings PSGallery | ConvertTo-SARIF -FilePath results.sarif
```
The resulting SARIF is uploaded to GitHub code scanning, which is what renders the inline PR comments. GitHub has no per-path mute for third-party SARIF — the only lever is what we feed into the analyzer.
Suggested fix
Run the analyzer in two passes: the full ruleset on modules/, and a relaxed ruleset on tests/ that excludes the rules which are inherently meaningless for test helpers:
```powershell
$results = Invoke-ScriptAnalyzer -Path ./modules -Recurse -Settings PSGallery
$results += Invoke-ScriptAnalyzer -Path ./tests -Recurse -Settings PSGallery -ExcludeRule PSUseShouldProcessForStateChangingFunctions, PSUseApprovedVerbs, PSAvoidUsingWriteHost $results | ConvertTo-SARIF -FilePath results.sarif \``
We can add to the the -ExcludeRule list over time if there are other analyzers that don't make sense for the tests.
Alternatives considered
Neither of these are ideal:
- Drop
tests/from the scan entirely (-Path ./modules): simplest, but loses all linting on tests. - Repo-wide
PSScriptAnalyzerSettings.psd1withExcludeRules: not path-aware, so it would also disable the rule formodules/, where we want it.
Context: came up while reviewing #135.
- 主要言語
- PowerShell
- スター
- 16
- フォーク
- 4
- 平均マージ
- 11時間 24分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-powershell のほかの issue
-
Improvement PowerShell
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
getsentry/sentry-powershell#128 · コメント 2 件 ·
-
Improvement PowerShell
難易度 5/5 1週間以上 初心者へのやさしさ 38/100
getsentry/sentry-powershell#121 · コメント 2 件 ·
-
.NET Improvement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
getsentry/sentry-powershell#38 · コメント 1 件 ·
getsentry/sentry-powershell の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 60/100
EchoTools/nevr-runtime#450 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
NuSkooler/enigma-bbs#907 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
-
python-version
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
initramfs: -type f (#18686) skips the libcurl.so.4 symlink, libcurl no longer copied into initramfsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 2 日以内に返信