The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
fix(hooks): support python style comments in pre-commit quality checks (#3194)
Sedat Dağc056ae7df2f1
diff --git a/scripts/hooks/pre-bash-commit-quality.js b/scripts/hooks/pre-bash-commit-quality.jsindex 400497055..6504a1b56 100644--- a/scripts/hooks/pre-bash-commit-quality.js+++ b/scripts/hooks/pre-bash-commit-quality.js@@ -99,7 +99,7 @@ function findFileIssues(filePath) {const lineNum = index + 1;// Check for console.log- if (line.includes('console.log') && !line.trim().startsWith('//') && !line.trim().startsWith('*')) {+ if (line.includes('console.log') && !line.trim().startsWith('//') && !line.trim().startsWith('*') && !line.trim().startsWith('#')) {issues.push({type: 'console.log',message: `console.log found at line ${lineNum}`,@@ -109,7 +109,7 @@ function findFileIssues(filePath) {}// Check for debugger statements- if (/\bdebugger\b/.test(line) && !line.trim().startsWith('//')) {+ if (/\bdebugger\b/.test(line) && !line.trim().startsWith('//') && !line.trim().startsWith('#')) {issues.push({type: 'debugger',message: `debugger statement at line ${lineNum}`,@@ -119,7 +119,7 @@ function findFileIssues(filePath) {}// Check for TODO/FIXME without issue reference- const todoMatch = line.match(/\/\/\s*(TODO|FIXME):?\s*(.+)/);+ const todoMatch = line.match(/(?:\/\/|#)\s*(TODO|FIXME):?\s*(\S.*)/);if (todoMatch && !todoMatch[2].match(/#\d+|issue/i)) {issues.push({type: 'todo',diff --git a/tests/hooks/pre-bash-commit-quality.test.js b/tests/hooks/pre-bash-commit-quality.test.jsindex 778fc2990..85a76ee9f 100644--- a/tests/hooks/pre-bash-commit-quality.test.js+++ b/tests/hooks/pre-bash-commit-quality.test.js@@ -504,6 +504,32 @@ if (test('measures length of the full message past an apostrophe (not the truncaassert.strictEqual(res.message, subject);assert.ok(res.issues.some(i => i.type === 'length'), 'full (>72) message should trigger a length issue');})) passed++; else failed++;-+if (test('handles hash-prefixed python comments and string false-positives', () => {+ inTempRepo(repoDir => {+ writeAndStage(repoDir, 'script.py', [+ '# console.log("commented out");',+ '# debugger',+ '# TODO: python unreferenced',+ '# TODO: python issue #456',+ 'const str = "# TODO: string false positive";', // Greptile string limitation+ ''+ ].join('\n'));++ const input = JSON.stringify({ tool_input: { command: 'git commit -m "fix(hooks): python hash comments"' } });++ const origConsoleError = console.error;+ let stderr = '';+ console.error = msg => { stderr += msg + '\n'; };++ const result = hook.evaluate(input);+ console.error = origConsoleError;++ assert.strictEqual(result.exitCode, 0, 'warning-only issues should not block');+ assert.ok(stderr.includes('INFO Line 3:'), `expected python TODO warning`);+ assert.ok(!stderr.includes('INFO Line 4'), 'referenced python TODO should not warn');+ assert.ok(!stderr.includes('ERROR Line 2'), 'commented debugger should not error');+ assert.ok(stderr.includes('INFO Line 5:'), `expected string limitation warning`);+ });+})) passed++; else failed++;console.log(`\nResults: Passed: ${passed}, Failed: ${failed}, Skipped: ${skipped}`);process.exit(failed > 0 ? 1 : 0);