PSAvoidOverwritingBuiltInCmdlets (core-6.1.0-*) returns warning for Write-Log, which is not a built-in cmdlet
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- powershell
- Área
- tooling
Línea de trabajo
Comienza con los archivos de configuración de plataforma de core-6.1.0 en Engine/Settings, especialmente con las entradas relacionadas con Write-Log, y compara las listas de cmdlets integrados en Linux ARM, Linux, macOS y Windows. Elimina o corrige las entradas que no se distribuyen con PowerShell y, después, ejecuta Invoke-ScriptAnalyzer contra la reproducción de Write-Log.psm1 y comprueba si existen advertencias falsas similares.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
Create a file called Write-Log.psm1 in your home directory and populate it with an empty function called Write-Log:
function Write-Log {
}
Install and run PSScriptAnalyzer against the file:
> Install-Module PSScriptAnalyzer
> Invoke-ScriptAnalyzer -Path ~\Write-Log.psm1
Expected behavior
PSScriptAnalyzer returns no findings because Write-Log is not a built-in cmdlet.
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidOverwritingBuiltInCmdlets Warning Write-Log.psm1 1 'Write-Log' is a cmdlet that is included with PowerShell (version core-6.1.0-windows) whose definition should not be overridden
This behaviour should be reproducible cross-platform.
Troubleshooting
Write-Log was never shipped with any version of PowerShell, but it is erroneously defined as a built-in cmdlet:
Probable cause is described in https://github.com/PowerShell/PowerShell/issues/7209 as an upstream issue in PSDesiredStateConfiguration that was reportedly fixed in 2020. However, the PSScriptAnalyzer files affected by that issue were never rebuilt afterwards.
The module that may have caused this problem at the time is https://github.com/microsoft/PowerShellForGitHub, which defines Write-Log and then suppresses PSScriptAnalyzer reports in Helper.ps1#L128. The PR to suppress that finding is recorded in https://github.com/microsoft/PowerShellForGitHub/pull/180. If this module was present in the build environment, then PSScriptAnalyzer would have added Write-Log and possibly other cmdlets to the list of built-in cmdlets even though they do not ship with PowerShell.
As a result, default installations of PSScriptAnalyzer return a false warning for PSAvoidOverwritingBuiltInCmdlets against cmdlets named Write-Log.
It is possible that there may be other cmdlets erroneously included in these files for the same reason.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.24.0
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 415
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
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.
Más de PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 comentario ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Todos los issues de PowerShell/PSScriptAnalyzer
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
sillsdev/languageforge-lexbox#2665 ·
-
[C#] Another Parens Edge-Case AbiertoC: Syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
bug documentation frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
azurenoops/spin_agent#975 ·
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SubtitleEdit/subtitleedit#15108 · 1 comentario ·