PowerShell / PowerShell/PSScriptAnalyzer
Accept `-Fix` for `-ScriptDefinition`
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 414
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
Descripción
Summary of the new feature
Currently the -Fix parameter is mutual exclusive with the -ScriptDefinition parameter:
Invoke-ScriptAnalyzer -ScriptDefinition 'GCI *' -Fix
Invoke-ScriptAnalyzer: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot; be used together or an insufficient number of parameters were provided.
Proposed technical implementation details (optional)
When both ( -Fixand -ScriptDefinition) parameters, are supplied, I would expect to get a fixed ScriptDefinition back (instead of a [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]).
This way, it would be easier to (pester) test a rule with SuggestedCorrections.
(You might of cause check the SuggestedCorrections property but that will not confirm it has been correctly inserted in the script.)
Besides it will allow to fix scripts by creating a fixed copy rather than make sure that you have a backup of your files when using this parameter.
Wishful thinking:
Get-Content *.ps1 | Foreach-Object { Invoke-ScriptAnalyzer -ScriptDefinition $_ | Set-Content "Fixed\$($_.Name)" }
What is the latest version of PSScriptAnalyzer at the point of writing
1.21.0
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.
Línea de trabajo
Comienza revisando el punto de entrada de Invoke-ScriptAnalyzer y su gestión actual de -ScriptDefinition y -Fix. Verifica cómo devuelve actualmente el comando los diagnósticos y, a continuación, define la cobertura para aceptar ambos parámetros, devolver la definición del script corregida y confirmar que se aplican las SuggestedCorrections.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- powershell
- Área
- cli, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100