From 62cae8114d0da29a2c7991f16c7fcc4583a9fda0 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 9 Dec 2025 11:49:11 +0900 Subject: [PATCH] refactor(comment-checker): simplify binary path resolution and add separator warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove platform-specific package lookup logic - Remove homebrew path resolution - Add code smell warning for comment separators 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) --- src/hooks/comment-checker/cli.ts | 57 -------------------------- src/hooks/comment-checker/constants.ts | 4 ++ 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/hooks/comment-checker/cli.ts b/src/hooks/comment-checker/cli.ts index c5b7bfa..fb39693 100644 --- a/src/hooks/comment-checker/cli.ts +++ b/src/hooks/comment-checker/cli.ts @@ -15,36 +15,13 @@ function debugLog(...args: unknown[]) { } } -type Platform = "darwin" | "linux" | "win32" | "unsupported" - -function getPlatformPackageName(): string | null { - const platform = process.platform as Platform - const arch = process.arch - - const platformMap: Record = { - "darwin-arm64": "@code-yeongyu/comment-checker-darwin-arm64", - "darwin-x64": "@code-yeongyu/comment-checker-darwin-x64", - "linux-arm64": "@code-yeongyu/comment-checker-linux-arm64", - "linux-x64": "@code-yeongyu/comment-checker-linux-x64", - "win32-x64": "@code-yeongyu/comment-checker-windows-x64", - } - - return platformMap[`${platform}-${arch}`] ?? null -} - function getBinaryName(): string { return process.platform === "win32" ? "comment-checker.exe" : "comment-checker" } -/** - * Synchronously find comment-checker binary path. - * Checks installed packages, homebrew, cache, and system PATH. - * Does NOT trigger download. - */ function findCommentCheckerPathSync(): string | null { const binaryName = getBinaryName() - // 1. Try to find from @code-yeongyu/comment-checker package try { const require = createRequire(import.meta.url) const cliPkgPath = require.resolve("@code-yeongyu/comment-checker/package.json") @@ -59,46 +36,12 @@ function findCommentCheckerPathSync(): string | null { debugLog("main package not installed") } - // 2. Try platform-specific package directly (legacy, for backwards compatibility) - const platformPkg = getPlatformPackageName() - if (platformPkg) { - try { - const require = createRequire(import.meta.url) - const pkgPath = require.resolve(`${platformPkg}/package.json`) - const pkgDir = dirname(pkgPath) - const binaryPath = join(pkgDir, "bin", binaryName) - - if (existsSync(binaryPath)) { - debugLog("found binary in platform package:", binaryPath) - return binaryPath - } - } catch { - debugLog("platform package not installed:", platformPkg) - } - } - - // 3. Try homebrew installation (macOS) - if (process.platform === "darwin") { - const homebrewPaths = [ - "/opt/homebrew/bin/comment-checker", - "/usr/local/bin/comment-checker", - ] - for (const path of homebrewPaths) { - if (existsSync(path)) { - debugLog("found binary via homebrew:", path) - return path - } - } - } - - // 4. Try cached binary (lazy download location) const cachedPath = getCachedBinaryPath() if (cachedPath) { debugLog("found binary in cache:", cachedPath) return cachedPath } - // 5. Try system PATH (as fallback) debugLog("no binary found in known locations") return null } diff --git a/src/hooks/comment-checker/constants.ts b/src/hooks/comment-checker/constants.ts index 3732e31..066964b 100644 --- a/src/hooks/comment-checker/constants.ts +++ b/src/hooks/comment-checker/constants.ts @@ -72,6 +72,10 @@ PRIORITY-BASED ACTION GUIDELINES: \t-> Make the code itself clearer so it can be understood without comments/docstrings. \t-> For verbose docstrings: refactor code to be self-documenting instead of adding lengthy explanations. +CODE SMELL WARNING: Using comments as visual separators (e.g., "// =========", "# ---", "// *** Section ***") +is a code smell. If you need separators, your file is too long or poorly organized. +Refactor into smaller modules or use proper code organization instead of comment-based section dividers. + MANDATORY REQUIREMENT: You must acknowledge this hook message and take one of the above actions. Review in the above priority order and take the corresponding action EVERY TIME this appears.