Update Array Reduce Transformation docs and notebook#262
Conversation
myoshi2891
commented
Feb 10, 2026
- Add executable example and fix tsconfig in notebook
- Update README_react.html with SRI hashes, prod assets, and SVG fix
- Optimize Python reducer example in README.md
- Add executable example and fix tsconfig in notebook - Update README_react.html with SRI hashes, prod assets, and SVG fix - Optimize Python reducer example in README.md
📝 WalkthroughSummary by CodeRabbitリリースノート
WalkthroughArrayReduce実装のドキュメント、テストコード、およびUIアセットを更新。Python直接反復パターンへの移行、TypeScript実装の追加デモンストレーション、HTMLスクリプト属性の強化を含む。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
JavaScript/2626. Array Reduce Transformation/Claude Code Sonnet 4.5 extended/README.md (1)
218-223:⚠️ Potential issue | 🟡 Minor「不要な条件分岐の回避」セクションの ✅ 例が直接反復パターンと矛盾しています。
セクション1で
for num in numsを推奨していますが、このセクションの「✅ シンプル」例では依然としてfor i in range(len(nums))を使用しています。一貫性のため、こちらも直接反復に更新するか、「ここではインデックスアクセスの例として示している」旨の補足を追加してください。提案
# ✅ シンプル: ループが自然に処理 -for i in range(len(nums)): - # 空配列なら range(0) で即座に終了 - accumulator = fn(accumulator, nums[i]) +for num in nums: + # 空配列ならループ本体が実行されず即座に終了 + accumulator = fn(accumulator, num)
🤖 Fix all issues with AI agents
In `@JavaScript/2626`. Array Reduce Transformation/Claude Code Sonnet 4.5
extended/README_react.html:
- Line 341: The SVG viewBox height was reduced to 620 which may clip the
loop-back arrow path (reaching y=585) and its label (at y=600); update the
viewBox attribute (the "viewBox" value currently "0 0 840 620") to provide extra
bottom space (e.g., restore to "0 0 840 700" or increase to a height ≥ 640–700),
or alternatively shift the loop-back arrow path and label upward so their y
coordinates are well within the viewBox, then verify in a browser that the path
and text are not clipped.
- Around line 892-901: HTML includes incorrect SRI hashes for the Prism JS
scripts: update the integrity attributes for the <script> tags that load
"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"
and
"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"
so they match the correct SHA values from CDNJS (they currently duplicate the
CSS hashes), replacing the integrity strings on those two <script> tags with the
correct SRI tokens from the prism 1.29.0 CDNJS entries to prevent browser load
failures.
| <div class="mt-[20px] overflow-x-auto"> | ||
| <svg | ||
| viewBox="0 0 840 700" | ||
| viewBox="0 0 840 620" |
There was a problem hiding this comment.
SVG viewBox の高さ縮小(700→620)がコンテンツに対して十分か確認してください。
フローチャートのループバック矢印のパス(Line 655)が y=585 まで到達し、ラベル(Line 663)が y=600 に配置されています。viewBox の高さ 620 に対してマージンが 20px しかなく、テキストの下端がクリッピングされる可能性があります。ブラウザで表示を確認してください。
🤖 Prompt for AI Agents
In `@JavaScript/2626`. Array Reduce Transformation/Claude Code Sonnet 4.5
extended/README_react.html at line 341, The SVG viewBox height was reduced to
620 which may clip the loop-back arrow path (reaching y=585) and its label (at
y=600); update the viewBox attribute (the "viewBox" value currently "0 0 840
620") to provide extra bottom space (e.g., restore to "0 0 840 700" or increase
to a height ≥ 640–700), or alternatively shift the loop-back arrow path and
label upward so their y coordinates are well within the viewBox, then verify in
a browser that the path and text are not clipped.
| <script | ||
| src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" | ||
| integrity="sha384-nUkTNLI8COlMCRJ0FHIdX76If83145OTCLUx4gQyfnO0gGeO/sD9czGEUBxtkcUv" | ||
| crossorigin="anonymous" | ||
| ></script> | ||
| <script | ||
| src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js" | ||
| integrity="sha384-EUzJ34/1CCeefTGUKLgvA5Z/vYIwi+Jyu8aAaCfFDxfwZ3Xs3OfkkIeegsLRM11e" | ||
| crossorigin="anonymous" | ||
| ></script> |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the SRI hashes by fetching the actual files and computing their sha384 hashes
echo "=== CSS: prism-line-numbers.min.css ==="
curl -sL "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" | openssl dgst -sha384 -binary | openssl base64 -A
echo ""
echo "=== JS: prism-line-numbers.min.js ==="
curl -sL "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" | openssl dgst -sha384 -binary | openssl base64 -A
echo ""
echo "=== CSS: prism-toolbar.min.css ==="
curl -sL "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css" | openssl dgst -sha384 -binary | openssl base64 -A
echo ""
echo "=== JS: prism-toolbar.min.js ==="
curl -sL "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js" | openssl dgst -sha384 -binary | openssl base64 -A
echo ""Repository: myoshi2891/Algorithm-DataStructures-Math-SQL
Length of output: 626
🏁 Script executed:
#!/bin/bash
python3 <<'EOF'
import urllib.request
import hashlib
import base64
files = {
"CSS: prism-line-numbers.min.css": "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css",
"JS: prism-line-numbers.min.js": "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js",
"CSS: prism-toolbar.min.css": "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css",
"JS: prism-toolbar.min.js": "https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js",
}
for name, url in files.items():
try:
response = urllib.request.urlopen(url)
content = response.read()
hash_digest = hashlib.sha384(content).digest()
hash_b64 = base64.b64encode(hash_digest).decode('ascii')
print(f"=== {name} ===")
print(f"sha384-{hash_b64}")
print()
except Exception as e:
print(f"Error fetching {name}: {e}")
print()
EOFRepository: myoshi2891/Algorithm-DataStructures-Math-SQL
Length of output: 781
🏁 Script executed:
#!/bin/bash
# Read the HTML file to verify the SRI hashes mentioned in the review
FILE="JavaScript/2626. Array Reduce Transformation/Claude Code Sonnet 4.5 extended/README_react.html"
echo "=== Lines around 24-36 (CSS integrity hashes) ==="
sed -n '24,37p' "$FILE"
echo ""
echo "=== Lines around 890-905 (JS integrity hashes) ==="
sed -n '890,905p' "$FILE"Repository: myoshi2891/Algorithm-DataStructures-Math-SQL
Length of output: 1809
prism-line-numbers.min.js と prism-toolbar.min.js の SRI ハッシュが不正(スクリプト読み込みブロック)
Line 894 の prism-line-numbers.min.js の integrity ハッシュ(sha384-nUkTNLI8COlMCRJ0FHIdX76If83145OTCLUx4gQyfnO0gGeO/sD9czGEUBxtkcUv)が、Line 30 の prism-line-numbers.min.css と完全に一致しています。同様に、Line 899 の prism-toolbar.min.js のハッシュも Line 36 の prism-toolbar.min.css と同一です。
CSS と JS は異なるファイルなので、SRI ハッシュが同じになることはありません。不正なハッシュはブラウザのセキュリティチェックで検証に失敗し、スクリプトの読み込みをブロックします。その結果、シンタックスハイライト、行番号、コピーボタンなどの機能が動作しなくなります。
各 JS ファイルの正しい SRI ハッシュを cdnjs から確認して修正してください。
🤖 Prompt for AI Agents
In `@JavaScript/2626`. Array Reduce Transformation/Claude Code Sonnet 4.5
extended/README_react.html around lines 892 - 901, HTML includes incorrect SRI
hashes for the Prism JS scripts: update the integrity attributes for the
<script> tags that load
"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"
and
"https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"
so they match the correct SHA values from CDNJS (they currently duplicate the
CSS hashes), replacing the integrity strings on those two <script> tags with the
correct SRI tokens from the prism 1.29.0 CDNJS entries to prevent browser load
failures.