Skip to content

Commit 5936f74

Browse files
committed
The Spotless Gradle plugin has been added
1 parent 29f7c04 commit 5936f74

File tree

2,160 files changed

+20880
-19338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,160 files changed

+20880
-19338
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
java-version: '17'
2525
cache: 'gradle'
2626
- name: Build with Gradle
27-
run: chmod +x gradlew && ./gradlew build
27+
run: chmod +x gradlew && ./gradlew spotlessCheck build

build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'com.diffplug.spotless' version '6.25.0'
34
id 'checkstyle'
45
}
56

@@ -54,3 +55,18 @@ checkstyle {
5455
toolVersion = '6.17'
5556
config = rootProject.resources.text.fromFile('fishercoder_checkstyle.xml')
5657
}
58+
59+
spotless {
60+
java {
61+
encoding 'UTF-8'
62+
target fileTree(projectDir) {
63+
include '**/src/**/*.java'
64+
exclude '**/build/**'
65+
}
66+
importOrder '\\#', '', '*'
67+
removeUnusedImports()
68+
googleJavaFormat('1.22.0').aosp()
69+
toggleOffOn()
70+
endWithNewline()
71+
}
72+
}

src/main/java/com/fishercoder/common/classes/Employee.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,13 @@
33
import java.util.List;
44

55
public class Employee {
6-
/**
7-
* It's the unique id of each node;
8-
* unique id of this employee
9-
*/
6+
/** It's the unique id of each node; unique id of this employee */
107
public int id;
11-
/**
12-
* the importance value of this employee
13-
*/
8+
9+
/** the importance value of this employee */
1410
public int importance;
15-
/**
16-
* the id of direct subordinates
17-
*/
11+
12+
/** the id of direct subordinates */
1813
public List<Integer> subordinates;
1914

2015
public Employee(int id, int importance, List<Integer> subordinates) {

src/main/java/com/fishercoder/common/classes/Interval.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.fishercoder.common.classes;
22

3-
/**
4-
* This is a class used by one OJ problem: MeetingRooms
5-
*/
3+
/** This is a class used by one OJ problem: MeetingRooms */
64
public class Interval implements Comparable<Interval> {
75
public int start;
86
public int end;
@@ -45,7 +43,7 @@ public Interval(int s, int e) {
4543
@Override
4644
public int compareTo(Interval o) {
4745
int compareStart = o.start;
48-
//ascending order
46+
// ascending order
4947
return this.start - compareStart;
5048
}
5149

src/main/java/com/fishercoder/common/classes/ListNode.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.fishercoder.common.classes;
22

33
import com.fishercoder.common.utils.CommonUtils;
4-
54
import java.util.List;
65

76
/**
@@ -86,5 +85,4 @@ public int hashCode() {
8685
public String toString() {
8786
return "ListNode{" + "val=" + val + ", next=" + next + '}';
8887
}
89-
9088
}

src/main/java/com/fishercoder/common/classes/NestedInteger.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,4 @@ public static String printNi(NestedInteger thisNi, StringBuilder sb) {
6262
sb.append("]");
6363
return sb.toString();
6464
}
65-
6665
}

src/main/java/com/fishercoder/common/classes/Node.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ public Node(int val, List<Node> children) {
2222
this.children = children;
2323
}
2424

25-
//todo: implement this method
25+
// todo: implement this method
2626

27-
/**
28-
* return a N-ary tree based on the preorder values
29-
*/
27+
/** return a N-ary tree based on the preorder values */
3028
public static Node createNaryTree(List<Integer> preorderValues) {
3129
return null;
3230
}

src/main/java/com/fishercoder/common/classes/Point.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.fishercoder.common.classes;
22

3-
/**
4-
* Created by fishercoder on 12/31/16.
5-
*/
3+
/** Created by fishercoder on 12/31/16. */
64
public class Point {
75
public int x;
86
public int y;

src/main/java/com/fishercoder/common/classes/UndirectedGraphNode.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
/**
7-
* Created by fishercoder1534 on 9/30/16.
8-
*/
6+
/** Created by fishercoder1534 on 9/30/16. */
97
public class UndirectedGraphNode {
108
public int val;
119
public List<UndirectedGraphNode> neighbors;

src/main/java/com/fishercoder/common/utils/BTreePrinter.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
/**
88
* Copied this class from
9-
* http://stackoverflow.com/questions/4965335/how-to-print-binary-tree-diagram
10-
* This is an awesome one! It prints out the tree in a very nice fashion.
9+
* http://stackoverflow.com/questions/4965335/how-to-print-binary-tree-diagram This is an awesome
10+
* one! It prints out the tree in a very nice fashion.
1111
*/
1212
public class BTreePrinter {
1313

@@ -55,8 +55,7 @@ private static <T extends Comparable<?>> void printNodeInternal(
5555
for (int j = 0; j < nodes.size(); j++) {
5656
BTreePrinter.printWhitespaces(firstSpaces - i);
5757
if (nodes.get(j) == null) {
58-
BTreePrinter.printWhitespaces(endgeLines + endgeLines + i
59-
+ 1);
58+
BTreePrinter.printWhitespaces(endgeLines + endgeLines + i + 1);
6059
continue;
6160
}
6261

@@ -94,8 +93,7 @@ private static <T extends Comparable<?>> int maxLevel(Node<T> node) {
9493
return 0;
9594
}
9695

97-
return Math.max(BTreePrinter.maxLevel(node.left),
98-
BTreePrinter.maxLevel(node.right)) + 1;
96+
return Math.max(BTreePrinter.maxLevel(node.left), BTreePrinter.maxLevel(node.right)) + 1;
9997
}
10098

10199
private static <T> boolean isAllElementsNull(List<T> list) {
@@ -171,7 +169,6 @@ private static Node<Integer> test2() {
171169
return root;
172170
}
173171

174-
175172
public static class Node<T extends Comparable<?>> {
176173
Node<T> left;
177174
Node<T> right;
@@ -181,5 +178,4 @@ public Node(T data) {
181178
this.data = data;
182179
}
183180
}
184-
185-
}
181+
}

0 commit comments

Comments
 (0)