Fix linting warnings (#9701)

* fix: VariableNaming warnings

* fix: MatchingDeclarationName warnings

* fix: SwallowedException warnings

* fix: UseRequire warnings

* Revert "fix: MatchingDeclarationName warnings"

This reverts commit 9475af5052.
This commit is contained in:
alexban011 2023-07-26 07:30:14 +03:00 committed by GitHub
parent 3c76e2bc64
commit 5f8c675512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -183,7 +183,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable {
val b: VersionResponse = r.body() val b: VersionResponse = r.body()
b.version == 2 b.version == 2
} }
} catch (e: IllegalArgumentException) { } catch (_: IllegalArgumentException) {
false false
} catch (e: Throwable) { } catch (e: Throwable) {
Log.error("Unexpected exception calling version endpoint for '$baseUrl': $e") Log.error("Unexpected exception calling version endpoint for '$baseUrl': $e")
@ -204,7 +204,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable {
val b: ApiErrorResponse = r.body() val b: ApiErrorResponse = r.body()
b.statusCode == ApiStatusCode.Unauthenticated b.statusCode == ApiStatusCode.Unauthenticated
} }
} catch (e: IllegalArgumentException) { } catch (_: IllegalArgumentException) {
false false
} catch (e: Throwable) { } catch (e: Throwable) {
Log.error("Unexpected exception calling WebSocket endpoint for '$baseUrl': $e") Log.error("Unexpected exception calling WebSocket endpoint for '$baseUrl': $e")
@ -339,9 +339,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable {
* This function may also throw arbitrary exceptions for network failures. * This function may also throw arbitrary exceptions for network failures.
*/ */
suspend fun awaitPing(size: Int = 2, timeout: Long? = null): Double? { suspend fun awaitPing(size: Int = 2, timeout: Long? = null): Double? {
if (size < 2) { require(size < 2) { "Size too small to identify ping responses uniquely" }
throw IllegalArgumentException("Size too small to identify ping responses uniquely")
}
val body = ByteArray(size) val body = ByteArray(size)
Random().nextBytes(body) Random().nextBytes(body)
@ -371,7 +369,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable {
throw exception throw exception
} }
}.toDouble() / 10e6 }.toDouble() / 10e6
} catch (c: ClosedReceiveChannelException) { } catch (_: ClosedReceiveChannelException) {
return null return null
} finally { } finally {
synchronized(this) { synchronized(this) {
@ -448,7 +446,7 @@ class ApiV2(private val baseUrl: String) : ApiV2Wrapper(baseUrl), Disposable {
Concurrency.run { Concurrency.run {
try { try {
c.send((msg as WebSocketMessageWithContent).content) c.send((msg as WebSocketMessageWithContent).content)
} catch (closed: ClosedSendChannelException) { } catch (_: ClosedSendChannelException) {
delay(10) delay(10)
eventChannelList.remove(c) eventChannelList.remove(c)
} catch (t: Throwable) { } catch (t: Throwable) {

View File

@ -50,7 +50,7 @@ class OnlineMultiplayerServer(
if (result.isNotEmpty()) { if (result.isNotEmpty()) {
featureSet = try { featureSet = try {
json().fromJson(ServerFeatureSet::class.java, result) json().fromJson(ServerFeatureSet::class.java, result)
} catch (ex: Exception) { } catch (_: Exception) {
// The server does not support server feature set - not an error! // The server does not support server feature set - not an error!
ServerFeatureSet() ServerFeatureSet()
} }