PowerShell / PowerShell/PSScriptAnalyzer

Whitespace Between Parameters Is Trimming Required Quotes

Aperta
#1,561 13 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area - Formatter Issue - Bug
Lingua principale
C#
Stelle
2.2k
Fork
414
Merge medio
13h 1m
PR unite (30g)
2

Descrizione

  • ✅ Make sure you are able to repro it on the latest released version
  • ✅ Perform a quick search for existing issues to check if this bug has already been reported.
    • Might be related to #1540

This was one of the more simple examples I could find.
I found this issue popping up in random files and finally realized it was a formatter issue.

Steps to reproduce

Describe "DescribeName" {
    Context "ContextName" {
        It "ItName" {
            Assertion
        }
        It "output: attributes     matches  $($outputs.attributes)" {
            $results.attributes | Should -Be $outputs.attributes
        }
    }
}

Expected behavior

Describe "DescribeName" {
    Context "ContextName" {
        It "ItName" {
            Assertion
        }
        It "output: attributes     matches  $($outputs.attributes)" {
            $results.attributes | Should -Be $outputs.attributes
        }
    }
}

Actual behavior

Describe "DescribeName" {
    Context "ContextName" {
        It "ItName" {
            Assertion
        }
        It "output: attributes     matches  $($outputs.attributes){ <----- it removed valid quote, resulting in breaking syntax
            $results.attributes | Should -Be $outputs.attributes
        }
    }
}

Environment data


> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Darwin 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
1.18.3
1.19.1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il problema del formatter con l'esempio PowerShell presente nell'issue, utilizzando le versioni di PSScriptAnalyzer elencate. Traccia la formattazione della stringa It tra virgolette e aggiungi un test di regressione per lo spazio bianco e la virgoletta richiesti. Il lavoro è completato quando la formattazione preserva la virgoletta di chiusura e il risultato rimane sintassi PowerShell valida.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.