PowerShell / PowerShell/PSScriptAnalyzer
Transient RULE_ERROR
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
I wish I could provide more information, but the error is transient and therefore cannot be deterministically reproed.
PowerShell version: 6.2.1
PSScriptAnalyzer version: 1.18.3
OS Version: Ubuntu 1604
PSScriptAnalyzer is failing occasionally with the following error:
Invoke-ScriptAnalyzer : Object reference not set to an instance of an object.
At /source/.build/Assert-ValidStyle.ps1:21 char:11
+ $issues = Invoke-ScriptAnalyzer -Path "$PSScriptRoot\.." -Recurse
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (/source/.build/powershell-helpers.psm1:String) [Invoke-ScriptAnalyzer], NullReferenceException
+ FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
Contents of powershell-helpers.psm1:
# execute a command block and display stderr output without throwing powershell exceptions
# Taken from https://mnaoumov.wordpress.com/2015/01/11/execution-of-external-commands-in-powershell-done-right
function Invoke-Script {
[CmdletBinding()]
[Alias('exec')]
param
(
[ScriptBlock] $ScriptBlock,
[string] $StderrPrefix = "",
[int[]] $AllowedExitCodes = @(0)
)
$backupErrorActionPreference = $script:ErrorActionPreference
$script:ErrorActionPreference = "Continue"
try {
& $ScriptBlock *>&1 | ForEach-Object -Process `
{
if ($_ -is [System.Management.Automation.ErrorRecord]) {
"$StderrPrefix$_"
}
else {
"$_"
}
}
if ($AllowedExitCodes -notcontains $LASTEXITCODE) {
throw "Execution failed with exit code $LASTEXITCODE"
}
}
finally {
$script:ErrorActionPreference = $backupErrorActionPreference
}
}
function Get-File {
param(
[string]$Uri,
[string]$Path,
[string]$Hash
)
New-Item -ItemType Directory -Path (Split-Path $path -Parent) -Force | Out-Null
Invoke-WebRequest -Uri $uri -OutFile $path
$actual = Get-FileHash -Path $path -Algorithm SHA256 | Select-Object -ExpandProperty Hash
if ($actual -ne $hash) {
throw "File $path with hash $actual doesn't match expected hash $hash"
}
}
function Invoke-InDirectory {
Param(
[ValidateScript( { Test-Path $_ -PathType Container } )]
[string]$Path,
[ValidateNotNullOrEmpty()]
[scriptblock]$ScriptBlock
)
Push-Location $Path
try {
&$ScriptBlock
}
finally {
Pop-Location
}
}
Export-ModuleMember -Alias * -Function *
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da .build/Assert-ValidStyle.ps1 e dalla chiamata a Invoke-ScriptAnalyzer, quindi esamina powershell-helpers.psm1 e il contesto RULE_ERROR segnalato. Prova a eseguire il comando sul repository con PowerShell 6.2.1 e PSScriptAnalyzer 1.18.3; il lavoro è completato quando il fallimento intermittente dovuto a un riferimento nullo è stato identificato e prevenuto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100