Skip to content

Verify Status Check with 'Request Changes' Disabled#29

Open
PrajaktaBendreBito wants to merge 14 commits intobranch1from
testbranch2
Open

Verify Status Check with 'Request Changes' Disabled#29
PrajaktaBendreBito wants to merge 14 commits intobranch1from
testbranch2

Conversation

@PrajaktaBendreBito
Copy link
Copy Markdown
Owner

@PrajaktaBendreBito PrajaktaBendreBito commented Dec 23, 2025

Summary by Bito

  • Introduces new domain models, constants, and service layer components to extend the bookstore application's functionality.
  • Adds a new implementation for user management in the service layer.
  • Refines utility classes involved in database connectivity and session management to handle resources and user interactions more robustly.
  • Overall, introduces new files and configuration updates, including modifications to the .idea directory for project configuration and version control integration, while combining these with functional additions and code-level refinements that streamline project setup and core operations.

@bito-app-pre-prod
Copy link
Copy Markdown
Contributor

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Other Improvements - Project Configuration Enhancements

.gitignore - Added default ignored files to exclude unnecessary files from version control.

BookStore.iml - Introduced module configuration for the BookStore project.

compiler.xml - Configured compiler settings including annotation processing profiles.

jarRepositories.xml - Defined remote repository settings to support Maven dependencies.

misc.xml - Updated project-level settings such as project JDK and output paths.

modules.xml - Configured module management by linking module files.

vcs.xml - Set up version control mappings for Git integration.

New Feature - New Domain Models & Constants

BookStoreConstants.java - Added bookstore specific constant definitions.

ResponseCode.java - Introduced an enum for standardized response codes.

BooksDBConstants.java - Defined database constants for book-related operations.

UsersDBConstants.java - Defined database constants for user-related operations.

Address.java - Implemented the Address model for user address details.

Book.java - Implemented the Book model with constructors and utility methods.

Cart.java - Created the Cart model to manage book items and quantities.

StoreException.java - Added a custom exception to handle store specific errors.

User.java - Implemented the User model including a helper for HTTP request extraction.

UserRole.java - Defined user roles using an enum.

package-info.java - Provided package-level documentation for the model package.

Feature Improvement - Service Layer Additions

UserService.java - Added an interface defining user-related functionalities.

UserServiceImpl.java - Introduced a new implementation for user operations including login, logout, registration, and session handling.

Other Improvements - Utility Enhancements

DBUtil.java - Enhanced database connection handling with improved exception management and static initialization.

DatabaseConfig.java - Refined resource loading and configuration retrieval with added InputStream closure management.

StoreUtil.java - Improved session and cart management methods to support item addition and removal with dynamic active tab updates.

Copy link
Copy Markdown
Contributor

@bito-app-pre-prod bito-app-pre-prod bot left a comment

Choose a reason for hiding this comment

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

Code Review Agent Run #f3a986

Actionable Suggestions - 17
  • scr/main/java/bittercode/model/Address.java - 1
  • scr/main/java/bittercode/model/Cart.java - 2
    • Missing type declaration in constructor parameter · Line 10-10
    • Incorrect capitalization in variable reference · Line 24-24
  • scr/main/java/bittercode/constant/ResponseCode.java - 1
    • Missing variable name in field declaration · Line 19-22
  • .idea/compiler.xml - 1
  • scr/main/java/bittercode/util/DatabaseConfig.java - 2
  • scr/main/java/bittercode/util/StoreUtil.java - 4
  • scr/main/java/bittercode/model/User.java - 1
  • scr/main/java/bittercode/service/impl/UserServiceImpl.java - 3
    • Resource leak and broad exception handling · Line 32-51
    • Plain text password storage · Line 32-51
    • Duplicate email assignment in SQL insert · Line 75-75
  • scr/main/java/bittercode/util/DBUtil.java - 1
  • scr/main/java/bittercode/service/UserService.java - 1
    • Missing method name in interface declaration · Line 17-17
Additional Suggestions - 15
  • scr/main/java/bittercode/service/impl/UserServiceImpl.java - 2
    • Inconsistent data type for usertype · Line 33-33
      In login, userType is set as a string ("1" or "2"), but in register as an int (1 or 2). This type inconsistency may cause DB type mismatches depending on the usertype column type.
    • Inconsistent DB column references · Line 41-43
      The ResultSet.getString calls use camelCase names like "firstName" instead of the defined constants (e.g., UsersDBConstants.COLUMN_FIRSTNAME = "firstname"). While JDBC is often case-insensitive, using constants improves maintainability and prevents potential issues.
  • scr/main/java/bittercode/constant/db/UsersDBConstants.java - 1
    • DB Column Name Mismatch · Line 9-10
      The values for COLUMN_FIRSTNAME and COLUMN_LASTNAME appear mismatched with the database column names used in `UserServiceImpl.login()` (e.g., rs.getString("firstName")), which could lead to errors if these constants are used for ResultSet retrieval instead of hardcoded strings.
  • scr/main/java/bittercode/service/BookService.java - 1
    • Spelling Error in Method Name · Line 14-14
      The method name and parameter contain a spelling error ('Seperated' instead of 'Separated'), which could confuse developers using this API. Correcting it improves readability without affecting functionality.
  • scr/main/java/bittercode/util/DatabaseConfig.java - 2
    • Poor Error Handling · Line 18-18
      Using printStackTrace() in production code is discouraged; consider using a logging framework instead.
    • Code Duplication · Line 22-32
      The code has two identical try-catch blocks attempting to close 'input', which is redundant and misplaced.
  • scr/main/java/bittercode/model/User.java - 2
    • Model-Servlet Coupling · Line 5-5
      The model class imports and uses HttpServletRequest, violating separation of concerns; models should be independent of web frameworks. Consider relocating this method.
    • Runtime Exception Risk · Line 85-85
      The call to Long.parseLong(phNo) could throw a NumberFormatException if the phone parameter from the request is not a valid long string, leading to runtime failure. Consider adding input validation or error handling here.
  • .idea/jarRepositories.xml - 2
    • IDE files in VCS · Line 1-20
      Committing .idea/jarRepositories.xml goes against best practices, as IDE-specific files should not be in version control. The .idea/.gitignore already lists this file to ignore, indicating it shouldn't be tracked.
    • Duplicate repo ID · Line 9-13
      Two repositories share the same ID 'central', which may lead to configuration conflicts in IntelliJ IDEA. Removing the duplicate (lines 9-13) would resolve this.
      Code suggestion
       suggestion
      --- .idea/jarRepositories.xml
       @@ -1,20 +1,16 @@
        <?xml version="1.0" encoding="UTF-8"?>
        <project version="4">
          <component name="RemoteRepositoriesConfiguration">
            <remote-repository>
              <option name="id" value="central" />
              <option name="name" value="Central Repository" />
              <option name="url" value="https://repo.maven.apache.org/maven2" />
            </remote-repository>
      -    <remote-repository>
      -      <option name="id" value="central" />
      -      <option name="name" value="Maven Central repository" />
      -      <option name="url" value="https://repo1.maven.org/maven2" />
      -    </remote-repository>
            <remote-repository>
              <option name="id" value="jboss.community" />
              <option name="name" value="JBoss Community repository" />
              <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
            </remote-repository>
          </component>
        </project>
  • scr/main/java/bittercode/model/package-info.java - 1
    • Invalid package Javadoc · Line 1-8
      The @author tag isn't supported in package-info.java per Javadoc standards, so it won't appear in generated documentation. Also, the first empty Javadoc comment seems redundant. If author info is needed, include it as plain text in the comment.
  • .idea/misc.xml - 1
    • Version mismatch · Line 1-6
      The language level is set to JDK_21, but the project JDK is openjdk-22. While IntelliJ allows this, matching versions is recommended for consistency and to avoid potential confusion.
  • scr/main/java/bittercode/model/Book.java - 2
    • Inconsistent field init · Line 17-17
      In the constructor, price is assigned via setter while other fields use direct assignment; for consistency and to avoid unnecessary method calls, use direct assignment here too.
    • Dead code: unused toString2 · Line 68-70
      The toString2 method appears to be a duplicate of toString but excludes quantity; it's not called anywhere in the codebase, suggesting it's dead code that should be removed for cleaner code.
  • .idea/BookStore.iml - 1
    • Unnecessary .idea commit · Line 1-9
      Committing the entire .idea directory, including BookStore.iml, goes against IntelliJ best practices. Typically, only shareable project configurations should be versioned, while user-specific files are ignored to avoid merge conflicts.
Review Details
  • Files reviewed - 25 · Commit Range: 9c6e4d6..062bda4
    • .idea/.gitignore
    • .idea/BookStore.iml
    • .idea/compiler.xml
    • .idea/jarRepositories.xml
    • .idea/misc.xml
    • .idea/modules.xml
    • .idea/vcs.xml
    • scr/main/java/bittercode/constant/BookStoreConstants.java
    • scr/main/java/bittercode/constant/ResponseCode.java
    • scr/main/java/bittercode/constant/db/BooksDBConstants.java
    • scr/main/java/bittercode/constant/db/UsersDBConstants.java
    • scr/main/java/bittercode/model/Address.java
    • scr/main/java/bittercode/model/Book.java
    • scr/main/java/bittercode/model/Cart.java
    • scr/main/java/bittercode/model/StoreException.java
    • scr/main/java/bittercode/model/User.java
    • scr/main/java/bittercode/model/UserRole.java
    • scr/main/java/bittercode/model/package-info.java
    • scr/main/java/bittercode/service/BookService.java
    • scr/main/java/bittercode/service/UserService.java
    • scr/main/java/bittercode/service/impl/BookServiceImpl.java
    • scr/main/java/bittercode/service/impl/UserServiceImpl.java
    • scr/main/java/bittercode/util/DBUtil.java
    • scr/main/java/bittercode/util/DatabaseConfig.java
    • scr/main/java/bittercode/util/StoreUtil.java
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Java-google-format (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at prajakta.bendre@bito.ai.

Documentation & Help

AI Code Review powered by Bito Logo

private String city;
private String state;
private String country;
private long pinCode;
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.

Data type issue for pinCode

The pinCode field is declared as long, but postal codes can have leading zeros (e.g., US ZIP codes like 01234). Using long would truncate them to 1234, causing data loss. Consider changing to String for accurate representation.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

private Book book;
private int quantity;

private Cart(Book book, quantity) {
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.

Missing type declaration in constructor parameter

Line 10: Constructor parameter quantity is missing its type declaration. This causes a syntax error. Change quantity to int quantity.

Code suggestion
Check the AI-generated fix before applying
Suggested change
private Cart(Book book, quantity) {
private Cart(Book book, int quantity) {

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

}

public int getQuantity() {
return Quantity;
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.

Incorrect capitalization in variable reference

Line 24: Variable name Quantity is incorrectly capitalized. Change to lowercase quantity to match the field declaration and fix the reference error.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return Quantity;
return quantity;

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +19 to +22
private final String message;
private final int ;

ResponseCode(int code, String message) {
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.

Missing variable name in field declaration

Line 20 has incomplete field declaration: private final int ; is missing the variable name. This causes a syntax error. Add the variable name code to fix it.

Code suggestion
Check the AI-generated fix before applying
Suggested change
private final String message;
private final int ;
ResponseCode(int code, String message) {
private final String message;
private final int code;
ResponseCode(int code, String message) {

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment thread .idea/compiler.xml
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="onlinebookstore" />
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.

Module name mismatch

The module name 'onlinebookstore' in the annotation processing profile does not match the actual module name 'BookStore' as defined in BookStore.iml and modules.xml, which could prevent IntelliJ from applying the configuration correctly.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

InputStream input = classLoader.getResourceAsStream("application.properties");

try {
prop.load(input);
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.

Missing Null Check

If 'application.properties' is not found, getResourceAsStream returns null, leading to a NullPointerException when calling load(null).

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +17 to +33
} catch (IOException e) {
e.printStackTrace();
}
}

try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}

try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
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.

Try-catch blocks outside of method scope

Lines 22-26 and 28-32 contain try-catch blocks that are not enclosed within a method or initializer block. These statements cannot exist at class level. Move these blocks into the static initializer (lines 10-20) to properly close the InputStream resource.

Code suggestion
Check the AI-generated fix before applying
Suggested change
} catch (IOException e) {
e.printStackTrace();
}
}
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}
finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +37 to +82
public static void updateCartItems(HttpServletRequest req) {
String selectedBookId = req.getParameter("selectedBookId");
HttpSession session = req.getSession();
if (selectedBookId != null) { // add item to the cart

// Items will contain comma separated bookIds that needs to be added in the cart
String items = (String) session.getAttribute("items");
if (req.getParameter("addToCart") != null) { // add to cart
if (items == null || items.length() == 0)
items = selectedBookId;
else if (!items.contains(selectedBookId))
items = items + "," + selectedBookId; // if items already contains bookId, don't add it

// set the items in the session to be used later
session.setAttribute("items", item);

/*
* Quantity of each item in the cart will be stored in the session as:
* Prefixed with qty_ following its bookId
* For example 2 no. of book with id 'myBook' in the cart will be
* added to the session as qty_myBook=2
*/
int itemQty = 0;
if (session.getAttribute("qty_" + selectedBookId) != null)
itemQty = (int) session.getAttribute("qty_" + selectedBookId);
itemQty += 1;
session.setAttribute("qty_" + selectedBookId, itemQty);
} else { // remove from the cart
int itemQty = 0;
if (session.getAttribute("qty_" + selectedBookId) != null)
itemQty = (int) session.getAttribute("qty_" + selectedBookId);
if (itemQty == 1) {
itemQty--;
session.setAttribute("qty_" + selectedBookId, itemQty);
} else {
session.removeAttribute("qty_" + selectedBookId);
items = items.replace(selectedBookId + ",", "");
items = items.replace("," + selectedBookId, "");
items = items.replace(selectedBookId, "");
session.setAttribute("items", items);
}
else {
session.removeAttribute("qty_" + selectedBookId);
session.setAttribute("items", items.replace(selectedBookId, ""));
}
}
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.

Logic Bug: Inconsistent Cart Removal

The cart removal logic is inconsistent: if quantity == 1, it sets to 0 but keeps the item in 'items'; if >1, it removes the item entirely without decrementing. This leads to incorrect cart state. Also, 'items.contains(selectedBookId)' can false-positive on partial matches (e.g., id '1' matches '12').

Typo: Undefined Variable

The variable 'item' is undefined here; it should be 'items' to match the local variable declared on line 43.

Code suggestion
Check the AI-generated fix before applying
 suggestion
                 session.setAttribute("items", items);

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +68 to +83
if (itemQty == 1) {
itemQty--;
session.setAttribute("qty_" + selectedBookId, itemQty);
} else {
session.removeAttribute("qty_" + selectedBookId);
items = items.replace(selectedBookId + ",", "");
items = items.replace("," + selectedBookId, "");
items = items.replace(selectedBookId, "");
session.setAttribute("items", items);
}
else {
session.removeAttribute("qty_" + selectedBookId);
session.setAttribute("items", items.replace(selectedBookId, ""));
}
}
}
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.

Orphaned else clause without matching if

Line 78 contains an else statement without a corresponding if condition. This is a syntax error caused by malformed control flow logic in the remove-from-cart section (lines 64-82). The nested if-else structure is broken, causing compilation failure.

Code suggestion
Check the AI-generated fix before applying
Suggested change
if (itemQty == 1) {
itemQty--;
session.setAttribute("qty_" + selectedBookId, itemQty);
} else {
session.removeAttribute("qty_" + selectedBookId);
items = items.replace(selectedBookId + ",", "");
items = items.replace("," + selectedBookId, "");
items = items.replace(selectedBookId, "");
session.setAttribute("items", items);
}
else {
session.removeAttribute("qty_" + selectedBookId);
session.setAttribute("items", items.replace(selectedBookId, ""));
}
}
}
if (itemQty == 1) {
itemQty--;
session.setAttribute("qty_" + selectedBookId, itemQty);
} else {
session.removeAttribute("qty_" + selectedBookId);
items = items.replace(selectedBookId + ",", "");
items = items.replace("," + selectedBookId, "");
items = items.replace(selectedBookId, "");
session.setAttribute("items", items);
}
}
}

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +28 to +29
pw.println("<script>document.getElementById(activeTab).classList.remove(\"active\");activeTab=" + activeTab
+ "</script>");
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.

Bug: Malformed JavaScript

In the generated JavaScript, document.getElementById should use a quoted string literal for the tab ID (e.g., getElementById('" + activeTab + "')) to avoid a ReferenceError.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

user.setEmailId(mailId);
user.setFirstName(fName);
user.setLastName(lName);
user.setPassword(pWord);
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.

Plain Text Password Storage

Storing passwords in plain text poses a security risk; the model sets password directly from request parameters, and related code (e.g., UserServiceImpl queries) suggests plain storage in DB. Hashing should be added for security.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Comment on lines +32 to +51
try {
String userType = UserRole.SELLER.equals(role) ? "1" : "2";
ps = con.prepareStatement(loginUserQuery);
ps.setString(1, email);
ps.setString(2, password);
ps.setString(3, userType);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
user = new User();
user.setFirstName(rs.getString("firstName"));
user.setLastName(rs.getString("lastName"));
user.setPhone(rs.getLong("phone"));
user.setEmailId(email);
user.setPassword(password);
session.setAttribute(role.toString(), user.getEmailId());
}
} catch (SQLException e) {
e.printStackTrace();
}
return user;
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.

Resource leak and broad exception handling

Database resources (Connection, PreparedStatement, ResultSet) are not closed, leading to potential resource leaks. Also, catching broad Exception instead of SQLException reduces specificity.

Plain text password storage

Passwords are stored and retrieved in plain text, posing a security risk. Consider using a secure hashing algorithm like BCrypt.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

Connection con = DBUtil.getConnection();
try {
PreparedStatement ps = con.prepareStatement(registerUserQuery);
ps.setString(1, user.getEmailId());
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.

Duplicate email assignment in SQL insert

In the register method, user.getEmailId() is set for both the username (position 1) and mailid (position 7) columns. This appears redundant since both columns receive the same value, potentially indicating a data model inconsistency.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

throw new StoreException(ResponseCode.DATABASE_CONNECTION_FAILURE);
}

return null;
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.

Logic Error in Connection Return

The getConnection method returns null when the connection is successfully initialized, but it should return the connection object. This causes NullPointerException in calling code like BookServiceImpl and UserServiceImpl that assign the result to a Connection variable.

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them


public boolean isLoggedIn(UserRole role, HttpSession session);

public boolean (HttpSession session);
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.

Missing method name in interface declaration

Line 17 has a syntax error: the method declaration is missing an identifier (method name). The boolean return type is declared but no method name follows. Add the missing method name to fix the compilation error.

Code suggestion
Check the AI-generated fix before applying
Suggested change
public boolean (HttpSession session);
public boolean logout(HttpSession session);

Code Review Run #f3a986


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

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