Skip to content

Commit

Permalink
Added spotless plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
javadev authored Jan 7, 2022
1 parent 065bcbd commit bebd258
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 26 deletions.
12 changes: 12 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
kotlin("jvm") version "1.6.10"
jacoco
id("org.sonarqube") version "3.3"
id("com.diffplug.spotless") version "6.1.2"
`maven-publish`
}

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

spotless {
kotlin {
encoding("UTF-8")
target("**/*.kt")
ktlint("0.43.0")
toggleOffOn()
trimTrailingWhitespace()
endWithNewline()
}
}

tasks {
jacocoTestReport {
reports {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ class Solution {
return f
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class Solution {
}
return s.substring((lpsCenter - lpsRadius + 1) / 2, (lpsCenter + lpsRadius - 1) / 2)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class Solution {
}
return buf.toString()
}
}
}
19 changes: 9 additions & 10 deletions src/main/kotlin/g0001_0100/s0009_palindrome_number/Solution.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package g0001_0100.s0009_palindrome_number

class Solution {
fun isPalindrome(x: Int): Boolean {
if (x < 0) return false
var rev = 0
var localX = x
while (localX > 0)
{
rev *= 10
rev += localX % 10
localX /= 10
}
return rev == x
if (x < 0) return false
var rev = 0
var localX = x
while (localX > 0) {
rev *= 10
rev += localX % 10
localX /= 10
}
return rev == x
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ class Solution {
cache[i][j] = result
return result
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ class Solution {
}
return num - div * one
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ class Solution {
}
return localX
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package g0801_0900.s0864_shortest_path_to_get_all_keys

import java.util.*
import java.util.LinkedList
import java.util.Queue

class Solution {
private var m = 0
Expand Down Expand Up @@ -75,8 +76,8 @@ class Solution {
// use & to see if we have the key
// 0 means that the digit we are looking at is 0
// need a 1 at the digit spot which means there is a key there
if (('A' > grid[nx][ny] || grid[nx][ny] > 'F' || nState and (1 shl grid[nx][ny] - 'A') != 0)
&& !visited[nx][ny][nState]
if (('A' > grid[nx][ny] || grid[nx][ny] > 'F' || nState and (1 shl grid[nx][ny] - 'A') != 0) &&
!visited[nx][ny][nState]
) {
q.add(intArrayOf(nx, ny, nState))
visited[nx][ny][nState] = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import org.junit.jupiter.api.Test
class SolutionTest {
@Test
fun isPalindrome() {
assertThat(Solution().maxArea(intArrayOf(1,8,6,2,5,4,8,3,7)), equalTo(49))
assertThat(Solution().maxArea(intArrayOf(1, 8, 6, 2, 5, 4, 8, 3, 7)), equalTo(49))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package g0001_0100.s0012_integer_to_roman

import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat

import org.junit.jupiter.api.Test

class SolutionTest {
Expand All @@ -15,4 +14,4 @@ class SolutionTest {
assertThat(solution.intToRoman(58), equalTo("LVIII"))
assertThat(solution.intToRoman(1994), equalTo("MCMXCIV"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package g0001_0100.s0013_roman_to_integer

import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat

import org.junit.jupiter.api.Test

class SolutionTest {
Expand All @@ -15,5 +14,4 @@ class SolutionTest {
assertThat(solution.romanToInt("LVIII"), equalTo(58))
assertThat(solution.romanToInt("MCMXCIV"), equalTo(1994))
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package g0801_0900.s0864_shortest_path_to_get_all_keys

import org.hamcrest.CoreMatchers.equalTo
import org.hamcrest.MatcherAssert.assertThat

import org.junit.jupiter.api.Test

internal class SolutionTest {
Expand Down

0 comments on commit bebd258

Please sign in to comment.