Skip to content

Conversation

@Johrespi
Copy link
Contributor

Challenge 3 Solution

Submitted by: @Johrespi
Challenge: Challenge 3

Description

This PR contains my solution for Challenge 3.

Changes

  • Added solution file to challenge-3/submissions/Johrespi/solution-template.go

Testing

  • Solution passes all test cases
  • Code follows Go best practices

Thank you for reviewing my submission! 🚀

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

A new Go file implementing an employee management system with Employee and Manager types. The Manager provides methods to add/remove employees, calculate average salary, and retrieve employees by ID, with a main function demonstrating usage.

Changes

Cohort / File(s) Change Summary
Employee Management Implementation
challenge-3/submissions/Johrespi/solution-template.go
Adds Employee struct with ID, Name, Age, Salary fields; Manager struct containing employee slice; Manager methods: AddEmployee (appends), RemoveEmployee (filters by ID with guard for negative IDs), GetAverageSalary (computes mean), FindEmployeeByID (linear search returning pointer); main demonstrates all operations with output statements.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • RemoveEmployee's silent return for negative IDs—verify if intended behavior aligns with requirements
  • FindEmployeeByID pointer semantics—confirm nil handling is acceptable for caller

Possibly related PRs

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Add solution for Challenge 3 by Johrespi" directly and accurately describes the main change in the changeset. The summary confirms that this PR adds a solution file (solution-template.go) to the challenge-3/submissions/Johrespi/ directory, introducing Employee and Manager types with associated methods. The title is concise, clear, and specific enough that a teammate scanning the commit history would immediately understand that this is a Challenge 3 solution submission. The title is fully related to the primary change and does not use vague or misleading language.
Description Check ✅ Passed The PR description is clearly related to the changeset and provides relevant context about the submission. It explicitly states that this is a Challenge 3 solution, identifies the specific file added (challenge-3/submissions/Johrespi/solution-template.go), and mentions that the solution has been tested and follows Go best practices. The description matches the actual changes shown in the raw summary and directly corresponds to the objectives outlined in the PR. The description is appropriately detailed without being excessive, making it suitable for understanding the purpose of the changeset.

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
Contributor

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
challenge-3/submissions/Johrespi/solution-template.go (4)

16-20: Remove TODO comment; consider duplicate ID validation.

The implementation is correct, but the TODO comment on line 18 should be removed since the method is fully implemented. Optionally, consider validating for duplicate employee IDs if uniqueness is required by the challenge specification.


22-43: Remove TODO comment; implementation looks correct.

The method is properly implemented with correct slice manipulation. Remove the TODO comment on line 24. The negative ID check (lines 25-27) is defensive but note that it allows ID 0 while rejecting negatives—ensure this aligns with your ID scheme.


45-59: Remove TODO comment; implementation is correct.

The average salary calculation properly handles the empty list case and computes the result correctly. Remove the TODO comment on line 47.


61-71: Excellent pointer handling! Remove TODO comment.

The implementation correctly returns &m.Employees[i] (line 66) instead of &e, avoiding the common pitfall of returning a pointer to the loop variable. This ensures the returned pointer remains valid. Remove the TODO comment on line 63.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9726d4c and 86825fe.

📒 Files selected for processing (1)
  • challenge-3/submissions/Johrespi/solution-template.go (1 hunks)
🔇 Additional comments (2)
challenge-3/submissions/Johrespi/solution-template.go (2)

5-14: LGTM! Clean struct definitions.

The Employee and Manager structs are well-defined with appropriate field types and follow Go naming conventions.


73-85: LGTM! Good demonstration of functionality.

The main function properly demonstrates all Manager methods. After removing Alice (ID 1), the average salary correctly calculates to 65000 (Bob's salary alone), and FindEmployeeByID successfully retrieves Bob's employee record.

@RezaSi RezaSi merged commit 88b91eb into RezaSi:main Oct 31, 2025
5 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