Skip to content

[code-simplifier] Simplify purity_scan.go by extracting resolveObj and ensureDir helpers - #53036

Merged
pelikhan merged 2 commits into
mainfrom
copilot/code-simplifiersimplify-purity-scan-go
Aug 16, 2026
Merged

[code-simplifier] Simplify purity_scan.go by extracting resolveObj and ensureDir helpers#53036
pelikhan merged 2 commits into
mainfrom
copilot/code-simplifiersimplify-purity-scan-go

Conversation

Copilot AI commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

This PR applies a behavior-preserving simplification to .github/scripts/purelock/purity_scan.go, a protected file flagged by the code-simplifier pass. It removes duplicated logic by extracting two local helpers used in multiple call sites.

  • Object lookup deduplication (resolveObj)

    • Extracted the repeated TypesInfo.UsesTypesInfo.Defs fallback pattern into resolveObj(pkg, ident).
    • Replaced identical inline blocks in:
      • isLocalValue
      • escapingTarget
      • escapingWriteThroughBase
  • Directory creation deduplication (ensureDir)

    • Extracted parent-directory creation logic (filepath.Dir + os.MkdirAll) into ensureDir(path).
    • Reused in:
      • writeJSON
      • writeSummary
  • Scope and behavior

    • No public API/signature changes.
    • Refactor is strictly DRY: same control flow and outcomes, with duplicated blocks centralized.
func resolveObj(pkg *packages.Package, ident *ast.Ident) types.Object {
	obj := pkg.TypesInfo.Uses[ident]
	if obj == nil {
		obj = pkg.TypesInfo.Defs[ident]
	}
	return obj
}

func ensureDir(path string) error {
	if dir := filepath.Dir(path); dir != "" && dir != "." {
		if err := os.MkdirAll(dir, 0o755); err != nil {
			return err
		}
	}
	return nil
}

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.8 AIC · ⌖ 7.58 AIC · ⊞ 6.3K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Simplify purity_scan.go by extracting resolveObj and ensureDir helpers [code-simplifier] Simplify purity_scan.go by extracting resolveObj and ensureDir helpers Aug 16, 2026
Copilot AI requested a review from pelikhan August 16, 2026 04:31
@pelikhan
pelikhan marked this pull request as ready for review August 16, 2026 04:32
Copilot AI balanced review requested due to automatic review settings August 16, 2026 04:32
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Reviewed PR #53036 per ponytail-review skill: pure DRY refactor extracting resolveObj() and ensureDir() to replace duplicated inline blocks (net -13 lines). No speculative abstractions, no reinvented stdlib, no dead flexibility introduced. Lean already. Ship.

Generated by Ponytail Reviewer for #53036

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

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 performs a behavior-preserving refactor of the PureLock scanner.

Changes:

  • Centralizes Go object lookup in resolveObj.
  • Centralizes parent-directory creation in ensureDir.
Show a summary per file
File Description
.github/scripts/purelock/purity_scan.go Replaces duplicated lookup and directory-creation logic with shared helpers.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-16T00:00:00Z
review_event: COMMENT
top_themes:
  - no actionable issues found in behavior-preserving helper extraction
files_reviewed:
  - .github/scripts/purelock/purity_scan.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 2.33 AIC · ⌖ 5.3 AIC · ⊞ 6.9K ·
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.

Verdict

No blocking issues found in the changed lines.

Review notes This patch is a narrow refactor that extracts duplicated identifier resolution and parent-directory creation into helpers without changing control flow or error handling. I checked the modified call sites for semantic drift and did not find an actionable correctness, performance, or testability regression in the diff.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 2.33 AIC · ⌖ 5.3 AIC · ⊞ 6.9K
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.

The refactoring is clean and correct. Both resolveObj and ensureDir are faithful extractions of the inlined patterns they replace, with no behavioural changes. No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 12.3 AIC · ⌖ 7.88 AIC · ⊞ 5.6K

@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 /codebase-design — the extractions are clean and the PR is approvable with one naming observation.

📋 Key Themes & Highlights

Key Themes

  • resolveObj: well-named, correctly consolidates 3 identical inline patterns into a single helper.
  • ensureDir: reduces duplication across writeJSON/writeSummary; name is slightly ambiguous (it ensures the parent dir exists for a file path, not a directory itself) — ensureParentDir(path) would be more precise.

Positive Highlights

  • ✅ Behavior-preserving: each call site is a drop-in replacement
  • ✅ Helper signatures are minimal and match existing code style
  • ✅ No change to observable behavior or error paths

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 15.3 AIC · ⌖ 8.31 AIC · ⊞ 7.7K
Comment /matt to run again

@github-actions github-actions Bot mentioned this pull request Aug 16, 2026
@pelikhan
pelikhan merged commit ca57487 into main Aug 16, 2026
80 of 89 checks passed
@pelikhan
pelikhan deleted the copilot/code-simplifiersimplify-purity-scan-go branch August 16, 2026 04:44
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please review the remaining feedback on this PR, refresh the branch if GitHub does not do it automatically, and run the pr-finisher skill before handing back.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.8 AIC · ⌖ 7.58 AIC · ⊞ 6.3K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.87.1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-simplifier] Simplify purity_scan.go: extract resolveObj and ensureDir helpers

4 participants