Skip to content

Docstrings#85

Merged
Kathify merged 2 commits into
mainfrom
docstrings
Jan 14, 2026
Merged

Docstrings#85
Kathify merged 2 commits into
mainfrom
docstrings

Conversation

@eraiicphu

@eraiicphu eraiicphu commented Jan 14, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Bug Fixes

    • Restaurant search functionality enhanced with a fallback feature that automatically displays all available restaurants when the initial search query returns no matching results.
  • Documentation

    • Comprehensive documentation added throughout the application to describe class purposes, method responsibilities, validation requirements, and workflow across backend services, factories, repositories, and frontend controllers.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds comprehensive Javadoc documentation across multiple backend service classes, factory classes, and frontend controllers. Additionally, BookingService is augmented with three new private fields, and RestaurantHandler's search method now includes fallback logic to return all restaurants if no matches are initially found.

Changes

Cohort / File(s) Summary
Backend Service Documentation
src/main/java/backend/services/BookingService.java, src/main/java/backend/services/CustomerService.java
Added Javadoc blocks describing class and method responsibilities. BookingService gains three new private fields: bookingFactory, customerService, and restaurantRepo for dependency management.
Backend Factory Documentation
src/main/java/backend/factories/BookingFactory.java, src/main/java/backend/factories/CustomerFactory.java
Added Javadoc documenting method purposes and validation behavior (e.g., fixed 2-hour booking duration, customer field validation). No method signature changes.
Backend Repository & Seeder Documentation
src/main/java/backend/repositories/BaseRepo.java, src/main/java/backend/DataSeeder.java
Added Javadoc describing class roles and responsibilities. Documentation-only changes with no behavioral impact.
Frontend Controller Documentation
src/main/java/frontend/controller/BookingController.java, src/main/java/frontend/controller/MainController.java
Added Javadoc above controller methods describing user actions, validation, and display logic. No functional changes.
Frontend Search Enhancement
src/main/java/frontend/model/RestaurantHandler.java
Added Javadoc for public class and method. Enhanced getResturantList(String) with fallback logic: if initial search returns empty, searches with empty string to return all restaurants.
Test Documentation
src/test/java/backend/services/BookingServiceTest.java
Added Javadoc above test setup and test methods describing their purposes. Documentation-only changes.

Possibly related PRs

  • Frontend bokning #68: Both PRs modify BookingFactory and BookingService; this PR documents fixed 2-hour booking while the related PR implements the underlying 2-hour end-time logic.
  • Service #63: Both PRs augment BookingService and BookingFactory with documentation and structural additions to the same classes.
  • Service/customer #58: Both PRs document CustomerFactory and CustomerService; the related PR introduces or modifies these factory/service implementations.

Poem

🐰 Docs spring forth like clover in the spring,
A rabbit hops through code with careful fling,
JavaDoc comments, clear and bright,
A fallback search to set things right! 📚

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Docstrings' is vague and generic, failing to clearly describe the specific changes made in this pull request. Consider using a more descriptive title such as 'Add Javadoc documentation to core service and factory classes' to better convey the scope and intent of the changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
src/main/java/backend/factories/BookingFactory.java (1)

10-15: Misleading API: end parameter is validated but ignored.

The Javadoc correctly documents that bookings always last 2 hours, but the method signature still accepts an end parameter that is validated (line 29) yet completely ignored when creating the booking (line 36 uses start.plusHours(2)).

This creates a confusing API where callers pass an end time expecting it to be honored, but it isn't. Consider one of these approaches:

  1. Remove the end parameter entirely since it's not used
  2. Use the provided end parameter and validate that the duration is exactly 2 hours
Option 1: Remove unused `end` parameter
     public Booking createBooking(
         Restaurant restaurant,
         Customer customer,
         Long tableId,
         LocalTime start,
-        LocalTime end,
         LocalDate date){

             if (restaurant == null)
                 throw new IllegalArgumentException("Restaurant required");

             if (customer == null)
                 throw new IllegalArgumentException("Customer required");
-            if (start == null || end == null || !start.isBefore(end))
-                throw new IllegalArgumentException("Invalid time");
+            if (start == null)
+                throw new IllegalArgumentException("Start time required");
             if (tableId == null)
                 throw new IllegalArgumentException("Table id required");

Also applies to: 20-21, 29-29, 36-36

src/main/java/backend/services/BookingService.java (1)

24-35: Misplaced method Javadoc and unused field.

Two issues:

  1. Misplaced Javadoc: The bookTable method Javadoc (lines 24-29) is placed before the field declarations rather than directly above the method it documents (line 38). Move it to immediately precede the method.

  2. Unused field: restaurantRepo (line 35) is declared but never used in this class.

Suggested structure
 public class BookingService {

     private final BookingRepo bookingRepo = new BookingRepo();
     private final DiningTableRepo diningTableRepo = new DiningTableRepo();
     private final BookingFactory bookingFactory = new BookingFactory();
     private final CustomerService customerService = new CustomerService();
-    private final RestaurantRepo restaurantRepo = new RestaurantRepo();

+    /**
+     * Books a table at a restaurant for a specific date and time.
+     *
+     * Validates input, finds an available table with enough capacity,
+     * prevents double bookings, creates the booking, and saves it.
+     */
     public Booking bookTable(
src/main/java/backend/factories/CustomerFactory.java (1)

7-12: Javadoc indentation is inconsistent with the method.

The Javadoc block starts at column 0 while the method it documents is indented inside the class. This should be aligned with the method for consistency.

✏️ Suggested fix
 public class CustomerFactory {
 
-/**
- * Creates a new customer.
- *
- * Validates the customer's name, phone number, and email address
- * before creating the customer.
- */
+    /**
+     * Creates a new customer.
+     *
+     * Validates the customer's name, phone number, and email address
+     * before creating the customer.
+     */
     public Customer createCustomer(

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a754c61 and 06e06ac.

📒 Files selected for processing (10)
  • src/main/java/backend/DataSeeder.java
  • src/main/java/backend/factories/BookingFactory.java
  • src/main/java/backend/factories/CustomerFactory.java
  • src/main/java/backend/repositories/BaseRepo.java
  • src/main/java/backend/services/BookingService.java
  • src/main/java/backend/services/CustomerService.java
  • src/main/java/frontend/controller/BookingController.java
  • src/main/java/frontend/controller/MainController.java
  • src/main/java/frontend/model/RestaurantHandler.java
  • src/test/java/backend/services/BookingServiceTest.java
🧰 Additional context used
🧬 Code graph analysis (1)
src/main/java/frontend/controller/MainController.java (1)
src/main/java/frontend/model/RestaurantHandler.java (1)
  • RestaurantHandler (14-42)
🔇 Additional comments (11)
src/main/java/backend/DataSeeder.java (1)

8-13: LGTM!

Clear and concise Javadoc that accurately describes the class purpose.

src/main/java/backend/repositories/BaseRepo.java (1)

9-14: LGTM!

Good documentation that describes the repository's responsibilities clearly.

src/main/java/backend/services/CustomerService.java (1)

13-19: LGTM!

The Javadoc accurately describes the lookup-or-create behavior. Consider adding @param and @return tags to document the method parameters and return value for completeness.

src/main/java/backend/services/BookingService.java (1)

16-21: Good class-level documentation.

The class-level Javadoc clearly explains the service responsibilities.

src/test/java/backend/services/BookingServiceTest.java (2)

45-48: LGTM!

Clear and concise Javadoc describing the setup method's purpose.


58-62: LGTM!

The Javadoc accurately describes both the connection verification and the table truncation side effect.

src/main/java/frontend/controller/BookingController.java (1)

44-49: LGTM!

The Javadoc accurately describes the method's workflow: reading input, validation, booking creation, and result display.

src/main/java/frontend/controller/MainController.java (2)

39-44: LGTM!

The Javadoc clearly describes the search handling behavior.


53-57: LGTM!

Accurate description of the display logic.

src/main/java/frontend/model/RestaurantHandler.java (2)

8-13: LGTM!

Clear class-level documentation describing the handler's responsibilities.


27-41: Verify the fallback behavior is intentional UX.

The Javadoc accurately documents the fallback behavior. However, returning all restaurants when no match is found may be unexpected for users—if someone searches for "xyz" and nothing matches, they might expect an empty result with a "no results found" message rather than seeing all restaurants.

Consider whether this is the intended UX, or if the UI should instead show a "no results found" state.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

@Kathify
Kathify merged commit d372397 into main Jan 14, 2026
1 of 2 checks passed
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.

2 participants