Unused variable false positive in `ForEach-Object` begin block (`PSUseDeclaredVarsMoreThanAssignments`)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 58/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- powershell, typescript
- Área
- tooling
Línea de trabajo
Comienza reproduciendo el diagnóstico con el ejemplo proporcionado de ForEach-Object en la extensión de PowerShell e inspecciona cómo se gestionan los resultados de PSUseDeclaredVarsMoreThanAssignments. Compara la advertencia con los bloques begin, process y end mostrados en el informe. Se considera terminado cuando el falso positivo ya no se informa, mientras que las advertencias genuinas sobre variables no utilizadas siguen apareciendo.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
Variables initialized in begin block of ForEach-Object trigger PSUseDeclaredVarsMoreThanAssignments warning.
PowerShell Version
Name Value
---- -----
PSVersion 5.1.26100.7705
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.7705
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Name : ConsoleHost
Version : 5.1.26100.7705
InstanceId : 4ed60023-e437-45ae-b589-226f399acc62
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
1.109.5
072586267e68ece9a47aa43f8c108e0dcbf44622
x64
Extension Version
[email protected]
Steps to Reproduce
1, 2, 3 | ForEach-Object { $list = @() } { $list += $_ } { $list }
^^^^^
The variable 'list' is assigned but never used.
PSScriptAnalyzer(PSUseDeclaredVarsMoreThanAssignments)
Returning the $list from the begin block offs the warning
1, 2, 3 | ForEach-Object { $list = @(); $list } { $list += $_ } { $list }
Visuals
No response
Logs
No response
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.9k
- Forks
- 549
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 PowerShell/vscode-powershell
-
[aw] Agentic Issue Triage failedAbiertoagentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
PowerShell/vscode-powershell#5615 · 1 comentario ·
-
agentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
PowerShell/vscode-powershell#5607 ·
-
[aw] Agentic Issue Triage failedAbiertoagentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
PowerShell/vscode-powershell#5599 · 3 comentarios ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PowerShell/vscode-powershell#5592 · 2 comentarios · 1 reacción ·
-
[aw] Agentic Issue Triage failedAbiertoagentic-workflows
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
PowerShell/vscode-powershell#5583 · 1 comentario ·
Todos los issues de PowerShell/vscode-powershell
Issues similares
-
type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
lingdojo/kana-dojo#31593 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
apache/fineract-backoffice-ui#697 ·
Los mantenedores suelen responder en 1 día
-
good first issue hacktoberfest help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
libredb/libredb-studio#1291 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug P1
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Yeachan-Heo/gajae-code#6295 · 1 comentario ·
Los mantenedores suelen responder en 1 día