Counter ASIC 3.0 PC 1 AMD: the family script's probe parameter renamed (the automatic unbound-arguments variable shadowed it, so nothing was splatted); the CI check gains the rule
This commit is contained in:
parent
fcb9ab1198
commit
020ea6b3e3
2 changed files with 9 additions and 3 deletions
|
|
@ -65,10 +65,11 @@ $byOrdinal = @($extra | Where-Object { -not ($_.name -match 'gfx1201' -and $_.dr
|
|||
"RESULT devices by_name=gfx1201 (newest driver $newest, $gfx1201Count gfx1201 entries) then by_ordinal=[$(($byOrdinal | ForEach-Object { "[$($_.idx)] $($_.name) on $($_.platform) driver $($_.driver)" }) -join ' ; ')]"
|
||||
|
||||
$runs = 0; $exactRows = 0; $rowsTotal = 0; $built = 0; $failedBuilds = 0; $probeErrors = 0; $mainRows = 0
|
||||
function RunProbe([string] $label, [string[]] $args, [int] $r) {
|
||||
"RESULT run=$r dev=$label start $(Stamp) args=[$($args -join ' ')] card_state=$cardState"
|
||||
function RunProbe([string] $label, [string[]] $probeArgs, [int] $r) {
|
||||
# never name a parameter after the automatic variable for unbound arguments: a splat of it is then empty (run b, 17:10Z)
|
||||
"RESULT run=$r dev=$label start $(Stamp) args=[$($probeArgs -join ' ')] card_state=$cardState"
|
||||
$t0 = Get-Date
|
||||
$lines = @(& $probe @args --reps 3 2>&1 | ForEach-Object { "$_" })
|
||||
$lines = @(& $probe @probeArgs --reps 3 2>&1 | ForEach-Object { "$_" })
|
||||
$rc = $LASTEXITCODE
|
||||
foreach ($l in $lines) {
|
||||
if ($l -match '^RESULT ') { "RESULT run=$r dev=$label $($l.Substring(7))" } else { "RESULT run=$r dev=$label text $l" }
|
||||
|
|
|
|||
|
|
@ -13,9 +13,14 @@ files = subprocess.check_output(['git', 'ls-files', '*.ps1', '**/*.ps1'], text=T
|
|||
ok_names = {'env', 'Env', 'ENV', 'script', 'global', 'local', 'private', 'using', 'function', 'variable', 'alias'}
|
||||
pat = re.compile(r'(?<!`)\$([A-Za-z_][A-Za-z0-9_]*):(?![\\/:])') # a backtick-escaped `$ is a literal dollar (here-strings that generate bash)
|
||||
fail = 0
|
||||
# rule 2 (6 October 2026, family run b): a declared parameter named $args is shadowed by PowerShell's automatic $args
|
||||
# (the unbound arguments), so a splat of it inside the function is empty
|
||||
sig = re.compile(r'(?:^|\s)(?:function\s+\S+\s*\(|param\s*\()[^)]*\$args\b', re.I)
|
||||
for f in sorted(set(files)):
|
||||
for n, line in enumerate(open(f, encoding='utf-8', errors='replace'), 1):
|
||||
if line.lstrip().startswith('#'): continue
|
||||
if sig.search(line):
|
||||
print(f'ps-params: {f}:{n}: a parameter named $args is shadowed by the automatic $args; rename it'); fail = 1
|
||||
for seg in re.findall(r'"(?:[^"\\]|\\.|`")*"', line):
|
||||
for m in pat.finditer(seg):
|
||||
if m.group(1) in ok_names: continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue