[Question] Unresolved compilation problem: The method of(String) is undefined for the type List #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024-2026 the original author or authors. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# https://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Auto Comment for Clarity | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
auto-comment: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
issues: write | |
discussions: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Analyze issue and create comment | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
// Handle both issues and discussions | |
let title, body, number, targetType, targetUrl; | |
if (context.eventName === 'issues') { | |
number = context.issue.number; | |
title = context.payload.issue.title || ''; | |
body = context.payload.issue.body || ''; | |
targetType = 'issue'; | |
targetUrl = context.payload.issue.html_url; | |
} else if (context.eventName === 'discussions') { | |
number = context.payload.discussion.number; | |
title = context.payload.discussion.title || ''; | |
body = context.payload.discussion.body || ''; | |
targetType = 'discussion'; | |
targetUrl = context.payload.discussion.html_url; | |
} else { | |
console.log('Unsupported event type:', context.eventName); | |
return; | |
} | |
console.log('Target Type:', targetType); | |
console.log('Target Number:', number); | |
console.log('Title:', title); | |
console.log('Body:', body); | |
// Analyze what's missing specifically | |
const hasDetailedDescription = body.length > 50 && !body.includes('No response'); | |
const hasStepsToReproduce = body.toLowerCase().includes('步骤') || body.toLowerCase().includes('重现') || body.toLowerCase().includes('reproduce'); | |
const hasEnvironmentInfo = body.toLowerCase().includes('环境') || body.toLowerCase().includes('版本') || body.toLowerCase().includes('version'); | |
const hasExpectedBehavior = body.toLowerCase().includes('期望') || body.toLowerCase().includes('expected'); | |
const hasErrorDetails = body.toLowerCase().includes('错误') || body.toLowerCase().includes('error') || body.toLowerCase().includes('异常'); | |
// Check if this looks like a bug report that needs more info | |
const isBugReport = title.toLowerCase().includes('bug') || title.toLowerCase().includes('错误'); | |
const hasVeryShortDescription = body.trim().length < 30 || body === 'No response' || body.includes('这个怎么用') || body.includes('不知道为什么'); | |
// Generate dynamic comment based on what's missing | |
const missingItems = []; | |
const suggestions = []; | |
if (hasVeryShortDescription) { | |
missingItems.push('详细的问题描述'); | |
suggestions.push('请详细描述您遇到的具体问题,而不是简单的一句话'); | |
} | |
if (isBugReport && !hasStepsToReproduce) { | |
missingItems.push('重现步骤'); | |
suggestions.push('请提供能够重现问题的具体操作步骤'); | |
} | |
if (isBugReport && !hasErrorDetails) { | |
missingItems.push('错误信息'); | |
suggestions.push('请提供完整的错误信息、异常堆栈或错误日志'); | |
} | |
if (isBugReport && !hasEnvironmentInfo) { | |
missingItems.push('环境信息'); | |
suggestions.push('请提供 mem4j 版本、Java 版本、操作系统等环境信息'); | |
} | |
if (!hasExpectedBehavior && isBugReport) { | |
missingItems.push('期望行为'); | |
suggestions.push('请描述您期望的正确行为应该是什么'); | |
} | |
// Only comment if there are missing items | |
if (missingItems.length > 0) { | |
let commentLines = [ | |
'👋 感谢您提交这个 ' + (targetType === 'issue' ? 'issue' : 'discussion') + '!', | |
'', | |
'为了更好地帮助您解决问题,我发现以下信息需要补充:', | |
'' | |
]; | |
// Add specific missing items | |
missingItems.forEach((item, index) => { | |
commentLines.push(`${index + 1}. **${item}** - ${suggestions[index]}`); | |
}); | |
commentLines.push(''); | |
commentLines.push('请编辑您的原始' + (targetType === 'issue' ? 'issue' : 'discussion') + '来添加这些信息,这将帮助我们更快地定位和解决问题。🙏'); | |
commentLines.push(''); | |
commentLines.push('---'); | |
commentLines.push('*这是一个自动生成的提醒,旨在提高' + (targetType === 'issue' ? 'issue' : 'discussion') + '的质量和解决效率。*'); | |
const commentBody = commentLines.join('\n'); | |
// Create comment based on target type | |
if (targetType === 'issue') { | |
await github.rest.issues.createComment({ | |
owner, | |
repo, | |
issue_number: number, | |
body: commentBody | |
}); | |
} else if (targetType === 'discussion') { | |
// Use the correct GitHub REST API for discussion comments | |
await github.request('POST /repos/{owner}/{repo}/discussions/{discussion_number}/comments', { | |
owner, | |
repo, | |
discussion_number: number, | |
body: commentBody | |
}); | |
} | |
console.log('Posted targeted clarity request comment to ' + targetType + ' #' + number); | |
console.log('Missing items:', missingItems.join(', ')); | |
} else { | |
console.log(targetType + ' has sufficient information, no comment needed'); | |
} |