mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
Clean up analyzer warnings across app search and ISO workflows (#4794)
* Clean up analyzer warnings * Align analyzer warning cleanup policy * Run PSScriptAnalyzer directly in unittests workflow * Bind lazy-rendered buttons to click handlers * Remove WinUtil performance tracing * Fix Win11 ISO creator temp directory reuse
This commit is contained in:
@@ -27,12 +27,10 @@ function Get-RawJsonBlock {
|
||||
|
||||
$escapedName = [regex]::Escape($ItemName)
|
||||
$startIndex = -1
|
||||
$startIndent = ""
|
||||
|
||||
for ($i = 0; $i -lt $JsonLines.Count; $i++) {
|
||||
if ($JsonLines[$i] -match "^(\s*)`"$escapedName`"\s*:\s*\{") {
|
||||
$startIndex = $i
|
||||
$startIndent = $matches[1]
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -47,7 +45,7 @@ function Get-RawJsonBlock {
|
||||
$depth = 1 # We're starting inside the opening brace
|
||||
for ($i = ($startIndex + 1); $i -lt $JsonLines.Count; $i++) {
|
||||
$line = $JsonLines[$i]
|
||||
|
||||
|
||||
# Count braces in this line, ignoring those in strings
|
||||
$inString = $false
|
||||
$chars = $line.ToCharArray()
|
||||
@@ -59,7 +57,7 @@ function Get-RawJsonBlock {
|
||||
elseif ($chars[$k] -eq '}') { $depth-- }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Found the closing brace of the item
|
||||
if ($depth -eq 0) {
|
||||
$endIndex = $i
|
||||
@@ -173,14 +171,14 @@ function Add-LinkAttributeToJson {
|
||||
|
||||
for ($j = $startIdx + 1; $j -lt $lines.Count; $j++) {
|
||||
$line = $lines[$j]
|
||||
|
||||
|
||||
# Check for existing "link" property at top-level (depth 1 before processing braces on this line)
|
||||
# Match at any indentation level (user may have manually changed indentation)
|
||||
if ($depth -eq 1 -and $line -match '^\s*"link"\s*:') {
|
||||
# Mark this line for removal
|
||||
$linesToRemove += $j
|
||||
}
|
||||
|
||||
|
||||
# Count braces in this line, ignoring those in strings
|
||||
$inString = $false
|
||||
$chars = $line.ToCharArray()
|
||||
@@ -192,7 +190,7 @@ function Add-LinkAttributeToJson {
|
||||
elseif ($chars[$k] -eq '}') { $depth-- }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Found the closing brace of the item
|
||||
if ($depth -eq 0) {
|
||||
$closeBraceIdx = $j
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
function Start-WinUtilPerformanceTrace {
|
||||
if (-not (Test-WinUtilPerformanceTrace) -or $null -eq $sync) {
|
||||
return
|
||||
}
|
||||
|
||||
if (-not $sync.ContainsKey("PerformanceTrace")) {
|
||||
$sync.PerformanceTrace = @{
|
||||
Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
LastElapsedMs = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
Write-WinUtilPerformanceCheckpoint -Name "Startup trace started"
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
function Stop-WinUtilPerformanceTrace {
|
||||
param(
|
||||
[string]$Name = "Startup trace complete"
|
||||
)
|
||||
|
||||
if (-not (Test-WinUtilPerformanceTrace) -or $null -eq $sync -or -not $sync.ContainsKey("PerformanceTrace")) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-WinUtilPerformanceCheckpoint -Name $Name
|
||||
|
||||
if ($null -ne $sync.PerformanceTrace.Stopwatch) {
|
||||
$sync.PerformanceTrace.Stopwatch.Stop()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
function Test-WinUtilPerformanceTrace {
|
||||
$enabledValue = ([string]$env:WINUTIL_PERF_LOG).ToLowerInvariant()
|
||||
if ($enabledValue -in @("1", "true", "yes", "on")) {
|
||||
return $true
|
||||
}
|
||||
|
||||
if ($null -ne $sync -and $sync.ContainsKey("PerformanceTraceEnabled")) {
|
||||
return [bool]$sync.PerformanceTraceEnabled
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
function Write-WinUtilPerformanceCheckpoint {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name
|
||||
)
|
||||
|
||||
if (-not (Test-WinUtilPerformanceTrace) -or $null -eq $sync) {
|
||||
return
|
||||
}
|
||||
|
||||
if (-not $sync.ContainsKey("PerformanceTrace") -or $null -eq $sync.PerformanceTrace.Stopwatch) {
|
||||
$sync.PerformanceTrace = @{
|
||||
Stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
|
||||
LastElapsedMs = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
$elapsedMs = [math]::Round($sync.PerformanceTrace.Stopwatch.Elapsed.TotalMilliseconds, 2)
|
||||
$deltaMs = [math]::Round($elapsedMs - [double]$sync.PerformanceTrace.LastElapsedMs, 2)
|
||||
$sync.PerformanceTrace.LastElapsedMs = $elapsedMs
|
||||
|
||||
Write-WinUtilLog -Level "DEBUG" -Component "StartupPerf" -Message ("{0}: {1:N2} ms (+{2:N2} ms)" -f $Name, $elapsedMs, $deltaMs)
|
||||
}
|
||||
Reference in New Issue
Block a user