Skip to content

fix: apply 13 lint-monster correctness/style findings (2026-06-29)#42165

Merged
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-fix-correctness-style
Jun 29, 2026
Merged

fix: apply 13 lint-monster correctness/style findings (2026-06-29)#42165
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-fix-correctness-style

Conversation

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Addresses 13 small correctness/style diagnostics flagged by the custom lint scanner across pkg/stringutil, pkg/constants, and pkg/parser.

Changes

  • pkg/parser/json_path_locator_test.go — handle the json.Unmarshal error instead of silently discarding it
  • 11× len(s) > 0s != "" across:
    • pkg/stringutil/stringutil.go, pkg/stringutil/sanitize.go
    • pkg/constants/constants.go, job_constants.go (×2), url_constants.go, version_constants.go
    • pkg/parser/frontmatter_content.go (×2), import_error.go, remote_fetch.go
  • pkg/parser/schema_errors.go — replace len(strings.Split(message, "\n")) with strings.Count(message, "\n")+1 to avoid allocating a []string just to count lines
// before
schemaErrorsLog.Printf("Simplifying oneOf error message (%d lines)", len(strings.Split(message, "\n")))

// after
schemaErrorsLog.Printf("Simplifying oneOf error message (%d lines)", strings.Count(message, "\n")+1)

All changes are pure expression replacements with no behavior change.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix small correctness and style lints from custom scan fix: apply 13 lint-monster correctness/style findings (2026-06-29) Jun 29, 2026
Copilot AI requested a review from pelikhan June 29, 2026 04:05
@pelikhan pelikhan marked this pull request as ready for review June 29, 2026 04:38
Copilot AI review requested due to automatic review settings June 29, 2026 04:38
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel analysis already completed in a prior invocation of this workflow run. Comment and APPROVE review were successfully posted to PR #42165 (score: 100/100, 1 design test, 0 violations). No further action needed.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #42165 does not have the 'implementation' label and has only 15 new lines of code in business logic directories (threshold: 100). This is a lint/style fix PR with no significant architectural decisions.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR applies a set of small lint-driven correctness/style updates across Go utilities/parsing/constants, plus minor formatting refactors in the agentic workflows dashboard extension.

Changes:

  • Replaced several len(s) > 0 checks with s != "" (including guarding string indexing sites).
  • Optimized schema error logging to count lines without allocating a []string.
  • Improved test robustness by failing fast on json.Unmarshal errors; also reformatted parts of the dashboard extension HTML/JS.
Show a summary per file
File Description
pkg/stringutil/stringutil.go Uses normalized != "" before appending a trailing newline.
pkg/stringutil/sanitize.go Uses result != "" before indexing result[0].
pkg/parser/schema_errors.go Uses strings.Count(...)+1 for line count logging to avoid Split allocation.
pkg/parser/remote_fetch.go Uses trimmed != "" before indexing trimmed[0].
pkg/parser/json_path_locator_test.go Adds explicit json.Unmarshal error handling in the test.
pkg/parser/import_error.go Uses line != "" before checking line[0] to detect section exit.
pkg/parser/frontmatter_content.go Uses line != "" / word != "" checks in metadata parsing and name generation.
pkg/constants/version_constants.go Uses v != "" for semantic-string validity checks.
pkg/constants/url_constants.go Uses d != "" for semantic-string validity checks.
pkg/constants/job_constants.go Uses j != "" / s != "" for semantic-string validity checks.
pkg/constants/constants.go Uses c != "" for semantic-string validity checks.
.github/extensions/agentic-workflows-dashboard/web/index.html Collapses a few conditional rows into single-line markup.
.github/extensions/agentic-workflows-dashboard/extension.mjs Refactors formatting of execFile, Promise.all callsite, and refresh handler block.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 13/13 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment on lines 142 to 145
try {
if (pathname === "/" || pathname === "/index.html") {
const [html, css] = await Promise.all([
readFile(join(__dirname, "web", "index.html"), "utf8"),
readFile(join(__dirname, "web", "styles.css"), "utf8"),
]);
const [html, css] = await Promise.all([readFile(join(__dirname, "web", "index.html"), "utf8"), readFile(join(__dirname, "web", "styles.css"), "utf8")]);
res.setHeader("Content-Type", "text/html; charset=utf-8");
Comment on lines +141 to +143
if err := json.Unmarshal([]byte(schemaJSON), &schemaDoc); err != nil {
t.Fatalf("json.Unmarshal error: %v", err)
}
@github-actions github-actions Bot mentioned this pull request Jun 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 100/100 — Excellent

Analyzed 1 test(s): 1 design, 0 implementation, 0 guideline violation(s).

📊 Metrics & Test Classification (1 test analyzed)
Metric Value
New/modified tests analyzed 1
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 1 (100%)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations 0
Test File Classification Issues Detected
TestExtractJSONPathFromValidationError pkg/parser/json_path_locator_test.go:101 ✅ Design

Go: 1 (*_test.go); JavaScript: 0 (*.test.cjs, *.test.js). Other languages detected but not scored.

Change detail: The PR fixes a lint finding — json.Unmarshal([]byte(schemaJSON), &schemaDoc) (silently discarding the error) was replaced with proper if err := ...; err != nil { t.Fatalf(...) } error handling. This improves test reliability: previously a malformed schema string would silently pass and potentially cause a confusing downstream failure.

Test inflation note: The production file pkg/parser/json_path_locator.go was not changed in this PR (lint fix was test-only), so the technical ratio is 3 test lines / 0 production lines. This is not inflation — it is a targeted test-quality improvement and does not represent over-engineering.

Verdict

Check passed. 0% implementation tests (threshold: 30%). The modified test verifies the observable output of ExtractJSONPathFromValidationError (extracted JSON paths match expected values) and the change adds a defensive setup guard that catches schema-parsing regressions early.

References:

🧪 Test quality analysis by Test Quality Sentinel · 79.3 AIC · ⌖ 27.6 AIC · ⊞ 8.1K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 100/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

All 13 lint-monster fixes look correct and safe.

Go changes — every len(x) > 0x != "" replacement is a semantically equivalent string comparison, safe at all call sites including those guarding x[0] indexing. The strings.Count(message, "\n")+1 optimization is arithmetically equivalent to len(strings.Split(message, "\n")) for all inputs and avoids a []string allocation in a log-only call. The json.Unmarshal error surfacing in the test is a reliability improvement.

No security, correctness, or reliability issues found.

Minor nit (non-blocking)

In extension.mjs, the execFile and refresh handler blocks were each expanded to multi-line for readability, but the Promise.all([readFile(...), readFile(...)]) call was compressed onto one long line — inconsistent with the rest of the formatting changes in this PR. No functional impact.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 34.2 AIC · ⌖ 6.94 AIC · ⊞ 4.9K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /zoom-out — 2 observations, neither blocking. The lint-monster fixes are solid and the json.Unmarshal error handling is a genuine correctness win.

📋 Key Themes & Highlights

Key Themes

  • Misleading optimization claim (schema_errors.go): The strings.Count()+1 change is idiomatic Go, but it doesn't actually avoid an allocation because strings.Split is called unconditionally on the very next line. The PR description overstates the benefit.
  • Inconsistent formatting (extension.mjs): The Promise.all array was collapsed to a single long line, contradicting the multi-line expansion applied to execFile and handler in the same file.

Positive Highlights

  • ✅ The json.Unmarshal error check in json_path_locator_test.go is a genuine correctness fix — silent test failures are dangerous.
  • ✅ All 11 len(s) > 0s != "" replacements are correct idiomatic Go; the short-circuit semantics are preserved where line[0] accesses follow the guard.
  • ✅ The typed-string IsValid() methods (CommandPrefix, JobName, StepID, DocURL, Version) now consistently use != "" — clean and readable.
  • ✅ The execFile and handler reformats in extension.mjs genuinely improve readability.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 47.2 AIC · ⌖ 7.47 AIC · ⊞ 6.6K
Comment /matt to run again

}

schemaErrorsLog.Printf("Simplifying oneOf error message (%d lines)", len(strings.Split(message, "\n")))
schemaErrorsLog.Printf("Simplifying oneOf error message (%d lines)", strings.Count(message, "\n")+1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/zoom-out] The allocation optimization is nullified by the very next statement.

The PR description says this change avoids allocating a []string just to count lines, but strings.Split(message, "\n") is called unconditionally on line 95 to populate lines. The strings.Count call saves nothing in practice because the []string allocation still happens immediately after.

💡 When this optimization would matter

This approach is a genuine win when the count is used in a conditional path that doesn't always reach the Split call:

// Worth optimizing: count guards the Split
if strings.Count(message, "\n")+1 > threshold {
    lines := strings.Split(message, "\n")
    // ...
}

Here, however, lines is always assigned right after the log line, so the split always runs. The change is still valid idiomatic Go — but the performance rationale in the PR description is misleading.

@copilot please address this.

readFile(join(__dirname, "web", "index.html"), "utf8"),
readFile(join(__dirname, "web", "styles.css"), "utf8"),
]);
const [html, css] = await Promise.all([readFile(join(__dirname, "web", "index.html"), "utf8"), readFile(join(__dirname, "web", "styles.css"), "utf8")]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/zoom-out] Readability regression: Promise.all was collapsed to a single long line, contradicting the expansion applied to execFile and handler in the same PR.

The original multi-line form was clearer and consistent with this PR's other formatting improvements. The new single-line form is harder to scan at a glance.

💡 Suggested formatting
const [html, css] = await Promise.all([
  readFile(join(__dirname, "web", "index.html"), "utf8"),
  readFile(join(__dirname, "web", "styles.css"), "utf8"),
]);

This mirrors the before-state and keeps each readFile call on its own line, which is easier to read and diff.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Go changes are correct and safe to merge.

Review details

Correctness verification

  • len(s) > 0s != "" (×11): Semantically equivalent for all named string types in Go; both return false for the zero value.
  • strings.Count(message, "\n")+1: Mathematically identical to len(strings.Split(message, "\n")) for every possible input — Split on a separator always yields exactly Count+1 elements.
  • Index-safe guards (line != "" && line[0] != ...): Equivalent to the removed len(line) > 0 && ... guards; no index-out-of-bounds risk introduced.
  • Test json.Unmarshal error handling: Strictly better — previously a bad JSON constant would silently produce a nil schemaDoc, causing a misleading downstream failure.
  • Dashboard changes: Formatting-only; no behavioral risk.

🔎 Code quality review by PR Code Quality Reviewer · 67.8 AIC · ⌖ 6.86 AIC · ⊞ 5.2K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage — §28357644191

Field Value
Category bug
Risk 🟢 Low
Score 55/100 (Impact 22 · Urgency 15 · Quality 18)
Action auto_merge

Small, clean correctness fixes (+37/-38, 13 files): error handling in test, 11× string comparison normalisations. CI ✅ passing, 3 automated approvals. Ready to auto-merge.

Generated by 🔧 PR Triage Agent · 89.9 AIC · ⌖ 12 AIC · ⊞ 5.4K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@pelikhan pelikhan merged commit 24cf6dc into main Jun 29, 2026
83 of 97 checks passed
@pelikhan pelikhan deleted the copilot/lint-monster-fix-correctness-style branch June 29, 2026 09:22
Copilot stopped work on behalf of pelikhan due to an error June 29, 2026 09:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants