PowerShell / PowerShell/PSScriptAnalyzer
Accept `-Fix` for `-ScriptDefinition`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 2.2k
- Forks
- 414
- Ø Merge
- 13 Std. 1 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Überprüfung des Einstiegspunkts von Invoke-ScriptAnalyzer und seiner aktuellen Verarbeitung von -ScriptDefinition und -Fix. Überprüfe, wie der Befehl derzeit Diagnosen zurückgibt, und definiere anschließend die Abdeckung für die Annahme beider Parameter, die Rückgabe der korrigierten Skriptdefinition und die Bestätigung, dass SuggestedCorrections angewendet werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell
- Bereich
- cli, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100