PowerShell / PowerShell/PSScriptAnalyzer

Indentation inconsistent when using more than 1 line continuation

Ouverte
#1,184 4 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

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

Description

Before submitting a bug report:

  • 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

Steps to reproduce

Execute the following script & compare the formatted output to the input (as defined by the variable $scriptDefinition)

$scriptDefinition = @'
$all_links = `
    [array](Get-ChildItem -Path ([Environment]::GetFolderPath('StartMenu')) -Recurse -Include '*.lnk') + `
    (Get-ChildItem -Path ([Environment]::GetFolderPath('CommonStartMenu')) -Recurse -Include '*.lnk')
'@

Invoke-Formatter -ScriptDefinition $scriptDefinition

Expected behavior

The output of the call to Invoke-Formatter should be the same as the input.

Actual behavior

The third line of the output is not indented to the same level as the second line - the output of Invoke-Formatter is as shown below.

$all_links = `
    [array](Get-ChildItem -Path ([Environment]::GetFolderPath('StartMenu')) -Recurse -Include '*.lnk') + `
(Get-ChildItem -Path ([Environment]::GetFolderPath('CommonStartMenu')) -Recurse -Include '*.lnk')

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.18356.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18356.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.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 exécuter le script PowerShell fourni via Invoke-Formatter avec PSScriptAnalyzer 1.18.0 et vérifiez comment plusieurs continuations avec backtick sont indentées. Le travail est terminé lorsque la troisième ligne est indentée au même niveau que la deuxième et que la sortie formatée correspond à l’entrée.

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

Évaluation

Stack technique
powershell
Domaine
tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

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