PowerShell / PowerShell/PSScriptAnalyzer
Use proper output streams for messages output by PSScriptAnalyzer
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 2.2k
- Forks
- 414
- Merge moyen
- 13 h 1 min
- PR mergées (30 j)
- 2
Description
This issue is a great example of why issue #193 should be approved and implemented.
Today if you run Invoke-ScriptAnalyzer on a moderate sized module recursively with the -Verbose switch, you get 38 verbose output messages per file in your module. For one of my modules that has 58 files (I put each function in its own file if the module is only small-to-medium in size), this results in 2204 verbose messages being sent to the console. These 2204 verbose messages are nothing but noise to me.
For each of the files that are processed, I get one verbose message that indicates a file is being analyzed and then I get 37 messages (one for each rule, so that will only grow over time) indicating that a rule is being processed for that file. Those should be progress messages, not verbose messages, and so they should be output using WriteProgress, not WriteVerbose. Verbose should be reserved for non-progress messages that provide some additional detail about what is happening behind the scenes -- some small amount of information that would be useful for the invoker to know if they want the additional detail, but that they don't see regularly. This is exactly why the PSProvideVerboseMessage rule needs to go away -- it encourages users to wrongly add verbose message output where there shouldn't be any.
The reason why I invoked Invoke-ScriptAnalyzer with -Verbose in the first place is because I wanted to see if it was writing a verbose message to the output stream when a rule is found but suppressed. It is not doing this, but that is a great example of the kind of output I would expect to be in a verbose stream for this command. This verbose output would not be noise, because it includes additional detail that is not visible by default (and rightly so) that would add value to a caller trying to figure out why a particular rule is not showing up in certain scenarios. This verbose output would also be highly useful to the community because it would allow them to catch scripts and/or modules that were a little too "suppress-happy", in which case they could inform the author about the error in their ways.
In summary, Invoke-ScriptAnalyzer should:
a) convert the current WriteVerbose calls that output what are really progress messages to the verbose stream to WriteProgress calls (this will also help wrt performance, so that end users see the progress as it is happening)
b) add WriteVerbose calls that output verbose messages indicating when a rule is suppressed, identifying the rule that is suppressed, the line/file where it would have been raised, and ideally the line/file where the attribute to suppress that rule was defined (the source of the suppression).
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par Invoke-ScriptAnalyzer et localisez les appels actuels à WriteVerbose pour le traitement des fichiers et des règles. Examinez la manière dont les flux de progression et verbose sont gérés, puis vérifiez la sortie de progression demandée et les détails de suppression au regard des critères énoncés dans l'issue. La description ne nomme aucun fichier ni test ; l'identification des emplacements pertinents de l'implémentation et des tests fait donc partie du travail.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, 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
- 35/100