Skip to content

🧹 Refactor fetchStarredRepos for better readability#455

Open
is0692vs wants to merge 1 commit into
mainfrom
refactor-fetch-starred-repos-16864096372775715831
Open

🧹 Refactor fetchStarredRepos for better readability#455
is0692vs wants to merge 1 commit into
mainfrom
refactor-fetch-starred-repos-16864096372775715831

Conversation

@is0692vs

@is0692vs is0692vs commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Extracted topic and language aggregation loops into their own functions (aggregateTopics and aggregateLanguages) to improve readability and maintainability.


PR created automatically by Jules for task 16864096372775715831 started by @is0692vs

Greptile Summary

PR のメイン変更は fetchStarredRepos 内のトピック・言語集計ロジックを aggregateTopics / aggregateLanguages という独立した関数に切り出すリファクタリングです。その他の差分はほぼすべて Prettier による整形(末尾カンマ追加、長行の折り返しなど)で、動作への影響はありません。

  • aggregateTopics / aggregateLanguages を抽出し、fetchStarredRepos の本体をシンプルにした。ロジック自体の変更はなく、出力結果は同一。
  • リファクタリングの副作用として allStarred への走査が1回から2回に増加したが、最大200件のデータ量なので実用上の影響は無視できる。
  • ファイル全体で Prettier スタイルに統一(末尾カンマ、関数シグネチャの折り返しなど)。

Confidence Score: 4/5

ロジックの正確性は維持されており、マージして問題ないリファクタリング PR です。

変更の大部分は Prettier によるフォーマット整形で、動作への影響はありません。aggregateTopics / aggregateLanguages の抽出も出力結果は元のコードと同一です。唯一の指摘点は allStarred を2回走査するようになった点ですが、データ量が最大200件のため実害はありません。

特に問題のあるファイルはありません。src/lib/github.ts の aggregateTopics / aggregateLanguages 付近を念のため確認するとよいでしょう。

Important Files Changed

Filename Overview
src/lib/github.ts fetchStarredRepos から aggregateTopics・aggregateLanguages を抽出するリファクタリングと、全体的な Prettier フォーマット統一。ロジックの正確性は維持されており、唯一の注意点は allStarred の二重イテレーションが導入された点(実用上影響なし)。
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/lib/github.ts:697-698
**リストの二重イテレーション**

リファクタリングにより `allStarred``aggregateTopics``aggregateLanguages` の2つの関数でそれぞれ走査するようになりました。元のコードは1回のループでトピックと言語を同時に集計していたため、イテレーション数が2倍になっています。最大200件(100件×2ページ)という規模なので実際のパフォーマンス影響はほぼ無視できますが、可読性のために行ったリファクタリングで計算量が増えている点は把握しておくとよいでしょう。

Reviews (1): Last reviewed commit: "refactor: extract aggregation loops in f..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
github-user-summary Ignored Ignored Jul 10, 2026 6:59am

@dosubot dosubot Bot added the enhancement New feature or request label Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@is0692vs, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 41 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 41f25128-8d1b-45b0-bfdc-347d763ffe10

📥 Commits

Reviewing files that changed from the base of the PR and between 05bc250 and 9e9b759.

📒 Files selected for processing (1)
  • src/lib/github.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-fetch-starred-repos-16864096372775715831

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.15686% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lib/github.ts 92.15% 0 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/lib/github.ts
Comment on lines +697 to +698
const topicCounts = aggregateTopics(allStarred);
const languageCounts = aggregateLanguages(allStarred);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 リストの二重イテレーション

リファクタリングにより allStarredaggregateTopicsaggregateLanguages の2つの関数でそれぞれ走査するようになりました。元のコードは1回のループでトピックと言語を同時に集計していたため、イテレーション数が2倍になっています。最大200件(100件×2ページ)という規模なので実際のパフォーマンス影響はほぼ無視できますが、可読性のために行ったリファクタリングで計算量が増えている点は把握しておくとよいでしょう。

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/lib/github.ts
Line: 697-698

Comment:
**リストの二重イテレーション**

リファクタリングにより `allStarred``aggregateTopics``aggregateLanguages` の2つの関数でそれぞれ走査するようになりました。元のコードは1回のループでトピックと言語を同時に集計していたため、イテレーション数が2倍になっています。最大200件(100件×2ページ)という規模なので実際のパフォーマンス影響はほぼ無視できますが、可読性のために行ったリファクタリングで計算量が増えている点は把握しておくとよいでしょう。

How can I resolve this? If you propose a fix, please make it concise.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request primarily applies formatting updates across src/lib/github.ts and refactors fetchStarredRepos by extracting aggregateTopics and aggregateLanguages helper functions. The review feedback highlights a potential out-of-bounds array access in fetchActivity where the manually parsed hour value is used directly as an index without validation, and suggests adding a safety check to handle malformed input strings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/lib/github.ts
Comment on lines +807 to +809
const hour =
(createdAt.charCodeAt(11) - charCodeZero) * 10 +
(createdAt.charCodeAt(12) - charCodeZero);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manually parsed hour value is used directly as an array index for heatmap[day]. If the createdAt string is malformed or unexpected, hour could be NaN or outside the valid range of [0, 23], leading to out-of-bounds access or runtime errors. Please validate the parsed hour value before using it as an index.

Suggested change
const hour =
(createdAt.charCodeAt(11) - charCodeZero) * 10 +
(createdAt.charCodeAt(12) - charCodeZero);
const parsedHour =
(createdAt.charCodeAt(11) - charCodeZero) * 10 +
(createdAt.charCodeAt(12) - charCodeZero);
const hour = parsedHour >= 0 && parsedHour < 24 ? parsedHour : 0;
References
  1. Validate manually parsed numeric values before using them as array indices to prevent out-of-bounds access and data corruption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant