PowerShell / PowerShell/PSScriptAnalyzer
Warn when partial enumeration values are used
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
Here's a little known feature that could come back to bite someone later with a broken script:
gsv blah -ea ig
I'm not sure in which version of PowerShell this was added, but you can now use partial enumeration values and as long as that partial value leads to an unambiguous match, it will be accepted.
This may result in errors in scripts that appear to be working correctly if a new emumeration value is added with the same leading characters as those that are in use within a script. It's the same issue/risk with using partial parameter names in scripts. Shorthand should be for ad-hoc use only, and PSScriptAnalyzer should have a rule that warns whenever an enumeration value is used in a script in shorthand (such as in the command above).
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
Verwende das Beispiel gsv blah -ea ig als zu untersuchendes Verhalten und finde die vorhandene PSScriptAnalyzer-Regel sowie die Teststruktur für vergleichbare Warnungen. Als erledigt gilt die Aufgabe, wenn ein Skript, das einen eindeutigen partiellen Enumerationswert verwendet, eine Warnung erzeugt, während vollständige Werte weiterhin akzeptiert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100