Skip to content

🧹 [Code Health] Extract magic number for bio length into a constant#337

Open
is0692vs wants to merge 4 commits into
mainfrom
fix-magic-number-bio-length-12727248390082554642
Open

🧹 [Code Health] Extract magic number for bio length into a constant#337
is0692vs wants to merge 4 commits into
mainfrom
fix-magic-number-bio-length-12727248390082554642

Conversation

@is0692vs

@is0692vs is0692vs commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🎯 What: The hardcoded magic number 110 used for truncating the bio length in src/lib/cardElements.tsx has been extracted into a top-level constant MAX_BIO_LENGTH.

💡 Why: By extracting this hardcoded number into a well-named constant, it improves the maintainability and readability of the codebase. It clearly defines the intent of the number and makes it easier to update the bio length limit consistently across the file in the future.

Verification:

  • The codebase linting (npm run lint) passed.
  • The full test suite (npm run test) successfully passed.
  • The unit test specifically targeting src/lib/cardElements.tsx (src/lib/__tests__/cardElements.test.tsx) was run and passed.

Result: The code health issue is resolved without changing the underlying functionality, resulting in a cleaner and more maintainable code structure.


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

Greptile Summary

バイオの文字数制限として使用されていたマジックナンバー 110 を、MAX_BIO_LENGTH という名前付き定数に抽出するリファクタリングです。機能的な変更は一切ありません。

  • src/lib/cardElements.tsx のファイル先頭に const MAX_BIO_LENGTH = 110; を追加し、createBioBlock 関数内の2箇所のハードコードされた 110 を置き換えました。
  • コードの可読性と保守性が向上し、将来的に制限値を変更する際の一元管理が容易になります。

Confidence Score: 5/5

変更はマジックナンバーの抽出のみで、ロジックに一切手を加えていないため、安全にマージできます。

変更箇所は MAX_BIO_LENGTH 定数の導入と、それを参照する2行への置き換えのみです。比較条件とスライスの両方に同じ定数が使われており、リファクタリング前後で動作は完全に同一です。

特に注意が必要なファイルはありません。

Important Files Changed

Filename Overview
src/lib/cardElements.tsx マジックナンバー 110 を定数 MAX_BIO_LENGTH に抽出。機能的な変更はなし。

Reviews (1): Last reviewed commit: "refactor: extract magic number 110 into ..." | Re-trigger Greptile

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.

@vercel

vercel Bot commented Jun 6, 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 Jun 6, 2026 3:36am

@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 →

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

More reviews will be available in 37 minutes and 21 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 62d0a33a-6ebb-43d8-930d-e4ff1d845a0c

📥 Commits

Reviewing files that changed from the base of the PR and between 4e9c001 and 0c82c4e.

📒 Files selected for processing (2)
  • src/lib/__tests__/cardElements.test.tsx
  • src/lib/cardElements.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-magic-number-bio-length-12727248390082554642

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 and usage tips.

@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 refactors src/lib/cardElements.tsx by extracting the magic number 110 into a constant MAX_BIO_LENGTH. A review comment suggests using Array.from() when slicing the bio string to prevent splitting surrogate pairs (such as emojis) and causing rendering issues.

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/cardElements.tsx
Comment on lines +103 to 105
{data.profile.bio.length > MAX_BIO_LENGTH
? `${data.profile.bio.slice(0, MAX_BIO_LENGTH)}...`
: data.profile.bio}

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

Truncating the bio string using standard String.prototype.slice can split surrogate pairs (such as emojis or certain multi-byte characters) if the truncation point falls in the middle of one. This can result in rendering malformed characters in the UI.

Using Array.from() or the spread operator ([...]) ensures that the string is sliced by Unicode code points rather than UTF-16 code units, preserving emojis and other multi-byte characters correctly.

Suggested change
{data.profile.bio.length > MAX_BIO_LENGTH
? `${data.profile.bio.slice(0, MAX_BIO_LENGTH)}...`
: data.profile.bio}
{data.profile.bio.length > MAX_BIO_LENGTH
? Array.from(data.profile.bio).slice(0, MAX_BIO_LENGTH).join("") + "..."
: data.profile.bio}

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@pull-request-size pull-request-size Bot added size/M and removed size/XS labels Jun 6, 2026
google-labs-jules Bot and others added 2 commits June 6, 2026 03:29
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant