Skip to content

Commit c2cff66

Browse files
committed
fix code analytics
Signed-off-by: alperozturk <alper_ozturk@proton.me>
1 parent 2ee0f84 commit c2cff66

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

library/src/androidTest/java/com/owncloud/android/ResponseFormatDetectorTests.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import junit.framework.TestCase.assertEquals
1313
import org.junit.Test
1414

1515
class ResponseFormatDetectorTests {
16-
1716
@Test
1817
fun testJsonDetection() {
1918
val json = """{ "name": "Alice", "age": 30 }"""

library/src/main/java/com/owncloud/android/lib/common/utils/responseFormat/ResponseFormat.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
package com.owncloud.android.lib.common.utils.responseFormat
99

1010
enum class ResponseFormat {
11-
JSON, XML, UNKNOWN
11+
JSON,
12+
XML,
13+
UNKNOWN
1214
}

library/src/main/java/com/owncloud/android/lib/common/utils/responseFormat/ResponseFormatDetector.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ object ResponseFormatDetector {
1818
private const val JSON_OBJECT_PREFIX = "{"
1919
private const val JSON_ARRAY_PREFIX = "["
2020

21-
fun detectFormat(input: String): ResponseFormat {
22-
return when {
21+
fun detectFormat(input: String): ResponseFormat =
22+
when {
2323
isJson(input) -> ResponseFormat.JSON
2424
isXml(input) -> ResponseFormat.XML
2525
else -> ResponseFormat.UNKNOWN
2626
}
27-
}
2827

28+
@Suppress("TooGenericExceptionCaught")
2929
private fun isJson(input: String): Boolean {
3030
return try {
3131
val trimmed = input.trim()
@@ -43,8 +43,9 @@ object ResponseFormatDetector {
4343
}
4444
}
4545

46-
private fun isXml(input: String): Boolean {
47-
return try {
46+
@Suppress("TooGenericExceptionCaught")
47+
private fun isXml(input: String): Boolean =
48+
try {
4849
val factory = DocumentBuilderFactory.newInstance()
4950
val builder = factory.newDocumentBuilder()
5051
val stream = ByteArrayInputStream(input.toByteArray())
@@ -54,5 +55,4 @@ object ResponseFormatDetector {
5455
Log_OC.e(TAG, "Exception isXml: $e")
5556
false
5657
}
57-
}
5858
}

0 commit comments

Comments
 (0)