-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: clear all 27 SonarCloud findings and unblock the Julia analysis-config step #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6fbbce0
1ff1826
06ef568
fc215ab
5bbe143
2faf5f4
2f77c09
fe2b18d
8ce54d2
ba546fe
47a643f
831cb21
987065e
002ae1b
4164ad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,8 @@ | |
| // gate (per the infrastructure prompt; gating is a later-prompt | ||
| // decision). | ||
|
|
||
| import { readFileSync, writeFileSync, mkdirSync } from 'node:fs' | ||
| import { dirname } from 'node:path' | ||
| import { execSync } from 'node:child_process' | ||
| import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync } from 'node:fs' | ||
| import { dirname, join, resolve, isAbsolute } from 'node:path' | ||
| import { applyColourOverrides } from '../src/api/figureColours' | ||
|
|
||
| const REPS = 5 | ||
|
|
@@ -202,10 +201,88 @@ function wTreeRendering(iters: number): BenchmarkResult { | |
|
|
||
| // --------------------------------------------------------------------------- | ||
|
|
||
| /** Walk up from `startDir` for the nearest `.git`; '' when there is none. */ | ||
| function findGitPath(startDir: string): string { | ||
| // Walk up for the checkout root rather than trusting cwd: the harness is run | ||
| // from frontend/ by `just bench` and from the repo root by CI. | ||
| let dir = startDir | ||
| for (;;) { | ||
| const candidate = join(dir, '.git') | ||
| if (existsSync(candidate)) return candidate | ||
| const parent = dirname(dir) | ||
| if (parent === dir) return '' | ||
| dir = parent | ||
| } | ||
| } | ||
|
|
||
| /** A linked worktree's `.git` is a FILE: "gitdir: /abs/or/rel/path". */ | ||
| function resolveGitDir(gitPath: string): string { | ||
| if (!statSync(gitPath).isFile()) return gitPath | ||
| const pointer = readFileSync(gitPath, 'utf8').trim() | ||
| if (!pointer.startsWith('gitdir:')) return '' | ||
| const target = pointer.slice('gitdir:'.length).trim() | ||
| return isAbsolute(target) ? target : resolve(dirname(gitPath), target) | ||
| } | ||
|
|
||
| /** Refs of a linked worktree live in the common dir, not beside its own HEAD. */ | ||
| function resolveCommonDir(gitDir: string): string { | ||
| const commonFile = join(gitDir, 'commondir') | ||
| if (!existsSync(commonFile)) return gitDir | ||
| const rel = readFileSync(commonFile, 'utf8').trim() | ||
| return isAbsolute(rel) ? rel : resolve(gitDir, rel) | ||
| } | ||
|
|
||
| /** Resolve a ref name to its sha: the loose file first, then `packed-refs`. */ | ||
| function resolveRef(commonDir: string, ref: string): string { | ||
| const loose = join(commonDir, ref) | ||
| if (existsSync(loose)) return readFileSync(loose, 'utf8').trim() | ||
|
|
||
| // Fresh clones pack their refs, so the loose file may simply not exist. | ||
| const packed = join(commonDir, 'packed-refs') | ||
| if (!existsSync(packed)) return 'unknown' | ||
|
Comment on lines
+241
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '180,310p' frontend/bench/index.ts
rg -n 'environment\(|\\.commit|commit:' frontend/bench frontend --glob '!frontend/bench/index.ts'Repository: hyperpolymath/MetaManifold-WebUI Length of output: 5833 🏁 Script executed: #!/bin/bash
printf '%s\n' '--- environment definitions and consumers ---'
rg -n -C 3 'environment\(\)|environment:|\.environment\b|commit\b' frontend/bench frontend README.md package.json justfile .github 2>/dev/null | head -n 260
printf '%s\n' '--- benchmark and repository-storage contract terms ---'
rg -n -i -C 3 'bench|benchmark|git|reftable|refStorage|repository|checkout|clone' frontend/bench README.md package.json justfile .github 2>/dev/null | head -n 320
printf '%s\n' '--- concise history metadata for the reviewed file ---'
git log --oneline -8 -- frontend/bench/index.ts 2>/dev/null
git status --shortRepository: hyperpolymath/MetaManifold-WebUI Length of output: 37318 🏁 Script executed: #!/bin/bash
printf '%s\n' '--- former and current commit-resolution changes ---'
git show --format=fuller --stat --oneline fe2b18d -- frontend/bench/index.ts
git show --format= --no-ext-diff fe2b18d -- frontend/bench/index.ts | sed -n '1,220p'
printf '%s\n' '--- helper split context ---'
git show --format= --no-ext-diff 831cb21 -- frontend/bench/index.ts | sed -n '1,240p'
printf '%s\n' '--- exact benchmark contract and JSON-output paths ---'
sed -n '1,40p' frontend/bench/manifest.a2ml
sed -n '330,365p' frontend/bench/index.ts
sed -n '530,545p' README.md
sed -n '330,348p' .github/workflows/ci.ymlRepository: hyperpolymath/MetaManifold-WebUI Length of output: 14924 Handle or explicitly exclude reftable repositories. When 🤖 Prompt for AI Agents |
||
| for (const line of readFileSync(packed, 'utf8').split('\n')) { | ||
| if (line.startsWith('#') || line.startsWith('^')) continue | ||
| const [sha, name] = line.trim().split(' ') | ||
| if (name === ref && sha) return sha | ||
| } | ||
| return 'unknown' | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the checkout's HEAD commit by reading git's own files. | ||
| * | ||
| * This used to shell out to `git rev-parse --short HEAD`. That resolved the | ||
| * `git` binary through PATH, so whatever `git` happened to be first on PATH ran | ||
| * with this process's privileges -- and a benchmark harness has no need of a | ||
| * subprocess at all. Reading the plaintext files git already maintains is both | ||
| * safer and faster, and it works with no git installed. | ||
| * | ||
| * The four shapes HEAD can take -- a detached SHA, a symbolic ref to a loose | ||
| * ref file, a symbolic ref that is only in `packed-refs`, and a linked worktree | ||
| * -- are handled by the four helpers above. They were inlined here until | ||
| * SonarCloud measured this function's cognitive complexity at 26 against a | ||
| * limit of 15; splitting on the seams the doc comment already described costs | ||
| * nothing and makes each shape separately readable. | ||
| */ | ||
| function headCommit(startDir: string): string { | ||
| const gitPath = findGitPath(startDir) | ||
| if (!gitPath) return 'unknown' | ||
| const gitDir = resolveGitDir(gitPath) | ||
| if (!gitDir) return 'unknown' | ||
|
|
||
| const head = readFileSync(join(gitDir, 'HEAD'), 'utf8').trim() | ||
| if (/^[0-9a-f]{40}$/.test(head)) return head // detached | ||
| if (!head.startsWith('ref:')) return 'unknown' | ||
|
|
||
| return resolveRef(resolveCommonDir(gitDir), head.slice(4).trim()) | ||
| } | ||
|
|
||
| function environment(): BenchRun['environment'] { | ||
| let commit = 'unknown' | ||
| try { | ||
| commit = execSync('git rev-parse --short HEAD', { stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim() | ||
| // 7 hex is git's own default abbreviation; `rev-parse --short` would widen | ||
| // it only in a repository large enough to collide, which this is not. | ||
| commit = headCommit(import.meta.dir).slice(0, 7) || 'unknown' | ||
| } catch { | ||
| /* outside a git checkout — artifacts still carry every other field */ | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '195,275p' .github/workflows/ci.ymlRepository: hyperpolymath/MetaManifold-WebUI
Length of output: 5351
Use a unique cache key for each rerun attempt.
github.run_idremains unchanged when GitHub reruns a workflow. GitHub Actions cache entries are immutable, so a later attempt cannot overwrite the cache created under the same key. Appendgithub.run_attemptto both the restore and save keys. The existingrestore-keysprefixes will then restore the previous attempt's cache.Proposed fix
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.30.0)
[warning] 2-587: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 92-519: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents