PowerShell / PowerShell/PSScriptAnalyzer

Automatically split | characters to a new line

Offen
#1,345 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Issue - New Rule
Vorherrschende Sprache
C#
Sterne
2.2k
Forks
414
Ø Merge
13 Std. 1 Min.
Gemergte PRs (30 T.)
2

Beschreibung

Summary of the new feature/enhancement

I should state that I am using VS Code. I was told that for this feature to be possible in VS Code, it has to first be implemented here. The setting I mention down below is a VS Code Powershell setting.

I'd like to the ability to take the following line:

$Ports | ForEach-Object -Process { NETSTAT.EXE -ano | findstr.exe :8080 | ForEach-Object -Process { ($_ -split '\s+')[-1] } | Sort-Object | Get-Unique | ForEach-Object -Process { taskkill.exe /F /PID $_ } }

and convert it to:

$Ports |
    ForEach-Object -Process {
        NETSTAT.EXE -ano |
            findstr.exe :8080 |
            ForEach-Object -Process {
                ($_ -split '\s+')[-1]
            } | Sort-Object |
            Get-Unique |
            ForEach-Object -Process {
                taskkill.exe /F /PID $_
            }
    }

I think this would go a long way in approving readability. At the very least, with the

"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline"

setting enabled, when I manually add the new line after each |, { , and }, it will format the indentation correctly which is nice.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue enthält PowerShell-Beispiele und verweist auf die Einstellung pipelineIndentationStyle in VS Code; ermittle zuerst den vorhandenen Einstiegspunkt für die Pipeline-Formatierung und die zugehörigen Tests in PSScriptAnalyzer. Vergleiche das aktuelle Verhalten mit der angeforderten Aufteilung nach |, { und }, und definiere den Abschluss anhand von Tests, die die gezeigte verschachtelte Pipeline und das Einrückungsverhalten abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
powershell
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.