Repository navigation
test(ci): AI 审查飞书通知测试(勿合并) #19
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Temporary file for testing the ai-review Feishu notification. This pull request will be closed without merging. | ||
| export function average(items) { | ||
| let total = 0; | ||
| for (let i = 0; i <= items.length; i++) { | ||
| total += items[i].value; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 低 缺少输入校验:如果某个元素的 |
||
| } | ||
| return total / items.length; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 中 空数组未处理:修复越界后, if (items.length === 0) {
throw new RangeError('items must not be empty');
} |
||
| } | ||
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.
🔴 高 循环边界越界(off-by-one):条件
i <= items.length会在最后一轮访问items[items.length],该值为undefined,第 5 行读取.value时会抛出TypeError: Cannot read properties of undefined。只要传入数组,函数必然抛错,无法返回结果。建议改为
i < items.length,或直接使用: