Skip to content

fix(searches): handle null array safely and eliminate raw type warnings in FibonacciSearch - #7650

Merged
alxkm merged 2 commits into
TheAlgorithms:masterfrom
hardikkaurani:fix/fibonacci-search-null-safety
Oct 21, 2026
Merged

alxkm merged 2 commits into
TheAlgorithms:masterfrom
hardikkaurani:fix/fibonacci-search-null-safety

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor
  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Description

This pull request addresses null safety and type safety in FibonacciSearch:

  1. Prevent NullPointerException on Null Array: Calling find(null, key) previously threw an unexpected NullPointerException when evaluating array.length == 0. Added an explicit check throwing IllegalArgumentException("Input array must not be null.") consistent with the method contract and existing parameter checks.
  2. Eliminated Raw Types and SuppressWarnings: Parameterized isSorted as <T extends Comparable<T>> boolean isSorted(T[] array), eliminating raw type usage and allowing removal of @SuppressWarnings({"rawtypes", "unchecked"}).
  3. Marked Class Final: Marked FibonacciSearch as final following project conventions.
  4. Updated Javadoc and Added Tests: Updated the @throws Javadoc to document null array handling and added a unit test verifying IllegalArgumentException is thrown when array is null.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 16:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@hardikkaurani

Copy link
Copy Markdown
Contributor Author

@alxkm Hi! I have submitted this PR to safely handle null arrays without throwing NullPointerException, eliminate raw type compiler warnings in FibonacciSearch, and add corresponding test coverage. Please review when you have a moment. Thanks!

@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.19%. Comparing base (ff36004) to head (b878fce).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7650      +/-   ##
============================================
- Coverage     82.19%   82.19%   -0.01%     
- Complexity     8376     8378       +2     
============================================
  Files           842      842              
  Lines         26099    26101       +2     
  Branches       5089     5090       +1     
============================================
+ Hits          21452    21453       +1     
- Misses         3857     3858       +1     
  Partials        790      790              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alxkm alxkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. NPE and @SuppressWarnings gone, nice. Thank you for the contribution.

@alxkm
alxkm merged commit 18c99d9 into TheAlgorithms:master Oct 21, 2026
7 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.

4 participants