Java
Java copied to clipboard
Add tests for NodeStack and rework
- [x] I have read CONTRIBUTING.md.
- [x] This pull request is all my own work -- I have not plagiarized it.
- [x] All filenames are in PascalCase.
- [x] All functions and variable names follow Java naming conventions.
- [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
- [x] All new code is formatted with
clang-format -i --style=file path/to/your/file.java
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 72.36%. Comparing base (
a163816) to head (f2fef25).
Additional details and impacted files
@@ Coverage Diff @@
## master #6009 +/- ##
============================================
- Coverage 72.37% 72.36% -0.01%
+ Complexity 4981 4979 -2
============================================
Files 652 652
Lines 17569 17564 -5
Branches 3385 3384 -1
============================================
- Hits 12716 12711 -5
Misses 4373 4373
Partials 480 480
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I cannot solve this PR because during a CI/CD pipeline run with Infer, a potential Null Dereference was detected in the BinaryTreeTest class. The analysis flagged the following line as a potential issue:
src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java:38: error: Null Dereference(NULLPTR_DEREFERENCE)
BinaryTree$Node BinaryTree.getRoot() could be null (from the call to BinaryTree() on line 28) and is dereferenced.
To solve the build problem, if I wish, I can apply a temporary fix to prevent the test from failing on the BinaryTreeTest class (e.g., by adding a null check in getRoot())
@siriak Let me know how to proceed
Hmm, that's odd. Could you try to fix the issue here or in a separate PR?
I cannot solve this PR because during a CI/CD pipeline run with Infer, a potential Null Dereference was detected in the BinaryTreeTest class. The analysis flagged the following line as a potential issue:
src/test/java/com/thealgorithms/datastructures/trees/BinaryTreeTest.java:38: error: Null Dereference(NULLPTR_DEREFERENCE)
BinaryTree$Node BinaryTree.getRoot()could be null (from the call toBinaryTree()on line 28) and is dereferenced.To solve the build problem, if I wish, I can apply a temporary fix to prevent the test from failing on the BinaryTreeTest class (e.g., by adding a null check in getRoot())
@siriak Let me know how to proceed
Hey @lorduke22, I’m facing the same conflict issue due to the failing Infer run check. I’m stuck and could use some guidance if you have any insights on resolving it.
@siriak I should have solved the problem in this PR. Hi @Chiefpatwal, the problem lies in the BinaryTreeTest class I see the getRoot() method may return null if the root node has been removed and there are no more nodes in the tree. This is why Infer reports a potential NullPointerException when attempting to access the date field in t.getRoot().data. To resolve the error, I added a null check on getRoot() in test2.
Feel free to add the following control to your code