PowerShell / PowerShell/PSScriptAnalyzer

Warn when partial enumeration values are used

Aperta
#600 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

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).

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

Usa l'esempio gsv blah -ea ig come comportamento da analizzare e individua la regola PSScriptAnalyzer esistente e la struttura dei test per avvisi comparabili. Il lavoro è completato quando uno script che usa un valore di enumerazione parziale non ambiguo produce un avviso, mentre i valori completi continuano a essere accettati.

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

Valutazione

Stack tecnologico
csharp, powershell
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.