Skip to content

style: include VA_FORMAT_STRING_USES_NEWLINE #5151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
<Match>
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match>
<Match>
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE" />
</Match>
<Match>
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
</Match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public boolean checkTableContainsKey(int key) {
public double checkLoadFactor() {
double factor = (double) size / tableSize;
if (factor > .7) {
System.out.printf("Load factor is %.2f , rehashing table\n", factor);
System.out.printf("Load factor is %.2f , rehashing table%n", factor);
reHashTableIncreasesTableSize();
}
return factor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void main(String[] args) {
break;
}
case 6: {
System.out.printf("Load factor is: %.2f\n", h.checkLoadFactor());
System.out.printf("Load factor is: %.2f%n", h.checkLoadFactor());
break;
}
case 7: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static void main(String[] args) {

System.out.println("Enter the number of elements to be inserted: ");
int n = sc.nextInt();
System.out.printf("Enter the %d elements: \n", n);
System.out.printf("Enter the %d elements: %n", n);
while (n-- > 0) {
singlyLinkedList.insert(sc.nextInt());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/others/TowerOfHanoi.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void shift(int n, String startPole, String intermediatePole, Strin
// Shift function is called in recursion for swapping the n-1 disc from the startPole to
// the intermediatePole
shift(n - 1, startPole, endPole, intermediatePole);
System.out.format("Move %d from %s to %s\n", n, startPole, endPole); // Result Printing
System.out.format("Move %d from %s to %s%n", n, startPole, endPole); // Result Printing
// Shift function is called in recursion for swapping the n-1 disc from the
// intermediatePole to the endPole
shift(n - 1, intermediatePole, startPole, endPole);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Node monteCarloTreeSearch(Node rootNode) {

winnerNode = getWinnerNode(rootNode);
printScores(rootNode);
System.out.format("\nThe optimal node is: %02d\n", rootNode.childNodes.indexOf(winnerNode) + 1);
System.out.format("%nThe optimal node is: %02d%n", rootNode.childNodes.indexOf(winnerNode) + 1);

return winnerNode;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/thealgorithms/sorts/InsertionSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public static void main(String[] args) {

InsertionSort insertionSort = new InsertionSort();
double insertionTime = measureApproxExecTime(insertionSort::sort, randomArray);
System.out.printf("Original insertion time: %5.2f sec.\n", insertionTime);
System.out.printf("Original insertion time: %5.2f sec.%n", insertionTime);

double insertionSentinelTime = measureApproxExecTime(insertionSort::sentinelSort, copyRandomArray);
System.out.printf("Sentinel insertion time: %5.2f sec.\n", insertionSentinelTime);
System.out.printf("Sentinel insertion time: %5.2f sec.%n", insertionSentinelTime);

// ~ 1.5 time sentinel sort is faster, then classical Insertion sort implementation.
System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort\n", insertionTime / insertionSentinelTime);
System.out.printf("Sentinel insertion is %f3.2 time faster than Original insertion sort%n", insertionTime / insertionSentinelTime);
}

private static double measureApproxExecTime(Function<Double[], Double[]> sortAlgorithm, Double[] randomArray) {
Expand Down