Repository: TheAlgorithms/Java
Pull request #5436 (2024-08-29 20:22:40)

style: use proper spelling
Fixed few naming and typo issues.

<!--
Thank you for your contribution!
In order to reduce the number of notifications sent to the maintainers, please:
- create your PR as draft, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests,
- make sure that all of the CI checks pass,
- mark your PR as ready for review, cf. https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review
-->

<!-- For completed items, change [ ] to [x] -->

- [x] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Java/blob/master/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-commenter: ## [Codecov](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) Report
Attention: Patch coverage is `0%` with `4 lines` in your changes missing coverage. Please review.
> Project coverage is 50.73%. Comparing base [(`c57e02d`)](https://app.codecov.io/gh/TheAlgorithms/Java/commit/c57e02dc856e61118d89609f34900ff6d4d0376c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) to head [(`44ca336`)](https://app.codecov.io/gh/TheAlgorithms/Java/commit/44ca336c59bb34cf0b98853d7c59f8024cb3dcbe?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms).

| [Files with missing lines](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) | Patch % | Lines |
|---|---|---|
| [...ava/com/thealgorithms/stacks/LargestRectangle.java](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fcom%2Fthealgorithms%2Fstacks%2FLargestRectangle.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms#diff-c3JjL21haW4vamF2YS9jb20vdGhlYWxnb3JpdGhtcy9zdGFja3MvTGFyZ2VzdFJlY3RhbmdsZS5qYXZh) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) |
| [...s/datastructures/lists/MergeKSortedLinkedList.java](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fcom%2Fthealgorithms%2Fdatastructures%2Flists%2FMergeKSortedLinkedList.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms#diff-c3JjL21haW4vamF2YS9jb20vdGhlYWxnb3JpdGhtcy9kYXRhc3RydWN0dXJlcy9saXN0cy9NZXJnZUtTb3J0ZWRMaW5rZWRMaXN0LmphdmE=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) |
| [src/main/java/com/thealgorithms/strings/Upper.java](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fcom%2Fthealgorithms%2Fstrings%2FUpper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms#diff-c3JjL21haW4vamF2YS9jb20vdGhlYWxnb3JpdGhtcy9zdHJpbmdzL1VwcGVyLmphdmE=) | 0.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms) |

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##             master    #5436      +/-   ##
============================================
+ Coverage     50.71%   50.73%   +0.01%     
- Complexity     3136     3137       +1     
============================================
  Files           523      523              
  Lines         15128    15128              
  Branches       2880     2880              
============================================
+ Hits           7672     7675       +3     
+ Misses         7130     7129       -1     
+ Partials        326      324       -2     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/TheAlgorithms/Java/pull/5436?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TheAlgorithms).


Patch:
diff --git a/pmd-exclude.properties b/pmd-exclude.properties
index 1e7a0954..f6ee8819 100644
--- a/pmd-exclude.properties
+++ b/pmd-exclude.properties
@@ -12,7 +12,7 @@ com.thealgorithms.datastructures.crdt.LWWElementSet=UselessParentheses
 com.thealgorithms.datastructures.crdt.Pair=UnusedPrivateField
 com.thealgorithms.datastructures.graphs.AStar=UselessParentheses
 com.thealgorithms.datastructures.graphs.AdjacencyMatrixGraph=CollapsibleIfStatements,UnnecessaryFullyQualifiedName,UselessParentheses
-com.thealgorithms.datastructures.graphs.BipartiteGrapfDFS=CollapsibleIfStatements
+com.thealgorithms.datastructures.graphs.BipartiteGraphDFS=CollapsibleIfStatements
 com.thealgorithms.datastructures.graphs.Kruskal=UselessParentheses
 com.thealgorithms.datastructures.hashmap.hashing.HashMapCuckooHashing=UselessParentheses
 com.thealgorithms.datastructures.heaps.FibonacciHeap=UselessParentheses
diff --git a/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java b/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java
similarity index 97%
rename from src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java
rename to src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java
index 4cc14bfd..e8d2b8fd 100644
--- a/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java
+++ b/src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGraphDFS.java
@@ -14,8 +14,8 @@ import java.util.Arrays;
  *
  * Output : YES
  */
-public final class BipartiteGrapfDFS {
-    private BipartiteGrapfDFS() {
+public final class BipartiteGraphDFS {
+    private BipartiteGraphDFS() {
     }
 
     private static boolean bipartite(int v, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
diff --git a/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java b/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedList.java
similarity index 96%
rename from src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java
rename to src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedList.java
index ece17890..0eac20d2 100644
--- a/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedlist.java
+++ b/src/main/java/com/thealgorithms/datastructures/lists/MergeKSortedLinkedList.java
@@ -7,7 +7,7 @@ import java.util.PriorityQueue;
 /**
  * @author Arun Pandey (https://github.com/pandeyarun709)
  */
-public class MergeKSortedLinkedlist {
+public class MergeKSortedLinkedList {
 
     /**
      * This function merge K sorted LinkedList
diff --git a/src/main/java/com/thealgorithms/stacks/LargestRectangle.java b/src/main/java/com/thealgorithms/stacks/LargestRectangle.java
index 0404d9c9..006e0363 100644
--- a/src/main/java/com/thealgorithms/stacks/LargestRectangle.java
+++ b/src/main/java/com/thealgorithms/stacks/LargestRectangle.java
@@ -11,7 +11,7 @@ public final class LargestRectangle {
     private LargestRectangle() {
     }
 
-    public static String largestRectanglehistogram(int[] heights) {
+    public static String largestRectangleHistogram(int[] heights) {
         int n = heights.length;
         int maxArea = 0;
         Stack<int[]> st = new Stack<>();
@@ -32,7 +32,7 @@ public final class LargestRectangle {
     }
 
     public static void main(String[] args) {
-        assert largestRectanglehistogram(new int[] {2, 1, 5, 6, 2, 3}).equals("10");
-        assert largestRectanglehistogram(new int[] {2, 4}).equals("4");
+        assert largestRectangleHistogram(new int[] {2, 1, 5, 6, 2, 3}).equals("10");
+        assert largestRectangleHistogram(new int[] {2, 4}).equals("4");
     }
 }
diff --git a/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java b/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java
index 5f9d27b4..7c22cd8a 100644
--- a/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java
+++ b/src/main/java/com/thealgorithms/strings/ReverseWordsInString.java
@@ -13,7 +13,6 @@ public final class ReverseWordsInString {
      * @param s the input string
      * @return A string created by reversing the order of the words in {@code s}
      */
-
     public static String reverseWordsInString(final String s) {
         var words = s.trim().split("\\s+");
         Collections.reverse(Arrays.asList(words));
diff --git a/src/main/java/com/thealgorithms/strings/Upper.java b/src/main/java/com/thealgorithms/strings/Upper.java
index 0fc87a9d..fa9a4084 100644
--- a/src/main/java/com/thealgorithms/strings/Upper.java
+++ b/src/main/java/com/thealgorithms/strings/Upper.java
@@ -15,13 +15,13 @@ public final class Upper {
     }
 
     /**
-     * Converts all of the characters in this {@code String} to upper case
+     * Converts all the characters in this {@code String} to upper case
      *
      * @param s the string to convert
      * @return the {@code String}, converted to uppercase.
      */
     public static String toUpperCase(String s) {
-        if (s == null || "".equals(s)) {
+        if (s == null || s.isEmpty()) {
             return s;
         }
         char[] values = s.toCharArray();


Test patch:
diff --git a/src/test/java/com/thealgorithms/stacks/LargestRectangleTest.java b/src/test/java/com/thealgorithms/stacks/LargestRectangleTest.java
index 023f20a1..a54372ad 100644
--- a/src/test/java/com/thealgorithms/stacks/LargestRectangleTest.java
+++ b/src/test/java/com/thealgorithms/stacks/LargestRectangleTest.java
@@ -11,19 +11,19 @@ public class LargestRectangleTest {
         // Typical case with mixed heights
         int[] heights = {2, 1, 5, 6, 2, 3};
         String expected = "10";
-        String result = LargestRectangle.largestRectanglehistogram(heights);
+        String result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
 
         // Another typical case with increasing heights
         heights = new int[] {2, 4};
         expected = "4";
-        result = LargestRectangle.largestRectanglehistogram(heights);
+        result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
 
         // Case with multiple bars of the same height
         heights = new int[] {4, 4, 4, 4};
         expected = "16";
-        result = LargestRectangle.largestRectanglehistogram(heights);
+        result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
     }
 
@@ -32,19 +32,19 @@ public class LargestRectangleTest {
         // Edge case with an empty array
         int[] heights = {};
         String expected = "0";
-        String result = LargestRectangle.largestRectanglehistogram(heights);
+        String result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
 
         // Edge case with a single bar
         heights = new int[] {5};
         expected = "5";
-        result = LargestRectangle.largestRectanglehistogram(heights);
+        result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
 
         // Edge case with all bars of height 0
         heights = new int[] {0, 0, 0};
         expected = "0";
-        result = LargestRectangle.largestRectanglehistogram(heights);
+        result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
     }
 
@@ -56,7 +56,7 @@ public class LargestRectangleTest {
             heights[i] = 1;
         }
         String expected = "10000";
-        String result = LargestRectangle.largestRectanglehistogram(heights);
+        String result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
     }
 
@@ -65,13 +65,13 @@ public class LargestRectangleTest {
         // Complex case with a mix of heights
         int[] heights = {6, 2, 5, 4, 5, 1, 6};
         String expected = "12";
-        String result = LargestRectangle.largestRectanglehistogram(heights);
+        String result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
 
         // Case with a peak in the middle
         heights = new int[] {2, 1, 5, 6, 2, 3, 1};
         expected = "10";
-        result = LargestRectangle.largestRectanglehistogram(heights);
+        result = LargestRectangle.largestRectangleHistogram(heights);
         assertEquals(expected, result);
     }
 }