PowerShell / PowerShell/PSScriptAnalyzer

Accept `-Fix` for `-ScriptDefinition`

Ouverte
#1,938 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Issue - Enhancement Up-for-Grabs
Langage dominant
C#
Étoiles
2.2k
Forks
414
Merge moyen
13 h 1 min
PR mergées (30 j)
2

Description

Summary of the new feature

Currently the -Fix parameter is mutual exclusive with the -ScriptDefinition parameter:

Invoke-ScriptAnalyzer -ScriptDefinition 'GCI *' -Fix

Invoke-ScriptAnalyzer: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot; be used together or an insufficient number of parameters were provided.

Proposed technical implementation details (optional)

When both ( -Fixand -ScriptDefinition) parameters, are supplied, I would expect to get a fixed ScriptDefinition back (instead of a [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]).
This way, it would be easier to (pester) test a rule with SuggestedCorrections.
(You might of cause check the SuggestedCorrections property but that will not confirm it has been correctly inserted in the script.)
Besides it will allow to fix scripts by creating a fixed copy rather than make sure that you have a backup of your files when using this parameter.

Wishful thinking:

Get-Content *.ps1 | Foreach-Object { Invoke-ScriptAnalyzer -ScriptDefinition $_ | Set-Content "Fixed\$($_.Name)" }

What is the latest version of PSScriptAnalyzer at the point of writing

1.21.0

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par examiner le point d’entrée de Invoke-ScriptAnalyzer et sa gestion actuelle de -ScriptDefinition et -Fix. Vérifiez comment la commande renvoie actuellement les diagnostics, puis définissez la couverture pour accepter les deux paramètres, renvoyer la définition de script corrigée et confirmer que les SuggestedCorrections sont appliquées.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
powershell
Domaine
cli, tooling
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.