PowerShell / PowerShell/PSScriptAnalyzer
PSUseConsistentWhitespace - Ability to ignore if in a line with multiple pipes
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
The various PSUseConsistentWhitespace rules have various issues that might never be solved:
My biggest issue is that I don't want it to touch one liners or multiliners like this:
(
(
Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = {[System.Version]$_}} -Descending | Select-Object -First 1
Which becomes this:
(
(
Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = { [System.Version]$_ } } -Descending | Select-Object -First 1
If I could tell PSScriptAnalyzer to ignore cases like that I'd be happy.
Current impact
This makes it so that I don't use the code formatting presets, and instead define all the rules manually and disable most of the PSUseConsistentWhitespace rules.
Side note: Would be great with the ability to override built-in presets, so you don't have to specify all the rules.
- 2017-03-07 "Add ability to inherit settings": https://github.com/PowerShell/PSScriptAnalyzer/issues/791
- 2024-12-01 "Code formatting preset - Add ability to override settings set by preset": https://github.com/PowerShell/vscode-powershell/issues/5109
Proposed technical implementation details (optional)
Don't know. Some ideas:
- Ability to ignore if more than one pipe `| is found on the same line?
What is the latest version of PSScriptAnalyzer at the point of writing
v1.24.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
Überprüfe die aktuellen PSUseConsistentWhitespace-Regeln und die verknüpften offenen Issues, um zu verstehen, wie Whitespace über Pipelines hinweg angewendet wird. Definiere das genaue Verhalten für Zeilen, die mehrere Pipes enthalten, und verifiziere anschließend, dass das vorgeschlagene Ignore-Verhalten die bestehenden Formatierungsprüfungen beibehält, ohne andere Fälle zu beeinflussen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- devtools, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100