Skip to content

Dev changes #2

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 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/custom-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### General

Rules
- For any change you make always add a comment 'Generated by Copilot - start' at the start of code block generated by you and 'Generated by Copilot - end' at the end of code block which is generated by you.
-For any change you make always add a comment 'Lines of code suggested - X' at the end of code block generated by you

- Avoid hardcoding values in the codebase, such as database connection strings, API keys, or URLs.
- Use environment variables to store configuration values.
- Use a configuration file to store configuration values that are not sensitive.
- Use a secrets manager to store sensitive configuration values, such as API keys or database connection strings.
- Use a `.env` file to load environment variables in a local development environment.
- Use a `.env.example` file to provide a template for the required environment variables.
- Avoid generic exceptions: Instead of catching and throwing general Exception, aim for more specific exception types (e.g., IOException, NullPointerException, DataFormatException).
- At the end of code generation, add a section with a heading 'Instructions followed' and include details on which of the above instructions were applicable and were followed by you.
23 changes: 23 additions & 0 deletions code-generation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# General Guidelines
Rules
-For any change you make always add a comment 'Generated by Copilot - start' at the start of code block generated by you and 'Generated by Copilot - end' at the end of code block which is generated by you.
-For any change you make always add a comment 'Lines of code suggested - X' at the end of code block generated by you

- For any change you make always fetch the current time stamp and add as a comment at the end of code block which is generated by you.

- For any change you make always fetch the current selected LLM model and add as a comment at the end of code block which is generated by you.


## API Design

- Follow RESTful principles for API design.
- Use appropriate HTTP methods (e.g., `GET`, `POST`, `PUT`, `DELETE`).
- Provide clear and consistent API documentation using Swagger.
- Implement proper authentication and authorization using JWT.

## Security

- Sanitize user inputs to prevent injection attacks.
- Use strong passwords and hashing algorithms.
- Protect sensitive data using encryption.
- Follow secure coding practices to prevent vulnerabilities.
10 changes: 10 additions & 0 deletions code-review.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- For any code review suggestions that you do, clearly mark the suggestion with comments example shown below:
// Copilot Review Suggestion - start
{suggested changes or improvements}
// Copilot Review Suggestion - end

# Additional Guidelines
- Ensure all code blocks are properly formatted.
- Review generated code for accuracy and relevance before finalizing.
## Additional Instructions
Revalidate before responding. Think step by step.
15 changes: 15 additions & 0 deletions commit-message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Don’t end commit message summaries with punctuation
Don’t write all words in capital letters
Use the imperative verb form
Use the present tense
Use the active voice
Explain what the commit does in crisp, clear language
Limit the summary to 50 characters
Include bug id or issue number where possible







Binary file removed complete backed course.pptx
Binary file not shown.
1 change: 1 addition & 0 deletions read-me.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test commit
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class CommentServiceImpl implements CommentService {
@Autowired
private ModelMapper modelMapper;


@Override
public CommentDto createComment(CommentDto commentDto, Integer postId) {

Expand All @@ -47,4 +48,28 @@ public void deleteComment(Integer commentId) {
this.commentRepo.delete(com);
}

@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;


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,33 @@ public InputStream getResource(String path, String fileName) throws FileNotFound
return is;
}

public static void SampleNestedIfMethod(String[] args) {
int age = 25;
String country = "USA";
boolean hasPermission = true;
boolean isMember = false;

// Deeply nested conditionals
if (age > 18) {
if (country.equals("USA")) {
if (hasPermission) {
if (isMember) {
System.out.println("Access granted: Adult from USA, with permission, and is a member.");
} else {
System.out.println("Access denied: Adult from USA, with permission, but not a member.");
}
} else {
System.out.println("Access denied: Adult from USA, without permission.");
}
} else {
System.out.println("Access denied: Adult, but not from USA.");
}
} else {
System.out.println("Access denied: Underage.");
}
}




}
7 changes: 7 additions & 0 deletions unit-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Unit Test Instructions

1. **Test Framework**: Use JUnit 5 for writing unit tests.
2. **Test Naming**:for each unit test write the name of unit test in the following format: `methodUnderTest_inputGiven_expectedOutput`
3. **Assertions**: Use `assertEquals`, `assertTrue`, `assertFalse`, and `assertThrows` for assertions.
4. **Mocking**: Use Mockito for mocking dependencies.
5. **Test Coverage**: Ensure that all public methods have corresponding unit tests.