@webpieces/code-rules 0.0.1 → 0.2.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/src/cli.d.ts +1 -0
- package/src/cli.js +19 -0
- package/src/cli.js.map +1 -0
- package/src/diff-utils.d.ts +24 -0
- package/src/{diff-utils.ts → diff-utils.js} +30 -38
- package/src/diff-utils.js.map +1 -0
- package/src/from-shared-config.d.ts +28 -0
- package/src/from-shared-config.js +119 -0
- package/src/from-shared-config.js.map +1 -0
- package/src/index.js +33 -0
- package/src/index.js.map +1 -0
- package/src/validate-catch-error-pattern.d.ts +47 -0
- package/src/{validate-catch-error-pattern.ts → validate-catch-error-pattern.js} +74 -195
- package/src/validate-catch-error-pattern.js.map +1 -0
- package/src/validate-code.d.ts +98 -0
- package/src/{validate-code.ts → validate-code.js} +65 -259
- package/src/validate-code.js.map +1 -0
- package/src/validate-dtos.d.ts +41 -0
- package/src/{validate-dtos.ts → validate-dtos.js} +88 -215
- package/src/validate-dtos.js.map +1 -0
- package/src/validate-modified-files.d.ts +24 -0
- package/src/{validate-modified-files.ts → validate-modified-files.js} +46 -115
- package/src/validate-modified-files.js.map +1 -0
- package/src/validate-modified-methods.d.ts +30 -0
- package/src/{validate-modified-methods.ts → validate-modified-methods.js} +94 -196
- package/src/validate-modified-methods.js.map +1 -0
- package/src/validate-new-methods.d.ts +27 -0
- package/src/{validate-new-methods.ts → validate-new-methods.js} +63 -133
- package/src/validate-new-methods.js.map +1 -0
- package/src/validate-no-any-unknown.d.ts +41 -0
- package/src/{validate-no-any-unknown.ts → validate-no-any-unknown.js} +69 -146
- package/src/validate-no-any-unknown.js.map +1 -0
- package/src/validate-no-destructure.d.ts +51 -0
- package/src/{validate-no-destructure.ts → validate-no-destructure.js} +80 -166
- package/src/validate-no-destructure.js.map +1 -0
- package/src/validate-no-direct-api-resolver.d.ts +46 -0
- package/src/{validate-no-direct-api-resolver.ts → validate-no-direct-api-resolver.js} +112 -211
- package/src/validate-no-direct-api-resolver.js.map +1 -0
- package/src/validate-no-implicit-any.d.ts +36 -0
- package/src/{validate-no-implicit-any.ts → validate-no-implicit-any.js} +94 -141
- package/src/validate-no-implicit-any.js.map +1 -0
- package/src/validate-no-inline-types.d.ts +90 -0
- package/src/{validate-no-inline-types.ts → validate-no-inline-types.js} +93 -198
- package/src/validate-no-inline-types.js.map +1 -0
- package/src/validate-no-unmanaged-exceptions.d.ts +43 -0
- package/src/{validate-no-unmanaged-exceptions.ts → validate-no-unmanaged-exceptions.js} +71 -140
- package/src/validate-no-unmanaged-exceptions.js.map +1 -0
- package/src/validate-prisma-converters.d.ts +59 -0
- package/src/{validate-prisma-converters.ts → validate-prisma-converters.js} +120 -307
- package/src/validate-prisma-converters.js.map +1 -0
- package/src/validate-return-types.d.ts +28 -0
- package/src/{validate-return-types.ts → validate-return-types.js} +84 -168
- package/src/validate-return-types.js.map +1 -0
- package/LICENSE +0 -373
- package/jest.config.ts +0 -20
- package/project.json +0 -22
- package/src/cli.ts +0 -17
- package/src/from-shared-config.ts +0 -118
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -14
- /package/src/{index.ts → index.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-modified-methods.js","sourceRoot":"","sources":["../../../../../packages/tooling/code-rules/src/validate-modified-methods.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAotBH,+BAoEC;;AAtxBD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAuBjC,MAAM,OAAO,GAAG,wBAAwB,CAAC;AACzC,MAAM,WAAW,GAAG,yBAAyB,CAAC;AAE9C,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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ACD,MAAM,YAAY,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;YAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,yBAAyB,YAAY,CAAC,MAAM,qBAAqB,CAAC,CAAC;QAE/E,MAAM,UAAU,GAAG,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;QAElG,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,wCAAwC,GAAG,KAAK,GAAG,QAAQ,CAAC,CAAC;YACzE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC;QAED,oBAAoB,CAAC,aAAa,CAAC,CAAC;QACpC,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;QACpD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,6BAA6B;QAC7B,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1E,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;AACL,CAAC","sourcesContent":["/**\n * Validate Modified Methods Executor\n *\n * Validates that modified methods don't exceed a maximum line count (default 80).\n * This encourages gradual cleanup of legacy long methods - when you touch a method,\n * you must bring it under the limit.\n *\n * Combined with validate-new-methods, this creates a gradual\n * transition to cleaner code:\n * - New methods: must be under limit\n * - Modified methods: must be under limit (cleanup when touched)\n * - Untouched methods: no limit (legacy allowed)\n *\n * Usage:\n * nx affected --target=validate-modified-methods --base=origin/main\n *\n * Escape hatch: Add webpieces-disable max-lines-modified comment with date and justification\n * Format: // webpieces-disable max-lines-modified 2025/01/15 -- [reason]\n * The disable expires after 1 month from the date specified.\n */\n\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type MethodMaxLimitMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';\n\nexport interface ValidateModifiedMethodsOptions {\n limit?: number;\n mode?: MethodMaxLimitMode;\n disableAllowed?: boolean;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface MethodViolation {\n file: string;\n methodName: string;\n line: number;\n lines: number;\n expiredDisable?: boolean;\n expiredDate?: string;\n}\n\nconst TMP_DIR = '.webpieces/instruct-ai';\nconst TMP_MD_FILE = 'webpieces.methodsize.md';\n\nconst METHODSIZE_DOC_CONTENT = `# Instructions: Method Too Long\n\n## Requirement\n\n**~99% of the time**, you can stay under the \\`limit\\` from nx.json\nby extracting logical units into well-named methods.\nNearly all software can be written with methods under this size.\nTake the extra time to refactor - it's worth it for long-term maintainability.\n\n## The \"Table of Contents\" Principle\n\nGood code reads like a book's table of contents:\n- Chapter titles (method names) tell you WHAT happens\n- Reading chapter titles gives you the full story\n- You can dive into chapters (implementations) for details\n\n## Why Limit Method Sizes?\n\nMethods under reasonable limits are:\n- Easy to review in a single screen\n- Simple to understand without scrolling\n- Quick for AI to analyze and suggest improvements\n- More testable in isolation\n- Self-documenting through well-named extracted methods\n\n## Gradual Cleanup Strategy\n\nThis codebase uses a gradual cleanup approach:\n- **New methods**: Must be under \\`limit\\` from nx.json\n- **Modified methods**: Must be under \\`limit\\` from nx.json\n- **Untouched methods**: No limit (legacy code is allowed until touched)\n\n## How to Refactor\n\nInstead of:\n\\`\\`\\`typescript\nasync processOrder(order: Order): Promise<Result> {\n // 100 lines of validation, transformation, saving, notifications...\n}\n\\`\\`\\`\n\nWrite:\n\\`\\`\\`typescript\nasync processOrder(order: Order): Promise<Result> {\n const validated = this.validateOrder(order);\n const transformed = this.applyBusinessRules(validated);\n const saved = await this.saveToDatabase(transformed);\n await this.notifyStakeholders(saved);\n return this.buildResult(saved);\n}\n\\`\\`\\`\n\nNow the main method is a \"table of contents\" - each line tells part of the story!\n\n## Patterns for Extraction\n\n### Pattern 1: Extract Loop Bodies\n\\`\\`\\`typescript\n// BEFORE\nfor (const item of items) {\n // 20 lines of processing\n}\n\n// AFTER\nfor (const item of items) {\n this.processItem(item);\n}\n\\`\\`\\`\n\n### Pattern 2: Extract Conditional Blocks\n\\`\\`\\`typescript\n// BEFORE\nif (isAdmin(user)) {\n // 15 lines of admin logic\n}\n\n// AFTER\nif (isAdmin(user)) {\n this.handleAdminUser(user);\n}\n\\`\\`\\`\n\n### Pattern 3: Extract Data Transformations\n\\`\\`\\`typescript\n// BEFORE\nconst result = {\n // 10+ lines of object construction\n};\n\n// AFTER\nconst result = this.buildResultObject(data);\n\\`\\`\\`\n\n## If Refactoring Is Not Feasible\n\nSometimes methods genuinely need to be longer (complex algorithms, state machines, etc.).\n\n**Escape hatch**: Add a webpieces-disable comment with DATE and justification:\n\n\\`\\`\\`typescript\n// webpieces-disable max-lines-modified 2025/01/15 -- Complex state machine, splitting reduces clarity\nasync complexStateMachine(): Promise<void> {\n // ... longer method with justification\n}\n\\`\\`\\`\n\n**IMPORTANT**: The date format is yyyy/mm/dd. The disable will EXPIRE after 1 month from this date.\nAfter expiration, you must either fix the method or update the date to get another month.\nThis ensures that disable comments are reviewed periodically.\n\n## AI Agent Action Steps\n\n1. **READ** the method to understand its logical sections\n2. **IDENTIFY** logical units that can be extracted\n3. **EXTRACT** into well-named private methods\n4. **VERIFY** the main method now reads like a table of contents\n5. **IF NOT FEASIBLE**: Add webpieces-disable max-lines-modified comment with clear justification\n\n## Remember\n\n- Every method you write today will be read many times tomorrow\n- The best code explains itself through structure\n- When in doubt, extract and name it\n`;\n\n/**\n * Write the instructions documentation to tmp directory\n */\nfunction writeTmpInstructions(workspaceRoot: string): string {\n const tmpDir = path.join(workspaceRoot, TMP_DIR);\n const mdPath = path.join(tmpDir, TMP_MD_FILE);\n\n fs.mkdirSync(tmpDir, { recursive: true });\n fs.writeFileSync(mdPath, METHODSIZE_DOC_CONTENT);\n\n return mdPath;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n * Uses `git diff base [head]` to match what `nx affected` does.\n * When head is NOT specified, also includes untracked files (matching nx affected behavior).\n */\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // If head is specified, diff base to head; otherwise diff base to working tree\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n // When comparing to working tree (no head specified), also include untracked files\n // This matches what nx affected does: \"All modified files not yet committed or tracked will also be added\"\n if (!head) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n // Merge and dedupe\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch (err: unknown) {\n //const error = toError(err);\n // If ls-files fails, just return the changed files\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch (err: unknown) {\n //const error = toError(err);\n return [];\n }\n}\n\n/**\n * Get the diff content for a specific file between base and head (or working tree if head not specified).\n * Uses `git diff base [head]` to match what `nx affected` does.\n * For untracked files, returns the entire file content as additions.\n */\nfunction getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // If head is specified, diff base to head; otherwise diff base to working tree\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n // If diff is empty and we're comparing to working tree, check if it's an untracked file\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n // Check if file is untracked\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n // For untracked files, treat entire content as additions\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n // Create a pseudo-diff where all lines are additions\n return lines.map((line) => `+${line}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch (err: unknown) {\n //const error = toError(err);\n return '';\n }\n}\n\n/**\n * Parse diff to find NEW method signatures.\n * Must handle: export function, async function, const/let arrow functions, class methods\n */\n// webpieces-disable max-lines-new-methods -- Regex patterns require inline documentation\nfunction findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n // Patterns to match method definitions (same as validate-new-methods)\n const patterns = [\n // [export] [async] function methodName( - most explicit, check first\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n // [export] const/let methodName = [async] (\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n // [export] const/let methodName = [async] function\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n // class method: [public/private/protected] [static] [async] methodName( - but NOT constructor, if, for, while, etc.\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n // Extract method name - now always in capture group 1\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n}\n\n/**\n * Parse diff to find line numbers that have changes in the new file\n */\nfunction getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n\n let currentNewLine = 0;\n\n for (const line of lines) {\n // Parse hunk header: @@ -oldStart,oldCount +newStart,newCount @@\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentNewLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (currentNewLine === 0) continue;\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n // Added line\n changedLines.add(currentNewLine);\n currentNewLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Removed line - doesn't increment new line counter\n } else if (!line.startsWith('\\\\')) {\n // Context line (unchanged)\n currentNewLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Parse a date string in yyyy/mm/dd format and return a Date object.\n * Returns null if the format is invalid.\n */\nfunction parseDisableDate(dateStr: string): Date | null {\n // Match yyyy/mm/dd format\n const match = dateStr.match(/^(\\d{4})\\/(\\d{2})\\/(\\d{2})$/);\n if (!match) return null;\n\n const year = parseInt(match[1], 10);\n const month = parseInt(match[2], 10) - 1; // JS months are 0-indexed\n const day = parseInt(match[3], 10);\n\n const date = new Date(year, month, day);\n\n // Validate the date is valid (e.g., not Feb 30)\n if (date.getFullYear() !== year || date.getMonth() !== month || date.getDate() !== day) {\n return null;\n }\n\n return date;\n}\n\n/**\n * Check if a date is within the last month (not expired).\n */\nfunction isDateWithinMonth(date: Date): boolean {\n const now = new Date();\n const oneMonthAgo = new Date(now.getFullYear(), now.getMonth() - 1, now.getDate());\n return date >= oneMonthAgo;\n}\n\n/**\n * Get today's date in yyyy/mm/dd format for error messages\n */\nfunction getTodayDateString(): string {\n const now = new Date();\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n return `${year}/${month}/${day}`;\n}\n\ninterface DisableInfo {\n type: 'full' | 'new-only' | 'none';\n isExpired: boolean;\n date?: string;\n}\n\n/**\n * Check what kind of webpieces-disable comment is present for a method.\n * Returns: DisableInfo with type, expiration status, and date\n * - 'full': max-lines-modified (ultimate escape, skips both validators)\n * - 'new-only': max-lines-new-methods (escaped 30-line check, still needs 80-line check)\n * - 'none': no escape hatch\n */\n// webpieces-disable max-lines-new-methods -- Complex validation logic with multiple escape hatch types\nfunction getDisableInfo(lines: string[], lineNumber: number): DisableInfo {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable')) {\n if (line.includes('max-lines-modified')) {\n // Check for date in format: max-lines-modified yyyy/mm/dd\n const dateMatch = line.match(/max-lines-modified\\s+(\\d{4}\\/\\d{2}\\/\\d{2}|XXXX\\/XX\\/XX)/);\n\n if (!dateMatch) {\n // No date found - treat as expired (invalid)\n return { type: 'full', isExpired: true, date: undefined };\n }\n\n const dateStr = dateMatch[1];\n\n // Secret permanent disable\n if (dateStr === 'XXXX/XX/XX') {\n return { type: 'full', isExpired: false, date: dateStr };\n }\n\n const date = parseDisableDate(dateStr);\n if (!date) {\n // Invalid date format - treat as expired\n return { type: 'full', isExpired: true, date: dateStr };\n }\n\n if (!isDateWithinMonth(date)) {\n // Date is expired (older than 1 month)\n return { type: 'full', isExpired: true, date: dateStr };\n }\n\n // Valid and not expired\n return { type: 'full', isExpired: false, date: dateStr };\n }\n if (line.includes('max-lines-new-methods')) {\n // Check for date in format: max-lines-new-methods yyyy/mm/dd\n const dateMatch = line.match(/max-lines-new-methods\\s+(\\d{4}\\/\\d{2}\\/\\d{2}|XXXX\\/XX\\/XX)/);\n\n if (!dateMatch) {\n // No date found - treat as expired (invalid)\n return { type: 'new-only', isExpired: true, date: undefined };\n }\n\n const dateStr = dateMatch[1];\n\n // Secret permanent disable\n if (dateStr === 'XXXX/XX/XX') {\n return { type: 'new-only', isExpired: false, date: dateStr };\n }\n\n const date = parseDisableDate(dateStr);\n if (!date) {\n // Invalid date format - treat as expired\n return { type: 'new-only', isExpired: true, date: dateStr };\n }\n\n if (!isDateWithinMonth(date)) {\n // Date is expired (older than 1 month)\n return { type: 'new-only', isExpired: true, date: dateStr };\n }\n\n // Valid and not expired\n return { type: 'new-only', isExpired: false, date: dateStr };\n }\n }\n }\n return { type: 'none', isExpired: false };\n}\n\ninterface MethodInfo {\n name: string;\n line: number;\n endLine: number;\n lines: number;\n disableInfo: DisableInfo;\n}\n\n/**\n * Parse a TypeScript file and find methods with their line counts\n */\n// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function\nfunction findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const methods: MethodInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor pattern requires handling multiple node types\n function visit(node: ts.Node): void {\n let methodName: string | undefined;\n let startLine: number | undefined;\n let endLine: number | undefined;\n\n if (ts.isMethodDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isFunctionDeclaration(node) && node.name) {\n methodName = node.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n } else if (ts.isArrowFunction(node)) {\n if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {\n methodName = node.parent.name.getText(sourceFile);\n const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());\n startLine = start.line + 1;\n endLine = end.line + 1;\n }\n }\n\n if (methodName && startLine !== undefined && endLine !== undefined) {\n methods.push({\n name: methodName,\n line: startLine,\n endLine: endLine,\n lines: endLine - startLine + 1,\n disableInfo: getDisableInfo(fileLines, startLine),\n });\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return methods;\n}\n\n/**\n * Check if a method has any changes within its line range\n */\nfunction methodHasChanges(method: MethodInfo, changedLineNumbers: Set<number>): boolean {\n for (let line = method.line; line <= method.endLine; line++) {\n if (changedLineNumbers.has(line)) return true;\n }\n return false;\n}\n\n/**\n * Check a NEW method and return violation if applicable\n */\nfunction checkNewMethodViolation(file: string, method: MethodInfo, disableAllowed: boolean): MethodViolation | null {\n const disableType = method.disableInfo.type;\n const isExpired = method.disableInfo.isExpired;\n const disableDate = method.disableInfo.date;\n\n if (!disableAllowed) {\n // When disableAllowed is false, skip NEW methods without escape (let validate-new-methods handle)\n if (disableType === 'none') return null;\n return { file, methodName: method.name, line: method.line, lines: method.lines };\n }\n\n if (disableType === 'full' && isExpired) {\n return { file, methodName: method.name, line: method.line, lines: method.lines, expiredDisable: true, expiredDate: disableDate };\n }\n if (disableType !== 'new-only') return null;\n\n if (isExpired) {\n return { file, methodName: method.name, line: method.line, lines: method.lines, expiredDisable: true, expiredDate: disableDate };\n }\n return { file, methodName: method.name, line: method.line, lines: method.lines };\n}\n\n/**\n * Check a MODIFIED method and return violation if applicable\n */\nfunction checkModifiedMethodViolation(file: string, method: MethodInfo, disableAllowed: boolean): MethodViolation | null {\n const disableType = method.disableInfo.type;\n const isExpired = method.disableInfo.isExpired;\n const disableDate = method.disableInfo.date;\n\n if (!disableAllowed) {\n return { file, methodName: method.name, line: method.line, lines: method.lines };\n }\n if (disableType === 'full' && !isExpired) {\n // Valid escape, no violation\n return null;\n }\n if (disableType === 'full' && isExpired) {\n return { file, methodName: method.name, line: method.line, lines: method.lines, expiredDisable: true, expiredDate: disableDate };\n }\n return { file, methodName: method.name, line: method.line, lines: method.lines };\n}\n\n/**\n * Find methods that exceed the limit.\n * Checks NEW methods with escape hatches and MODIFIED methods.\n */\nfunction findViolations(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n limit: number,\n disableAllowed: boolean,\n head?: string\n): MethodViolation[] {\n const violations: MethodViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n if (!diff) continue;\n\n const newMethodNames = findNewMethodSignaturesInDiff(diff);\n const changedLineNumbers = getChangedLineNumbers(diff);\n if (changedLineNumbers.size === 0) continue;\n\n const methods = findMethodsInFile(file, workspaceRoot);\n\n for (const method of methods) {\n const disableType = method.disableInfo.type;\n const isExpired = method.disableInfo.isExpired;\n\n // Skip methods with valid, non-expired full escape - unless disableAllowed is false\n if (disableAllowed && disableType === 'full' && !isExpired) continue;\n if (method.lines <= limit) continue;\n\n const isNewMethod = newMethodNames.has(method.name);\n\n if (isNewMethod) {\n const violation = checkNewMethodViolation(file, method, disableAllowed);\n if (violation) violations.push(violation);\n } else if (methodHasChanges(method, changedLineNumbers)) {\n const violation = checkModifiedMethodViolation(file, method, disableAllowed);\n if (violation) violations.push(violation);\n }\n }\n }\n\n return violations;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch (err: unknown) {\n //const error = toError(err);\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch (err2: unknown) {\n //const error2 = toError(err2);\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Report violations to console\n */\n// webpieces-disable max-lines-new-methods -- Error output formatting with multiple message sections\nfunction reportViolations(violations: MethodViolation[], limit: number, disableAllowed: boolean): void {\n console.error('');\n console.error('\\u274c Modified methods exceed ' + limit + ' lines!');\n console.error('');\n console.error('\\ud83d\\udcda When you modify a method, you must bring it under ' + limit + ' lines.');\n console.error(' This rule encourages GRADUAL cleanup so even though you did not cause it,');\n console.error(' you touched it, so you should fix now as part of your PR');\n console.error(' (this is for vibe coding and AI to fix as it touches things).');\n console.error(' You can refactor to stay under the limit 50% of the time. If not feasible, use the escape hatch.');\n console.error('');\n console.error(\n '\\u26a0\\ufe0f *** READ .webpieces/instruct-ai/webpieces.methodsize.md for detailed guidance on how to fix this easily *** \\u26a0\\ufe0f'\n );\n console.error('');\n\n for (const v of violations) {\n if (v.expiredDisable) {\n console.error(` \\u274c ${v.file}:${v.line}`);\n console.error(` Method: ${v.methodName} (${v.lines} lines, max: ${limit})`);\n console.error(` \\u23f0 EXPIRED DISABLE: Your disable comment dated ${v.expiredDate ?? 'unknown'} has expired (>1 month old).`);\n console.error(` You must either FIX the method or UPDATE the date to get another month.`);\n } else {\n console.error(` \\u274c ${v.file}:${v.line}`);\n console.error(` Method: ${v.methodName} (${v.lines} lines, max: ${limit})`);\n }\n }\n console.error('');\n\n // Only show escape hatch instructions when disableAllowed is true\n if (disableAllowed) {\n console.error(' You can disable this error, but you will be forced to fix again in 1 month');\n console.error(' since 99% of methods can be less than ' + limit + ' lines of code.');\n console.error('');\n console.error(' Use escape with DATE (expires in 1 month):');\n console.error(` // webpieces-disable max-lines-modified ${getTodayDateString()} -- [your reason]`);\n console.error('');\n } else {\n console.error(' \\u26a0\\ufe0f disableAllowed is false - disable comments are NOT allowed.');\n console.error(' This rule must be met and cannot be disabled since nx.json disableAllowed is set to false.');\n console.error(' You MUST refactor to reduce method size.');\n console.error('');\n console.error(' For a major refactor, a human can add \"ignoreModifiedUntilEpoch\" to nx.json validate-code options.');\n console.error(' This is an expiry timestamp (epoch ms) for when we start forcing everyone to meet size rules again.');\n console.error(' Sometimes for speed, we allow methods to expand during a refactor and over time,');\n console.error(' each PR reduces methods as they get touched.');\n console.error(' AI agents should NOT add ignoreModifiedUntilEpoch - ask a human to do it.');\n console.error('');\n }\n}\n\nexport default async function runValidator(\n options: ValidateModifiedMethodsOptions,\n workspaceRoot: string\n): Promise<ExecutorResult> {\n const limit = options.limit ?? 80;\n const mode: MethodMaxLimitMode = options.mode ?? 'NEW_AND_MODIFIED_METHODS';\n const disableAllowed = options.disableAllowed ?? true;\n\n // Skip validation entirely if mode is OFF\n if (mode === 'OFF') {\n console.log('\\n\\u23ed\\ufe0f Skipping modified method validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n // If NX_HEAD is set (via nx affected --head=X), use it; otherwise compare to working tree\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n\\u23ed\\ufe0f Skipping modified method validation (could not detect base branch)');\n console.log(' To run explicitly: nx affected --target=validate-modified-methods --base=origin/main');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n\\ud83d\\udccf Validating Modified Method Sizes (auto-detected base)\\n');\n } else {\n console.log('\\n\\ud83d\\udccf Validating Modified Method Sizes\\n');\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log(` Mode: ${mode}`);\n console.log(` Limit for modified methods: ${limit}`);\n console.log(` Disable allowed: ${disableAllowed}${!disableAllowed ? ' (no escape hatch)' : ''}`);\n console.log('');\n\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('\\u2705 No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`\\ud83d\\udcc2 Checking ${changedFiles.length} changed file(s)...`);\n\n const violations = findViolations(workspaceRoot, changedFiles, base, limit, disableAllowed, head);\n\n if (violations.length === 0) {\n console.log('\\u2705 All modified methods are under ' + limit + ' lines');\n return { success: true };\n }\n\n writeTmpInstructions(workspaceRoot);\n reportViolations(violations, limit, disableAllowed);\n return { success: false };\n } catch (err: unknown) {\n //const error = toError(err);\n const error = err instanceof Error ? err : new Error(String(err));\n console.error('\\u274c Modified method validation failed:', error.message);\n return { success: false };\n }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate New Methods Executor
|
|
3
|
+
*
|
|
4
|
+
* Validates that newly added methods don't exceed a maximum line count.
|
|
5
|
+
* Runs in affected mode when:
|
|
6
|
+
* 1. NX_BASE environment variable is set (via nx affected), OR
|
|
7
|
+
* 2. Auto-detects base by finding merge-base with origin/main
|
|
8
|
+
*
|
|
9
|
+
* This validator encourages writing methods that read like a "table of contents"
|
|
10
|
+
* where each method call describes a larger piece of work.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* nx affected --target=validate-new-methods --base=origin/main
|
|
14
|
+
* OR: runs automatically via build's architecture:validate-complete dependency
|
|
15
|
+
*
|
|
16
|
+
* Escape hatch: Add webpieces-disable max-lines-new-methods comment with justification
|
|
17
|
+
*/
|
|
18
|
+
export type MethodMaxLimitMode = 'OFF' | 'NEW_METHODS' | 'NEW_AND_MODIFIED_METHODS' | 'MODIFIED_FILES';
|
|
19
|
+
export interface ValidateNewMethodsOptions {
|
|
20
|
+
limit?: number;
|
|
21
|
+
mode?: MethodMaxLimitMode;
|
|
22
|
+
disableAllowed?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ExecutorResult {
|
|
25
|
+
success: boolean;
|
|
26
|
+
}
|
|
27
|
+
export default function runValidator(options: ValidateNewMethodsOptions, workspaceRoot: string): Promise<ExecutorResult>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Validate New Methods Executor
|
|
3
4
|
*
|
|
@@ -15,43 +16,15 @@
|
|
|
15
16
|
*
|
|
16
17
|
* Escape hatch: Add webpieces-disable max-lines-new-methods comment with justification
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export interface ValidateNewMethodsOptions {
|
|
27
|
-
limit?: number;
|
|
28
|
-
mode?: MethodMaxLimitMode;
|
|
29
|
-
disableAllowed?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface ExecutorResult {
|
|
33
|
-
success: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface MethodViolation {
|
|
37
|
-
file: string;
|
|
38
|
-
methodName: string;
|
|
39
|
-
line: number;
|
|
40
|
-
lines: number;
|
|
41
|
-
isNew: boolean;
|
|
42
|
-
limit: number;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface MethodInfo {
|
|
46
|
-
name: string;
|
|
47
|
-
line: number;
|
|
48
|
-
lines: number;
|
|
49
|
-
hasDisableComment: boolean;
|
|
50
|
-
}
|
|
51
|
-
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.default = runValidator;
|
|
21
|
+
const tslib_1 = require("tslib");
|
|
22
|
+
const child_process_1 = require("child_process");
|
|
23
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
24
|
+
const path = tslib_1.__importStar(require("path"));
|
|
25
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
52
26
|
const TMP_DIR = '.webpieces/instruct-ai';
|
|
53
27
|
const TMP_MD_FILE = 'webpieces.methodsize.md';
|
|
54
|
-
|
|
55
28
|
const METHODSIZE_DOC_CONTENT = `# Instructions: New Method Too Long
|
|
56
29
|
|
|
57
30
|
## Requirement
|
|
@@ -167,31 +140,27 @@ async complexStateMachine(): Promise<void> {
|
|
|
167
140
|
- The best code explains itself through structure
|
|
168
141
|
- When in doubt, extract and name it
|
|
169
142
|
`;
|
|
170
|
-
|
|
171
143
|
/**
|
|
172
144
|
* Write the instructions documentation to tmp directory
|
|
173
145
|
*/
|
|
174
|
-
function writeTmpInstructions(workspaceRoot
|
|
146
|
+
function writeTmpInstructions(workspaceRoot) {
|
|
175
147
|
const tmpDir = path.join(workspaceRoot, TMP_DIR);
|
|
176
148
|
const mdPath = path.join(tmpDir, TMP_MD_FILE);
|
|
177
|
-
|
|
178
149
|
fs.mkdirSync(tmpDir, { recursive: true });
|
|
179
150
|
fs.writeFileSync(mdPath, METHODSIZE_DOC_CONTENT);
|
|
180
|
-
|
|
181
151
|
return mdPath;
|
|
182
152
|
}
|
|
183
|
-
|
|
184
153
|
/**
|
|
185
154
|
* Get changed TypeScript files between base and head (or working tree if head not specified).
|
|
186
155
|
* Uses `git diff base [head]` to match what `nx affected` does.
|
|
187
156
|
* When head is NOT specified, also includes untracked files (matching nx affected behavior).
|
|
188
157
|
*/
|
|
189
|
-
function getChangedTypeScriptFiles(workspaceRoot
|
|
158
|
+
function getChangedTypeScriptFiles(workspaceRoot, base, head) {
|
|
190
159
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
191
160
|
try {
|
|
192
161
|
// If head is specified, diff base to head; otherwise diff base to working tree
|
|
193
162
|
const diffTarget = head ? `${base} ${head}` : base;
|
|
194
|
-
const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {
|
|
163
|
+
const output = (0, child_process_1.execSync)(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {
|
|
195
164
|
cwd: workspaceRoot,
|
|
196
165
|
encoding: 'utf-8',
|
|
197
166
|
});
|
|
@@ -199,13 +168,12 @@ function getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: s
|
|
|
199
168
|
.trim()
|
|
200
169
|
.split('\n')
|
|
201
170
|
.filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
|
|
202
|
-
|
|
203
171
|
// When comparing to working tree (no head specified), also include untracked files
|
|
204
172
|
// This matches what nx affected does: "All modified files not yet committed or tracked will also be added"
|
|
205
173
|
if (!head) {
|
|
206
174
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
207
175
|
try {
|
|
208
|
-
const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {
|
|
176
|
+
const untrackedOutput = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {
|
|
209
177
|
cwd: workspaceRoot,
|
|
210
178
|
encoding: 'utf-8',
|
|
211
179
|
});
|
|
@@ -216,45 +184,43 @@ function getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: s
|
|
|
216
184
|
// Merge and dedupe
|
|
217
185
|
const allFiles = new Set([...changedFiles, ...untrackedFiles]);
|
|
218
186
|
return Array.from(allFiles);
|
|
219
|
-
}
|
|
187
|
+
}
|
|
188
|
+
catch (err) {
|
|
220
189
|
//const error = toError(err);
|
|
221
190
|
// If ls-files fails, just return the changed files
|
|
222
191
|
return changedFiles;
|
|
223
192
|
}
|
|
224
193
|
}
|
|
225
|
-
|
|
226
194
|
return changedFiles;
|
|
227
|
-
}
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
228
197
|
//const error = toError(err);
|
|
229
198
|
return [];
|
|
230
199
|
}
|
|
231
200
|
}
|
|
232
|
-
|
|
233
201
|
/**
|
|
234
202
|
* Get the diff content for a specific file between base and head (or working tree if head not specified).
|
|
235
203
|
* Uses `git diff base [head]` to match what `nx affected` does.
|
|
236
204
|
* For untracked files, returns the entire file content as additions.
|
|
237
205
|
*/
|
|
238
|
-
function getFileDiff(workspaceRoot
|
|
206
|
+
function getFileDiff(workspaceRoot, file, base, head) {
|
|
239
207
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
240
208
|
try {
|
|
241
209
|
// If head is specified, diff base to head; otherwise diff base to working tree
|
|
242
210
|
const diffTarget = head ? `${base} ${head}` : base;
|
|
243
|
-
const diff = execSync(`git diff ${diffTarget} -- "${file}"`, {
|
|
211
|
+
const diff = (0, child_process_1.execSync)(`git diff ${diffTarget} -- "${file}"`, {
|
|
244
212
|
cwd: workspaceRoot,
|
|
245
213
|
encoding: 'utf-8',
|
|
246
214
|
});
|
|
247
|
-
|
|
248
215
|
// If diff is empty and we're comparing to working tree, check if it's an untracked file
|
|
249
216
|
if (!diff && !head) {
|
|
250
217
|
const fullPath = path.join(workspaceRoot, file);
|
|
251
218
|
if (fs.existsSync(fullPath)) {
|
|
252
219
|
// Check if file is untracked
|
|
253
|
-
const isUntracked = execSync(`git ls-files --others --exclude-standard "${file}"`, {
|
|
220
|
+
const isUntracked = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard "${file}"`, {
|
|
254
221
|
cwd: workspaceRoot,
|
|
255
222
|
encoding: 'utf-8',
|
|
256
223
|
}).trim();
|
|
257
|
-
|
|
258
224
|
if (isUntracked) {
|
|
259
225
|
// For untracked files, treat entire content as additions
|
|
260
226
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
@@ -264,21 +230,19 @@ function getFileDiff(workspaceRoot: string, file: string, base: string, head?: s
|
|
|
264
230
|
}
|
|
265
231
|
}
|
|
266
232
|
}
|
|
267
|
-
|
|
268
233
|
return diff;
|
|
269
|
-
}
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
270
236
|
//const error = toError(err);
|
|
271
237
|
return '';
|
|
272
238
|
}
|
|
273
239
|
}
|
|
274
|
-
|
|
275
240
|
/**
|
|
276
241
|
* Parse diff to find newly added method signatures
|
|
277
242
|
*/
|
|
278
|
-
function findNewMethodSignaturesInDiff(diffContent
|
|
279
|
-
const newMethods = new Set
|
|
243
|
+
function findNewMethodSignaturesInDiff(diffContent) {
|
|
244
|
+
const newMethods = new Set();
|
|
280
245
|
const lines = diffContent.split('\n');
|
|
281
|
-
|
|
282
246
|
// Patterns to match method definitions
|
|
283
247
|
const patterns = [
|
|
284
248
|
// [export] [async] function methodName( - most explicit, check first
|
|
@@ -290,7 +254,6 @@ function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {
|
|
|
290
254
|
// class method: [public/private/protected] [static] [async] methodName( - but NOT constructor, if, for, while, etc.
|
|
291
255
|
/^\+\s*(?:(?:public|private|protected)\s+)?(?:static\s+)?(?:async\s+)?(\w+)\s*\(/,
|
|
292
256
|
];
|
|
293
|
-
|
|
294
257
|
for (const line of lines) {
|
|
295
258
|
if (line.startsWith('+') && !line.startsWith('+++')) {
|
|
296
259
|
for (const pattern of patterns) {
|
|
@@ -306,15 +269,13 @@ function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {
|
|
|
306
269
|
}
|
|
307
270
|
}
|
|
308
271
|
}
|
|
309
|
-
|
|
310
272
|
return newMethods;
|
|
311
273
|
}
|
|
312
|
-
|
|
313
274
|
/**
|
|
314
275
|
* Check if a line contains a webpieces-disable comment that exempts from new method validation.
|
|
315
276
|
* Both max-lines-new-methods AND max-lines-modified are accepted here.
|
|
316
277
|
*/
|
|
317
|
-
function hasDisableComment(lines
|
|
278
|
+
function hasDisableComment(lines, lineNumber) {
|
|
318
279
|
// Check the line before the method (lineNumber is 1-indexed, array is 0-indexed)
|
|
319
280
|
// We need to check a few lines before in case there's JSDoc or decorators
|
|
320
281
|
const startCheck = Math.max(0, lineNumber - 5);
|
|
@@ -333,39 +294,37 @@ function hasDisableComment(lines: string[], lineNumber: number): boolean {
|
|
|
333
294
|
}
|
|
334
295
|
return false;
|
|
335
296
|
}
|
|
336
|
-
|
|
337
297
|
/**
|
|
338
298
|
* Parse a TypeScript file and find methods with their line counts
|
|
339
299
|
*/
|
|
340
300
|
// webpieces-disable max-lines-new-methods -- AST traversal requires inline visitor function
|
|
341
|
-
function findMethodsInFile(filePath
|
|
301
|
+
function findMethodsInFile(filePath, workspaceRoot) {
|
|
342
302
|
const fullPath = path.join(workspaceRoot, filePath);
|
|
343
|
-
if (!fs.existsSync(fullPath))
|
|
344
|
-
|
|
303
|
+
if (!fs.existsSync(fullPath))
|
|
304
|
+
return [];
|
|
345
305
|
const content = fs.readFileSync(fullPath, 'utf-8');
|
|
346
306
|
const fileLines = content.split('\n');
|
|
347
307
|
const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let
|
|
353
|
-
let startLine: number | undefined;
|
|
354
|
-
let endLine: number | undefined;
|
|
355
|
-
|
|
308
|
+
const methods = [];
|
|
309
|
+
function visit(node) {
|
|
310
|
+
let methodName;
|
|
311
|
+
let startLine;
|
|
312
|
+
let endLine;
|
|
356
313
|
if (ts.isMethodDeclaration(node) && node.name) {
|
|
357
314
|
methodName = node.name.getText(sourceFile);
|
|
358
315
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
359
316
|
const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
|
|
360
317
|
startLine = start.line + 1;
|
|
361
318
|
endLine = end.line + 1;
|
|
362
|
-
}
|
|
319
|
+
}
|
|
320
|
+
else if (ts.isFunctionDeclaration(node) && node.name) {
|
|
363
321
|
methodName = node.name.getText(sourceFile);
|
|
364
322
|
const start = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
365
323
|
const end = sourceFile.getLineAndCharacterOfPosition(node.getEnd());
|
|
366
324
|
startLine = start.line + 1;
|
|
367
325
|
endLine = end.line + 1;
|
|
368
|
-
}
|
|
326
|
+
}
|
|
327
|
+
else if (ts.isArrowFunction(node)) {
|
|
369
328
|
// Check if it's assigned to a variable
|
|
370
329
|
if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {
|
|
371
330
|
methodName = node.parent.name.getText(sourceFile);
|
|
@@ -375,7 +334,6 @@ function findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[
|
|
|
375
334
|
endLine = end.line + 1;
|
|
376
335
|
}
|
|
377
336
|
}
|
|
378
|
-
|
|
379
337
|
if (methodName && startLine !== undefined && endLine !== undefined) {
|
|
380
338
|
methods.push({
|
|
381
339
|
name: methodName,
|
|
@@ -384,40 +342,27 @@ function findMethodsInFile(filePath: string, workspaceRoot: string): MethodInfo[
|
|
|
384
342
|
hasDisableComment: hasDisableComment(fileLines, startLine),
|
|
385
343
|
});
|
|
386
344
|
}
|
|
387
|
-
|
|
388
345
|
ts.forEachChild(node, visit);
|
|
389
346
|
}
|
|
390
|
-
|
|
391
347
|
visit(sourceFile);
|
|
392
348
|
return methods;
|
|
393
349
|
}
|
|
394
|
-
|
|
395
350
|
/**
|
|
396
351
|
* Find new methods that exceed the line limit
|
|
397
352
|
*/
|
|
398
|
-
function findViolations(
|
|
399
|
-
|
|
400
|
-
changedFiles: string[],
|
|
401
|
-
base: string,
|
|
402
|
-
limit: number,
|
|
403
|
-
disableAllowed: boolean,
|
|
404
|
-
head?: string
|
|
405
|
-
): MethodViolation[] {
|
|
406
|
-
const violations: MethodViolation[] = [];
|
|
407
|
-
|
|
353
|
+
function findViolations(workspaceRoot, changedFiles, base, limit, disableAllowed, head) {
|
|
354
|
+
const violations = [];
|
|
408
355
|
for (const file of changedFiles) {
|
|
409
356
|
// Get the diff to find which methods are NEW (not just modified)
|
|
410
357
|
const diff = getFileDiff(workspaceRoot, file, base, head);
|
|
411
358
|
const newMethodNames = findNewMethodSignaturesInDiff(diff);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
359
|
+
if (newMethodNames.size === 0)
|
|
360
|
+
continue;
|
|
415
361
|
// Parse the current file to get method line counts
|
|
416
362
|
const methods = findMethodsInFile(file, workspaceRoot);
|
|
417
|
-
|
|
418
363
|
for (const method of methods) {
|
|
419
|
-
if (!newMethodNames.has(method.name))
|
|
420
|
-
|
|
364
|
+
if (!newMethodNames.has(method.name))
|
|
365
|
+
continue;
|
|
421
366
|
if (method.lines > limit) {
|
|
422
367
|
if (!disableAllowed) {
|
|
423
368
|
// No escape possible
|
|
@@ -429,7 +374,8 @@ function findViolations(
|
|
|
429
374
|
isNew: true,
|
|
430
375
|
limit,
|
|
431
376
|
});
|
|
432
|
-
}
|
|
377
|
+
}
|
|
378
|
+
else if (!method.hasDisableComment) {
|
|
433
379
|
// Escape allowed but not present
|
|
434
380
|
violations.push({
|
|
435
381
|
file,
|
|
@@ -443,53 +389,50 @@ function findViolations(
|
|
|
443
389
|
}
|
|
444
390
|
}
|
|
445
391
|
}
|
|
446
|
-
|
|
447
392
|
return violations;
|
|
448
393
|
}
|
|
449
|
-
|
|
450
394
|
/**
|
|
451
395
|
* Auto-detect the base branch by finding the merge-base with origin/main.
|
|
452
396
|
* This allows the executor to run even when NX_BASE isn't set (e.g., via dependsOn).
|
|
453
397
|
*/
|
|
454
|
-
function detectBase(workspaceRoot
|
|
398
|
+
function detectBase(workspaceRoot) {
|
|
455
399
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
456
400
|
try {
|
|
457
401
|
// First, try to get merge-base with origin/main
|
|
458
|
-
const mergeBase = execSync('git merge-base HEAD origin/main', {
|
|
402
|
+
const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD origin/main', {
|
|
459
403
|
cwd: workspaceRoot,
|
|
460
404
|
encoding: 'utf-8',
|
|
461
405
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
462
406
|
}).trim();
|
|
463
|
-
|
|
464
407
|
if (mergeBase) {
|
|
465
408
|
return mergeBase;
|
|
466
409
|
}
|
|
467
|
-
}
|
|
410
|
+
}
|
|
411
|
+
catch (err) {
|
|
468
412
|
//const error = toError(err);
|
|
469
413
|
// origin/main might not exist, try main
|
|
470
414
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
471
415
|
try {
|
|
472
|
-
const mergeBase = execSync('git merge-base HEAD main', {
|
|
416
|
+
const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD main', {
|
|
473
417
|
cwd: workspaceRoot,
|
|
474
418
|
encoding: 'utf-8',
|
|
475
419
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
476
420
|
}).trim();
|
|
477
|
-
|
|
478
421
|
if (mergeBase) {
|
|
479
422
|
return mergeBase;
|
|
480
423
|
}
|
|
481
|
-
}
|
|
424
|
+
}
|
|
425
|
+
catch (err2) {
|
|
482
426
|
//const error2 = toError(err2);
|
|
483
427
|
// Ignore - will return null
|
|
484
428
|
}
|
|
485
429
|
}
|
|
486
430
|
return null;
|
|
487
431
|
}
|
|
488
|
-
|
|
489
432
|
/**
|
|
490
433
|
* Report violations to the user with helpful instructions
|
|
491
434
|
*/
|
|
492
|
-
function reportViolations(violations
|
|
435
|
+
function reportViolations(violations, limit, disableAllowed) {
|
|
493
436
|
console.error('');
|
|
494
437
|
console.error('\u274c New methods exceed ' + limit + ' line limit!');
|
|
495
438
|
console.error('');
|
|
@@ -498,10 +441,10 @@ function reportViolations(violations: MethodViolation[], limit: number, disableA
|
|
|
498
441
|
console.error('');
|
|
499
442
|
console.error('\u26a0\ufe0f *** READ .webpieces/instruct-ai/webpieces.methodsize.md for detailed guidance on how to fix this easily *** \u26a0\ufe0f');
|
|
500
443
|
console.error('');
|
|
501
|
-
|
|
502
444
|
if (disableAllowed) {
|
|
503
445
|
console.error('\u26a0\ufe0f VIOLATIONS (can use escape hatch):');
|
|
504
|
-
}
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
505
448
|
console.error('\ud83d\udeab VIOLATIONS (cannot be bypassed with disable comment):');
|
|
506
449
|
}
|
|
507
450
|
console.error('');
|
|
@@ -512,83 +455,70 @@ function reportViolations(violations: MethodViolation[], limit: number, disableA
|
|
|
512
455
|
console.error('');
|
|
513
456
|
if (disableAllowed) {
|
|
514
457
|
console.error(' Use escape: // webpieces-disable max-lines-new-methods -- [your reason]');
|
|
515
|
-
}
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
516
460
|
console.error(' These methods MUST be refactored - no escape hatch available (disableAllowed=false).');
|
|
517
461
|
}
|
|
518
462
|
console.error('');
|
|
519
463
|
}
|
|
520
|
-
|
|
521
|
-
export default async function runValidator(
|
|
522
|
-
options: ValidateNewMethodsOptions,
|
|
523
|
-
workspaceRoot: string
|
|
524
|
-
): Promise<ExecutorResult> {
|
|
464
|
+
async function runValidator(options, workspaceRoot) {
|
|
525
465
|
const limit = options.limit ?? 80;
|
|
526
|
-
const mode
|
|
466
|
+
const mode = options.mode ?? 'NEW_AND_MODIFIED_METHODS';
|
|
527
467
|
const disableAllowed = options.disableAllowed ?? true;
|
|
528
|
-
|
|
529
468
|
// Skip validation entirely if mode is OFF
|
|
530
469
|
if (mode === 'OFF') {
|
|
531
470
|
console.log('\n\u23ed\ufe0f Skipping new method validation (mode: OFF)');
|
|
532
471
|
console.log('');
|
|
533
472
|
return { success: true };
|
|
534
473
|
}
|
|
535
|
-
|
|
536
474
|
// Check if running in affected mode via NX_BASE, or auto-detect
|
|
537
475
|
// If NX_HEAD is set (via nx affected --head=X), use it; otherwise compare to working tree
|
|
538
476
|
let base = process.env['NX_BASE'];
|
|
539
477
|
const head = process.env['NX_HEAD'];
|
|
540
|
-
|
|
541
478
|
if (!base) {
|
|
542
479
|
// Try to auto-detect base from git merge-base
|
|
543
480
|
base = detectBase(workspaceRoot) ?? undefined;
|
|
544
|
-
|
|
545
481
|
if (!base) {
|
|
546
482
|
console.log('\n\u23ed\ufe0f Skipping new method validation (could not detect base branch)');
|
|
547
483
|
console.log(' To run explicitly: nx affected --target=validate-new-methods --base=origin/main');
|
|
548
484
|
console.log('');
|
|
549
485
|
return { success: true };
|
|
550
486
|
}
|
|
551
|
-
|
|
552
487
|
console.log('\n\ud83d\udccf Validating New Method Sizes (auto-detected base)\n');
|
|
553
|
-
}
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
554
490
|
console.log('\n\ud83d\udccf Validating New Method Sizes\n');
|
|
555
491
|
}
|
|
556
|
-
|
|
557
492
|
console.log(` Base: ${base}`);
|
|
558
493
|
console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);
|
|
559
494
|
console.log(` Mode: ${mode}`);
|
|
560
495
|
console.log(` Limit for new methods: ${limit} lines (${disableAllowed ? 'can escape' : 'NO escape possible'})`);
|
|
561
496
|
console.log('');
|
|
562
|
-
|
|
563
497
|
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
564
498
|
try {
|
|
565
499
|
// Get changed TypeScript files (base to head, or working tree if head not set)
|
|
566
500
|
const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);
|
|
567
|
-
|
|
568
501
|
if (changedFiles.length === 0) {
|
|
569
502
|
console.log('\u2705 No TypeScript files changed');
|
|
570
503
|
return { success: true };
|
|
571
504
|
}
|
|
572
|
-
|
|
573
505
|
console.log(`\ud83d\udcc2 Checking ${changedFiles.length} changed file(s)...`);
|
|
574
|
-
|
|
575
506
|
// Find violations
|
|
576
507
|
const violations = findViolations(workspaceRoot, changedFiles, base, limit, disableAllowed, head);
|
|
577
|
-
|
|
578
508
|
if (violations.length === 0) {
|
|
579
509
|
console.log('\u2705 All new methods are within ' + limit + ' lines');
|
|
580
510
|
return { success: true };
|
|
581
511
|
}
|
|
582
|
-
|
|
583
512
|
// Write instructions file and report violations
|
|
584
513
|
writeTmpInstructions(workspaceRoot);
|
|
585
514
|
reportViolations(violations, limit, disableAllowed);
|
|
586
|
-
|
|
587
515
|
return { success: false };
|
|
588
|
-
}
|
|
516
|
+
}
|
|
517
|
+
catch (err) {
|
|
589
518
|
//const error = toError(err);
|
|
590
519
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
591
520
|
console.error('\u274c New method validation failed:', error.message);
|
|
592
521
|
return { success: false };
|
|
593
522
|
}
|
|
594
523
|
}
|
|
524
|
+
//# sourceMappingURL=validate-new-methods.js.map
|