-
Notifications
You must be signed in to change notification settings - Fork 0
Fix lint automation workflow duplication and enhance issue titles with region context #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -459,11 +459,13 @@ All instances of \`${ruleId}\` violations have been fixed. This issue is now aut | |||||
| const category = fileIssues[0].category; | ||||||
| const severity = fileIssues.some(issue => issue.severity === 'error') ? 'error' : 'warning'; | ||||||
|
|
||||||
| // Create title using filename as requested by user | ||||||
| // Create enhanced title with region context for API verify files | ||||||
| const enhancedTitle = this.generateEnhancedTitle(filePath, fileName); | ||||||
|
|
||||||
| groups.push({ | ||||||
| category, | ||||||
| title: fileName, | ||||||
| body: this.generateFileIssueBody(fileName, filePath, fileIssues), | ||||||
| title: enhancedTitle, | ||||||
| body: this.generateFileIssueBody(enhancedTitle, filePath, fileIssues), | ||||||
| labels: [ | ||||||
| 'lint', | ||||||
| 'code-quality', | ||||||
|
|
@@ -477,6 +479,67 @@ All instances of \`${ruleId}\` violations have been fixed. This issue is now aut | |||||
| return groups; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Generates an enhanced title that includes region context for API verify files | ||||||
| * @param filePath - Full path to the file | ||||||
| * @param fileName - Base filename | ||||||
| * @returns Enhanced title with region context if applicable | ||||||
| */ | ||||||
| private generateEnhancedTitle(filePath: string, fileName: string): string { | ||||||
| // Check if this is a file in the API verify directory structure | ||||||
| const apiVerifyMatch = filePath.match(/app\/api\/verify\/([^\/]+)\/(.+)$/); | ||||||
|
|
||||||
| if (apiVerifyMatch) { | ||||||
| const regionFolder = apiVerifyMatch[1]; | ||||||
| const fileInRegion = apiVerifyMatch[2]; | ||||||
|
|
||||||
| // Convert region folder name to proper case for display | ||||||
| // e.g., "arizona" -> "Arizona", "districtofcolumbia" -> "District of Columbia" | ||||||
| const regionName = this.formatRegionName(regionFolder); | ||||||
|
|
||||||
| return `${regionName} - ${fileInRegion}`; | ||||||
| } | ||||||
|
|
||||||
| // For non-API verify files, return the original filename | ||||||
| return fileName; | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Formats region folder names into proper display names | ||||||
| * @param regionFolder - Raw folder name (e.g., "arizona", "districtofcolumbia") | ||||||
| * @returns Formatted region name (e.g., "Arizona", "District of Columbia") | ||||||
| */ | ||||||
| private formatRegionName(regionFolder: string): string { | ||||||
| // Handle special cases | ||||||
| const specialCases: Record<string, string> = { | ||||||
| 'districtofcolumbia': 'District of Columbia', | ||||||
| 'newhampshire': 'New Hampshire', | ||||||
| 'newjersey': 'New Jersey', | ||||||
| 'newmexico': 'New Mexico', | ||||||
| 'newyork': 'New York', | ||||||
| 'northcarolina': 'North Carolina', | ||||||
| 'northdakota': 'North Dakota', | ||||||
| 'rhodeisland': 'Rhode Island', | ||||||
| 'southcarolina': 'South Carolina', | ||||||
| 'southdakota': 'South Dakota', | ||||||
| 'westvirginia': 'West Virginia', | ||||||
| 'britishcolumbia': 'British Columbia', | ||||||
| 'newbrunswick': 'New Brunswick', | ||||||
| 'newfoundland&labrador': 'Newfoundland & Labrador', | ||||||
| 'novascotia': 'Nova Scotia', | ||||||
| 'princeedwardisland': 'Prince Edward Island', | ||||||
| 'puertorico': 'Puerto Rico' | ||||||
| }; | ||||||
|
Comment on lines
+514
to
+532
|
||||||
|
|
||||||
| // Check for special cases first | ||||||
| if (specialCases[regionFolder.toLowerCase()]) { | ||||||
| return specialCases[regionFolder.toLowerCase()]; | ||||||
| } | ||||||
|
|
||||||
| // For regular cases, just capitalize the first letter | ||||||
| return regionFolder.charAt(0).toUpperCase() + regionFolder.slice(1); | ||||||
| } | ||||||
|
|
||||||
| private generateSummaryIssueBody(report: IssueReport): string { | ||||||
| let body = `## 📊 Lint Analysis Summary\n\n`; | ||||||
|
|
||||||
|
|
@@ -681,14 +744,18 @@ All instances of \`${ruleId}\` violations have been fixed. This issue is now aut | |||||
| return body; | ||||||
| } | ||||||
|
|
||||||
| async checkExistingFileIssue(fileName: string): Promise<{ number: number; title: string; body: string } | null> { | ||||||
| async checkExistingFileIssue(enhancedTitle: string): Promise<{ number: number; title: string; body: string } | null> { | ||||||
| if (!this.token) return null; | ||||||
|
|
||||||
| try { | ||||||
| // Search for issues with the filename as title | ||||||
| const searchQuery = `repo:${this.owner}/${this.repo}+is:issue+is:open+"${fileName}"+label:lint+label:automated`; | ||||||
| // Search for issues with the enhanced title or just the filename | ||||||
| // This handles both old format (just filename) and new format (Region - filename) | ||||||
| const fileNamePart = enhancedTitle.includes(' - ') ? enhancedTitle.split(' - ')[1] : enhancedTitle; | ||||||
|
|
||||||
| const response = await fetch( | ||||||
| // First try exact match with enhanced title | ||||||
| let searchQuery = `repo:${this.owner}/${this.repo}+is:issue+is:open+"${enhancedTitle}"+label:lint+label:automated`; | ||||||
|
|
||||||
| let response = await fetch( | ||||||
| `${this.apiBase}/search/issues?q=${encodeURIComponent(searchQuery)}`, | ||||||
| { | ||||||
| headers: { | ||||||
|
|
@@ -703,9 +770,9 @@ All instances of \`${ruleId}\` violations have been fixed. This issue is now aut | |||||
| const data = await response.json(); | ||||||
| if (data.total_count > 0) { | ||||||
| // Find exact title match (case-insensitive) | ||||||
| const exactMatch = data.items.find((issue: any) => issue.title.toLowerCase() === fileName.toLowerCase()); | ||||||
| const exactMatch = data.items.find((issue: any) => issue.title.toLowerCase() === enhancedTitle.toLowerCase()); | ||||||
| if (exactMatch) { | ||||||
| console.log(`🔍 Found existing file-based issue for ${fileName}: #${exactMatch.number}`); | ||||||
| console.log(`🔍 Found existing file-based issue for ${enhancedTitle}: #${exactMatch.number}`); | ||||||
| return { | ||||||
| number: exactMatch.number, | ||||||
| title: exactMatch.title, | ||||||
|
|
@@ -714,14 +781,46 @@ All instances of \`${ruleId}\` violations have been fixed. This issue is now aut | |||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // If no exact match found, try searching for just the filename part (for backward compatibility) | ||||||
| if (fileNamePart !== enhancedTitle) { | ||||||
|
||||||
| if (fileNamePart !== enhancedTitle) { | |
| if (enhancedTitle.includes(' - ')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
generateFileIssueBodymethod is being called withenhancedTitleas the first parameter, but this might not be the intended behavior. Based on the context, the first parameter should likely be the originalfileNamesince the body generation might expect the actual filename rather than the enhanced display title.