Relax PSScriptAnalyzer rules for tests/ folder
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 84/100
Línea de trabajo
Comienza en .github/workflows/analysis.yml e inspecciona los pasos existentes de Invoke-ScriptAnalyzer y de carga de SARIF. Mantén el análisis de PSGallery para modules/, añade una ejecución independiente para tests/ con las exclusiones indicadas y combina ambos conjuntos de resultados antes de generar results.sarif. Se considera completado cuando el workflow sigue cargando SARIF y se excluyen las advertencias de los helpers que solo se usan en las pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PowerShell
- Estrellas
- 16
- Forks
- 4
- Merge medio
- 11 h 24 min
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de getsentry/sentry-powershell
-
Improvement PowerShell
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
getsentry/sentry-powershell#128 · 2 comentarios ·
-
Improvement PowerShell
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
getsentry/sentry-powershell#121 · 2 comentarios ·
-
Automatic flush on exitAbierto.NET Improvement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
getsentry/sentry-powershell#38 · 1 comentario ·
Todos los issues de getsentry/sentry-powershell
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
kubernetes-sigs/headlamp#7950 ·
Los mantenedores suelen responder en 3 días
-
kind/bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
kubernetes-sigs/vsphere-csi-driver#4351 ·
Los mantenedores suelen responder en 1 día
-
component/gpu-kubelet-plugin component/helm needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
kubernetes-sigs/dra-driver-nvidia-gpu#1559 ·
Los mantenedores suelen responder en 1 día
-
OSCI'26
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
GauravKarakoti/SecureFlow#1301 ·
Los mantenedores suelen responder en 1 día