PowerShell / PowerShell/PSScriptAnalyzer

Warn on syntax that will cause comment-based help to fail to be discovered/usable

Abierto
#500 8 comentarios 1 reacción 1 asignado Ver en GitHub

@kapilmb ya está trabajando en esto.

Desde el 23/4/2016.

Issue - Discussion Issue - New Rule Up-for-Grabs
Lenguaje dominante
C#
Estrellas
2.2k
Forks
414
Merge medio
13 h 1 min
PR fusionados (30 d)
2

Descripción

Related to this item on UserVoice:
https://windowsserver.uservoice.com/forums/295047-general-feedback/suggestions/13383489-show-syntax-errors-in-powershell-comment-based-hel

Today comment-based help is very fragile, and there are multiple ways you can do something with it that will cause the help to fail to load in PowerShell. PowerShell would do well to report a warning when such a failure is discovered, but that change would only happen in PSvLatest, while a PSScriptAnalyzer rule would resolve this for PSv3+, so I'd like to see this improved with a new rule in PSScriptAnalyzer.

Here are the issues I have noticed people mention so far:

Invalid (mispelled, incorrect) comment-based help keywords.
e.g. The incorrect
.DESCIPRITION
vs the correct
.DESCRIPTION
Note for this issue, that includes starting a line with a period, such as ".NET Framework". The parsing logic should split on lines that start with period and warn if any line keywords don't match up with what is in the comment-based help keyword list.

Incorrect placement of comment-based help keyword values.
e.g. The incorrect
.PARAMETER
<parameter_name>
vs. the correct
.PARAMETER <parameter_name>
The parsing logic should verify the syntax for each keyword.

Spaces between comment-based help and a function, when placing it outside of a function.
e.g. The incorrect
<#
.SYNOPSIS
whatever

>

function Test-CommentBasedHelp {}
vs the correct
<#
.SYNOPSIS
whatever

>

function Test-CommentBasedHelp {}
(NOTE: I'm reporting this one because I saw others mention it but I could not reproduce it using 5.0.10586.122, so maybe this applies only to earlier versions of PowerShell? Some testing is required to nail this one down -- see the discussion point below)

These are only a few examples. I think it would be good to mark this as Discussion and then let others share specific issues they have run into with comment-based help, and then address them with a rule in PSScriptAnalyzer that watches script authors' backs in this area.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.