PowerShell / PowerShell/PSScriptAnalyzer
Rule request: `Get-Content x | ConvertFrom-Json` should suggest adding `-raw` for `Get-content`
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
When you call get-content file.json | convertfrom-json, funny things happen when file.json contains a comment at the top of the file.
Multiple places suggest that it's better to use get-content -raw for performance and predictability.
See:
- https://github.com/PowerShell/PowerShell/issues/12229
- https://stackoverflow.com/questions/71025659/set-property-value-on-object-loaded-from-json-containing-comments
Proposed technical implementation details (optional)
When get-content is piped to convertfrom-*, PSScriptAnalyzer should suggest adding -raw to get-content.
The same could apply to [xml] get-content file.xml.
What is the latest version of PSScriptAnalyzer at the point of writing
1.21
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
Keine Quelldatei oder kein Test ist genannt. Beginne damit, die bestehenden PSScriptAnalyzer-Regeln für Get-Content, das an ConvertFrom-* weitergeleitet wird, und das verknüpfte PowerShell-Issue zu prüfen; bestimme die vorgesehene Behandlung von JSON-Kommentaren und den möglichen XML-Fall. Als erledigt gilt, dass der Analyzer, wo angemessen, konsistent -Raw vorschlägt und das Verhalten durch Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- devtools, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100