Skip to content

Commit bebd258

Browse files
authored
Added spotless plugin.
1 parent 065bcbd commit bebd258

File tree

13 files changed

+33
-26
lines changed

13 files changed

+33
-26
lines changed

build.gradle.kts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
kotlin("jvm") version "1.6.10"
33
jacoco
44
id("org.sonarqube") version "3.3"
5+
id("com.diffplug.spotless") version "6.1.2"
56
`maven-publish`
67
}
78

@@ -38,6 +39,17 @@ tasks.withType<JavaCompile>() {
3839
options.encoding = "UTF-8"
3940
}
4041

42+
spotless {
43+
kotlin {
44+
encoding("UTF-8")
45+
target("**/*.kt")
46+
ktlint("0.43.0")
47+
toggleOffOn()
48+
trimTrailingWhitespace()
49+
endWithNewline()
50+
}
51+
}
52+
4153
tasks {
4254
jacocoTestReport {
4355
reports {

src/main/kotlin/g0001_0100/s0004_median_of_two_sorted_arrays/Solution.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ class Solution {
2222
return f
2323
}
2424
}
25-

src/main/kotlin/g0001_0100/s0005_longest_palindromic_substring/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ class Solution {
3232
}
3333
return s.substring((lpsCenter - lpsRadius + 1) / 2, (lpsCenter + lpsRadius - 1) / 2)
3434
}
35-
}
35+
}

src/main/kotlin/g0001_0100/s0006_zigzag_conversion/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ class Solution {
2929
}
3030
return buf.toString()
3131
}
32-
}
32+
}

src/main/kotlin/g0001_0100/s0009_palindrome_number/Solution.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package g0001_0100.s0009_palindrome_number
22

33
class Solution {
44
fun isPalindrome(x: Int): Boolean {
5-
if (x < 0) return false
6-
var rev = 0
7-
var localX = x
8-
while (localX > 0)
9-
{
10-
rev *= 10
11-
rev += localX % 10
12-
localX /= 10
13-
}
14-
return rev == x
5+
if (x < 0) return false
6+
var rev = 0
7+
var localX = x
8+
while (localX > 0) {
9+
rev *= 10
10+
rev += localX % 10
11+
localX /= 10
12+
}
13+
return rev == x
1514
}
1615
}

src/main/kotlin/g0001_0100/s0010_regular_expression_matching/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class Solution {
2525
cache[i][j] = result
2626
return result
2727
}
28-
}
28+
}

src/main/kotlin/g0001_0100/s0012_integer_to_roman/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ class Solution {
5555
}
5656
return num - div * one
5757
}
58-
}
58+
}

src/main/kotlin/g0001_0100/s0013_roman_to_integer/Solution.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ class Solution {
3232
}
3333
return localX
3434
}
35-
}
35+
}

src/main/kotlin/g0801_0900/s0864_shortest_path_to_get_all_keys/Solution.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package g0801_0900.s0864_shortest_path_to_get_all_keys
22

3-
import java.util.*
3+
import java.util.LinkedList
4+
import java.util.Queue
45

56
class Solution {
67
private var m = 0
@@ -75,8 +76,8 @@ class Solution {
7576
// use & to see if we have the key
7677
// 0 means that the digit we are looking at is 0
7778
// need a 1 at the digit spot which means there is a key there
78-
if (('A' > grid[nx][ny] || grid[nx][ny] > 'F' || nState and (1 shl grid[nx][ny] - 'A') != 0)
79-
&& !visited[nx][ny][nState]
79+
if (('A' > grid[nx][ny] || grid[nx][ny] > 'F' || nState and (1 shl grid[nx][ny] - 'A') != 0) &&
80+
!visited[nx][ny][nState]
8081
) {
8182
q.add(intArrayOf(nx, ny, nState))
8283
visited[nx][ny][nState] = true

src/test/kotlin/g0001_0100/s0011_container_with_most_water/SolutionTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import org.junit.jupiter.api.Test
77
class SolutionTest {
88
@Test
99
fun isPalindrome() {
10-
assertThat(Solution().maxArea(intArrayOf(1,8,6,2,5,4,8,3,7)), equalTo(49))
10+
assertThat(Solution().maxArea(intArrayOf(1, 8, 6, 2, 5, 4, 8, 3, 7)), equalTo(49))
1111
}
1212
}

src/test/kotlin/g0001_0100/s0012_integer_to_roman/SolutionTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package g0001_0100.s0012_integer_to_roman
22

33
import org.hamcrest.CoreMatchers.equalTo
44
import org.hamcrest.MatcherAssert.assertThat
5-
65
import org.junit.jupiter.api.Test
76

87
class SolutionTest {
@@ -15,4 +14,4 @@ class SolutionTest {
1514
assertThat(solution.intToRoman(58), equalTo("LVIII"))
1615
assertThat(solution.intToRoman(1994), equalTo("MCMXCIV"))
1716
}
18-
}
17+
}

src/test/kotlin/g0001_0100/s0013_roman_to_integer/SolutionTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package g0001_0100.s0013_roman_to_integer
22

33
import org.hamcrest.CoreMatchers.equalTo
44
import org.hamcrest.MatcherAssert.assertThat
5-
65
import org.junit.jupiter.api.Test
76

87
class SolutionTest {
@@ -15,5 +14,4 @@ class SolutionTest {
1514
assertThat(solution.romanToInt("LVIII"), equalTo(58))
1615
assertThat(solution.romanToInt("MCMXCIV"), equalTo(1994))
1716
}
18-
19-
}
17+
}

src/test/kotlin/g0801_0900/s0864_shortest_path_to_get_all_keys/SolutionTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package g0801_0900.s0864_shortest_path_to_get_all_keys
22

33
import org.hamcrest.CoreMatchers.equalTo
44
import org.hamcrest.MatcherAssert.assertThat
5-
65
import org.junit.jupiter.api.Test
76

87
internal class SolutionTest {

0 commit comments

Comments
 (0)