Skip to content

ブックマーク編集・削除機能を追加#9

Open
JLee-Casareal wants to merge 1 commit into
goofmint:mainfrom
JLee-Casareal:dev
Open

ブックマーク編集・削除機能を追加#9
JLee-Casareal wants to merge 1 commit into
goofmint:mainfrom
JLee-Casareal:dev

Conversation

@JLee-Casareal
Copy link
Copy Markdown

@JLee-Casareal JLee-Casareal commented May 30, 2026

fixes #3

Summary by CodeRabbit

リリースノート

  • 新機能

    • ブックマークの編集機能を追加しました。タイトル、説明、タグを修正できます。
    • ブックマークの削除機能を追加しました。
  • スタイル

    • ブックマークカードのUIを改善し、操作ボタンをより見やすく表示するようになりました。

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

📝 Walkthrough

Walkthrough

このプルリクエストはブックマークの編集・削除機能を実装します。Repository に findById/update/delete メソッドを追加し、Controller に対応するエンドポイントを実装し、edit.html テンプレートと UI スタイルを追加します。バリデーション(タイトル空欄・100文字超、説明300文字超)とエラーメッセージ表示を含みます。

Changes

ブックマーク編集・削除機能

Layer / File(s) Summary
Repository CRUD メソッド
src/main/java/com/example/bookmark/BookmarkRepository.java
findById(id) でIDに一致するブックマークを取得し、update(id, title, description, tags) で該当行を更新、delete(id) で削除するメソッドを追加します。
Controller エンドポイント
src/main/java/com/example/bookmark/BookmarkController.java
GET /bookmarks/{id}/edit でブックマーク取得後、edit ビューへ遷移、POST /bookmarks/{id}/update で入力値のバリデーション(タイトル空/100文字超、説明300文字超)とエラーハンドリング、POST /bookmarks/{id}/delete で削除処理を実装します。
編集フォームと UI
src/main/resources/templates/edit.html, src/main/resources/templates/index.html, src/main/resources/static/styles.css
edit.html に Thymeleaf フォーム(タイトル、説明、タグ入力、エラー表示、URL は読取専用)を実装、index.html のカードに編集・削除のアクションボタンを追加、styles.css でカードヘッダー・アクション・削除ボタンのスタイルを定義します。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • goofmint/bookmark-app-java#1: 初期の Spring Boot ブックマークアプリの実装で、このプルリクエストが BookmarkController と BookmarkRepository に新しい編集・更新・削除メソッドを追加する際の基盤となります。

Poem

📝 ウサギの本棚も整理整頓
編集ボタン、削除ボタンと
管理しやすく生まれ変わり
削減も追記も思いのまま
🐰 ブックマークの旅、ここに完成

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning プルリクエストは#3の要件の大部分を実装していますが、削除前の確認ダイアログが未実装であり、タイトルの空白文字のみの入力に対する明示的な検証が不明確です。 削除エンドポイントにJavaScript確認ダイアログを追加し、タイトルの空白文字のみのケースを明示的にバリデーションロジックで処理してください。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトル「ブックマーク編集・削除機能を追加」はプルリクエストの主要な変更を正確に反映しており、追加された編集・削除エンドポイント、リポジトリメソッド、UIコンポーネントなどの変更すべてを包括的に表現しています。
Out of Scope Changes check ✅ Passed すべての変更(BookmarkController、BookmarkRepository、styles.css、edit.html、index.html)は#3の編集・削除機能実装に直接関連し、スコープ外の変更は検出されていません。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/main/resources/templates/index.html (1)

44-46: ⚡ Quick win

th:hrefjavascript: スキーム懸念は上流で抑止されています

src/main/resources/templates/index.html の該当リンクは th:href="${bookmark.url()}" ですが、BookmarkMetadataFetcher.normalizeUrl() でURLスキームを http/https 以外の場合に IllegalArgumentException として拒否しており、BookmarkController 側でもその例外はキャッチしてエラーフラッシュ&トップへリダイレクトしています。これにより bookmark.url()javascript: になる経路は現状ありません。

関連スキーム検証(BookmarkMetadataFetcher)
String scheme = uri.getScheme();
if (!"http".equalsIgnoreCase(scheme) && !"https".equalsIgnoreCase(scheme)) {
    throw new IllegalArgumentException("URL scheme must be http or https");
}

(防御的に)保存前/表示時の二重チェックとして bookmark.url() 再検証を行うのは任意の改善です。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/templates/index.html` around lines 44 - 46, Although
upstream code rejects non-http/https schemes in
BookmarkMetadataFetcher.normalizeUrl() and BookmarkController handles that, add
a defensive re-check before rendering to ensure bookmark.url() cannot be a
javascript: scheme: in the controller action that prepares the model (the method
in BookmarkController that adds Bookmark objects to the view) validate the
bookmark.url() again (reusing the same scheme check logic from
BookmarkMetadataFetcher.normalizeUrl() or a small helper) and if invalid replace
it with a safe fallback (null or "#") or remove the href attribute from the
model so the template anchor (th:href="${bookmark.url()}") never outputs a
javascript: URL; ensure any exception is caught and a safe value is supplied to
the view.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/main/resources/templates/index.html`:
- Around line 44-46: Although upstream code rejects non-http/https schemes in
BookmarkMetadataFetcher.normalizeUrl() and BookmarkController handles that, add
a defensive re-check before rendering to ensure bookmark.url() cannot be a
javascript: scheme: in the controller action that prepares the model (the method
in BookmarkController that adds Bookmark objects to the view) validate the
bookmark.url() again (reusing the same scheme check logic from
BookmarkMetadataFetcher.normalizeUrl() or a small helper) and if invalid replace
it with a safe fallback (null or "#") or remove the href attribute from the
model so the template anchor (th:href="${bookmark.url()}") never outputs a
javascript: URL; ensure any exception is caught and a safe value is supplied to
the view.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2f08d2cc-f18e-4825-822c-c143ed17147f

📥 Commits

Reviewing files that changed from the base of the PR and between 700e006 and 1213b93.

📒 Files selected for processing (5)
  • src/main/java/com/example/bookmark/BookmarkController.java
  • src/main/java/com/example/bookmark/BookmarkRepository.java
  • src/main/resources/static/styles.css
  • src/main/resources/templates/edit.html
  • src/main/resources/templates/index.html

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ブックマーク編集、削除機能の実装

1 participant