Fix MiniMaxAlgorithm setScores bug and add comprehensive tests#6566
Merged
DenizAltunkapan merged 10 commits intoTheAlgorithms:masterfrom Oct 2, 2025
Merged
Fix MiniMaxAlgorithm setScores bug and add comprehensive tests#6566DenizAltunkapan merged 10 commits intoTheAlgorithms:masterfrom
DenizAltunkapan merged 10 commits intoTheAlgorithms:masterfrom
Conversation
- Fix bug in setScores method where scores.length % 1 == 0 always returned true - Add isPowerOfTwo helper method to properly validate array length - Add comprehensive unit tests covering edge cases and algorithm correctness - Tests include validation for power of 2 check, minimax logic, and error handling Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6566 +/- ##
============================================
+ Coverage 75.31% 75.49% +0.18%
- Complexity 5659 5679 +20
============================================
Files 693 693
Lines 19552 19554 +2
Branches 3786 3786
============================================
+ Hits 14725 14763 +38
+ Misses 4252 4215 -37
- Partials 575 576 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Replace star imports with explicit imports in test file - Remove trailing whitespaces from all lines - Add proper file ending newline - Improve setScores method to handle edge cases properly - Use direct bit manipulation for power-of-2 check as suggested - Ensure error message is printed and scores remain unchanged for invalid input All Checkstyle violations resolved and tests pass successfully.
- Fix Checkstyle violation: NewlineAtEndOfFile - Ensure file ends with proper newline character - All tests continue to pass successfully
- Replace inline bit manipulation with isPowerOfTwo method call - Resolves PMD UnusedPrivateMethod violation - Maintains same validation logic and error handling - All tests continue to pass successfully
- Add comprehensive test cases for isPowerOfTwo function edge cases - Test setScores method with various invalid array lengths (0, 3, 5, 6, 7, 9, 10, 15) - Add tests for large valid powers of 2 (up to 64 elements) - Ensure complete coverage of error handling branches - Increase test count from 14 to 19 tests - Fix partial coverage issues identified in CodeCov report Resolves CodeCov coverage gaps in MiniMaxAlgorithm.java
auto-merge was automatically disabled
October 1, 2025 19:41
Head branch was pushed to by a user without write access
Contributor
Author
|
Hi @DenizAltunkapan , could you please re-review my PR? I've added some additional test cases to increase the code coverage. |
DenizAltunkapan
approved these changes
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #6563
Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
clang-format -i --style=file path/to/your/file.java