PowerShell / PowerShell/PSScriptAnalyzer
Disable PSSA or supress all rules for **one** file without excluding path in settings.psd1?
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 414
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
Descripción
- Slack Community Chat: https://powershell.slack.com (you can sign-up at http://slack.poshcode.org/ for an invite)
- Also have a look at the
RoleDocumentationfolder for more information on each rule:
https://github.com/PowerShell/PSScriptAnalyzer/tree/development/RuleDocumentation
^ These links either isn't relevant anymore (first one, it's moved to Discord, right?), or does not work (the two others)
Say I have a script I'm just using for inspiration, I have no plans of iterating and improving it.
We can use [Diagnostics.CodeAnalysis.SuppressMessageAttribute()] to supress one rule. We can not use wildcard ( [Diagnostics.CodeAnalysis.SuppressMessageAttribute('*','')] ) to suppress all rules, I've tried.
Is it possible to disable PSSA or suppress all rules for one script/file, from inside that file? I don't want to hardcode paths in global PSSA settings.
To get PSSA and VSCode "Problems" tab to stay quiet I now have all these in top of the script:
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingConvertToSecureStringWithPlainText','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingInvokeExpression','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Used to output text with color')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseLiteralInitializerForHashtable','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions','')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns','')]
This is with the following Microsoft maintained script btw.:
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza revisando settings.psd1 y el manejo existente de Diagnostics.CodeAnalysis.SuppressMessageAttribute; después, revisa la carpeta RuleDocumentation y el comportamiento informado de VSCode Problems. Se considera terminado cuando un único script puede deshabilitar PSScriptAnalyzer o suprimir todas las reglas desde ese archivo sin añadir su ruta a la configuración global.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- powershell
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100