Skip to content

Commit f43c74b

Browse files
authored
Fixed sonar warnings
1 parent 38050a5 commit f43c74b

File tree

9 files changed

+18
-13
lines changed

9 files changed

+18
-13
lines changed

src/main/kotlin/com_github_leetcode/NestedInteger.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com_github_leetcode
22

3+
@Suppress("kotlin:S6512")
34
class NestedInteger {
45
private var list: MutableList<NestedInteger>? = null
56
private var integer: Int? = null

src/main/kotlin/g0201_0300/s0211_design_add_and_search_words_data_structure/WordDictionary.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ class WordDictionary {
2525
fun dfs(p: TrieNode?, start: Int): Boolean {
2626
if (p == null) return false
2727
if (start == word.length) return p.isWord
28-
if (word[start] == '.') {
28+
return if (word[start] == '.') {
2929
for (i in 0..25) {
3030
if (dfs(p.children[i], start + 1)) {
3131
return true
3232
}
3333
}
34-
return false
34+
false
3535
} else {
3636
val i = word[start] - 'a'
37-
return dfs(p.children[i], start + 1)
37+
dfs(p.children[i], start + 1)
3838
}
3939
}
4040
return dfs(trieTree, 0)

src/main/kotlin/g0301_0400/s0347_top_k_frequent_elements/Solution.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package g0301_0400.s0347_top_k_frequent_elements
88
import java.util.PriorityQueue
99
import java.util.Queue
1010

11+
@Suppress("kotlin:S6518")
1112
class Solution {
1213
fun topKFrequent(nums: IntArray, k: Int): IntArray {
1314
nums.sort()

src/main/kotlin/g0301_0400/s0381_insert_delete_getrandom_o1_duplicates_allowed/RandomizedCollection.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class RandomizedCollection() {
1313
fun insert(x: Int): Boolean {
1414
a2m.add(x)
1515
val pos = a2m.size - 1
16-
if (x in m2a) {
16+
return if (x in m2a) {
1717
m2a[x]!!.add(pos)
18-
return false
18+
false
1919
} else {
2020
m2a[x] = HashSet<Int>()
2121
m2a[x]!!.add(pos)
22-
return true
22+
true
2323
}
2424
}
2525

src/main/kotlin/g0301_0400/s0399_evaluate_division/Solution.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package g0301_0400.s0399_evaluate_division
33
// #Medium #Array #Depth_First_Search #Breadth_First_Search #Graph #Union_Find #Shortest_Path
44
// #2022_11_29_Time_183_ms_(91.49%)_Space_34.6_MB_(95.74%)
55

6+
@Suppress("kotlin:S6518")
67
class Solution {
78
private var root: MutableMap<String?, String?>? = null
89
private var rate: MutableMap<String?, Double>? = null
10+
911
fun calcEquation(
1012
equations: List<List<String?>>,
1113
values: DoubleArray,

src/main/kotlin/g0501_0600/s0508_most_frequent_subtree_sum/Solution.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class Solution {
2828
}
2929

3030
private fun treeSum(node: TreeNode?): Int {
31-
if (node == null) {
32-
return 0
31+
return if (node == null) {
32+
0
3333
} else {
3434
val sum = node.`val` + treeSum(node.left) + treeSum(node.right)
3535
cache[sum] = cache.getOrDefault(sum, 0) + 1
36-
return sum
36+
sum
3737
}
3838
}
3939
}

src/main/kotlin/g0601_0700/s0641_design_circular_deque/MyCircularDeque.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package g0601_0700.s0641_design_circular_deque
33
// #Medium #Array #Design #Linked_List #Queue
44
// #2023_02_10_Time_232_ms_(100.00%)_Space_37.5_MB_(83.33%)
55

6+
@Suppress("kotlin:S6512")
67
class MyCircularDeque(k: Int) {
78
private val data: IntArray
89
private var front: Int

src/main/kotlin/g0601_0700/s0692_top_k_frequent_words/Solution.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ class Solution {
1616
}
1717
val sortedset: SortedSet<Map.Entry<String, Int>> = TreeSet(
1818
java.util.Comparator { (key, value): Map.Entry<String, Int>, (key1, value1): Map.Entry<String, Int> ->
19-
if (value != value1) {
20-
return@Comparator value1 - value
19+
return@Comparator if (value != value1) {
20+
value1 - value
2121
} else {
22-
return@Comparator key.compareTo(key1, ignoreCase = true)
22+
key.compareTo(key1, ignoreCase = true)
2323
}
2424
}
2525
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package g0801_0900.s0843_guess_the_word
1111
* }
1212
*/
1313
class Solution {
14-
interface Master {
14+
fun interface Master {
1515
fun guess(word: String): Int
1616
}
1717

0 commit comments

Comments
 (0)