Skip to content

Feature3 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Feature3 #5

wants to merge 4 commits into from

Conversation

umaranit
Copy link

This pull request includes several changes to the CommentServiceImpl and FileServiceImpl classes to add new functionality and improve the codebase. The most important changes include the addition of methods for retrieving comments by ID and by post ID, as well as the introduction of a sample method demonstrating deeply nested conditionals.

@umaranit umaranit requested a review from Copilot April 11, 2025 05:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces new methods for retrieving comments by ID and by post ID in CommentServiceImpl and a sample method demonstrating deeply nested conditionals in FileServiceImpl.

  • Added SampleNestedIfMethod to FileServiceImpl to illustrate deeply nested conditionals.
  • Introduced new methods (getCommentById and getAllCommentsByPostId) in CommentServiceImpl; however, duplicate definitions are present.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/java/com/codewithdurgesh/blog/services/impl/FileServiceImpl.java Added SampleNestedIfMethod with deeply nested conditionals
src/main/java/com/codewithdurgesh/blog/services/impl/CommentServiceImpl.java New methods for retrieving comments with duplicate implementations present

Comment on lines +75 to 99
@Override
public CommentDto getCommentById(Integer commentId) {

Comment comment = this.commentRepo.findById(commentId).get(); // Should handle Optional properly
return null; // Should use modelMapper to map Comment to CommentDto
}

@Override
public List<CommentDto> getAllCommentsByPostId(Integer postId) {

List<Comment> comments = this.commentRepo.findByPostId(postId); // Assuming such a method exists in CommentRepo

// Issue 1: Null check for comments is missing.
// Issue 2: Improper exception handling for a case where comments list might be empty or null.

List<CommentDto> commentDtos = comments.stream()
.map(comment -> this.modelMapper.map(comment, CommentDto.class))
.collect(Collectors.toList());

return commentDtos;


}

}
Copy link
Preview

Copilot AI Apr 11, 2025

Choose a reason for hiding this comment

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

Duplicate implementations of getCommentById and getAllCommentsByPostId methods found; please remove the redundant definitions to avoid conflicts.

Suggested change
@Override
public CommentDto getCommentById(Integer commentId) {
Comment comment = this.commentRepo.findById(commentId).get(); // Should handle Optional properly
return null; // Should use modelMapper to map Comment to CommentDto
}
@Override
public List<CommentDto> getAllCommentsByPostId(Integer postId) {
List<Comment> comments = this.commentRepo.findByPostId(postId); // Assuming such a method exists in CommentRepo
// Issue 1: Null check for comments is missing.
// Issue 2: Improper exception handling for a case where comments list might be empty or null.
List<CommentDto> commentDtos = comments.stream()
.map(comment -> this.modelMapper.map(comment, CommentDto.class))
.collect(Collectors.toList());
return commentDtos;
}
}
// Removed redundant definitions of getCommentById and getAllCommentsByPostId methods.
}

Copilot uses AI. Check for mistakes.

boolean isMember = false;

// Deeply nested conditionals
if (age > 18) {
Copy link
Preview

Copilot AI Apr 11, 2025

Choose a reason for hiding this comment

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

Consider refactoring the deeply nested conditional statements to simplify the logic and improve readability.

Copilot uses AI. Check for mistakes.

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