Skip to content

Commit

Permalink
chore: Mega Linters
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <ahmed.moussa@iohk.io>
  • Loading branch information
hamada147 committed Mar 19, 2024
1 parent 22bb989 commit ccfc556
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
root = true

[*.{kt,kts}]
ktlint_experimental = disabled
ktlint_code_style = intellij_idea
ktlint_standard_no_semi = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_no-empty-file = disabled
ktlint_standard_backing-property-naming = disabled
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ data class AttachmentDescriptor @JvmOverloads constructor(
val data: AttachmentData,
val filename: Array<String>? = null,
val format: String? = null,
val lastModTime: String? = null, // TODO(Date format)
// TODO(Date format)
val lastModTime: String? = null,
val byteCount: Int? = null,
val description: String? = null
) : AttachmentData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kotlinx.serialization.Serializable
* @property entropy The entropy for the credential request.
* @property nonce The nonce for the credential request.
*/
@Suppress("ktlint:standard:property-naming")
interface CredentialRequest {
val cred_def_id: String
val blinded_ms: CredentialRequestBlindedMS
Expand All @@ -38,6 +39,7 @@ interface CredentialRequestBlindedMS {
* @property v_dash_cap The value used in the proof calculation.
* @property m_caps The map of attribute names to their corresponding blinded value commitments.
*/
@Suppress("ktlint:standard:property-naming")
interface CredentialRequestBlindedMSCorrectnessProof {
val c: String
val v_dash_cap: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ sealed class PrismAgentError : KnownPrismError() {
get() = "Failed to onboard.\nStatus code: $statusCode\nResponse: $response"
}

class InvalidCredentialError @JvmOverloads constructor(private val credential: Credential) :
class InvalidCredentialError constructor(private val credential: Credential) :
PrismAgentError() {
override val code: Int
get() = 120
Expand All @@ -93,7 +93,7 @@ sealed class PrismAgentError : KnownPrismError() {
get() = "Invalid credential type, ${credential::class} is not supported"
}

class InvalidCredentialFormatError @JvmOverloads constructor(private val expectedFormat: CredentialType) :
class InvalidCredentialFormatError constructor(private val expectedFormat: CredentialType) :
PrismAgentError() {
override val code: Int
get() = 121
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,31 @@ class ConnectionAccept {
* @return true if this [Body] object is equal to the specified [other] object, false otherwise.
*/
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
if (this === other) {
return true
}
if (other == null || this::class != other::class) {
return false
}

other as Body

if (goalCode != other.goalCode) return false
if (goal != other.goal) return false
if (goalCode != other.goalCode) {
return false
}
if (goal != other.goal) {
return false
}
if (accept != null) {
if (other.accept == null) return false
if (!accept.contentEquals(other.accept)) return false
} else if (other.accept != null) return false
if (other.accept == null) {
return false
}
if (!accept.contentEquals(other.accept)) {
return false
}
} else if (other.accept != null) {
return false
}

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,31 @@ class ConnectionRequest {
* @return true if the objects are equal, false otherwise.
*/
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
if (this === other) {
return true
}
if (other == null || this::class != other::class) {
return false
}

other as Body

if (goalCode != other.goalCode) return false
if (goal != other.goal) return false
if (goalCode != other.goalCode) {
return false
}
if (goal != other.goal) {
return false
}
if (accept != null) {
if (other.accept == null) return false
if (!accept.contentEquals(other.accept)) return false
} else if (other.accept != null) return false
if (other.accept == null) {
return false
}
if (!accept.contentEquals(other.accept)) {
return false
}
} else if (other.accept != null) {
return false
}

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ constructor(
/**
* Represents the body of the out-of-band invitation message.
*/
@OptIn(ExperimentalSerializationApi::class)
@Serializable
data class Body(
data class Body constructor(
@SerialName(GOAL_CODE)
@EncodeDefault
val goalCode: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,38 @@ data class ProofTypes(
* @return true if the objects are equal, false otherwise.
*/
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
if (this === other) {
return true
}
if (other == null || this::class != other::class) {
return false
}

other as ProofTypes

if (schema != other.schema) return false
if (schema != other.schema) {
return false
}
if (requiredFields != null) {
if (other.requiredFields == null) return false
if (!requiredFields.contentEquals(other.requiredFields)) return false
} else if (other.requiredFields != null) return false
if (other.requiredFields == null) {
return false
}
if (!requiredFields.contentEquals(other.requiredFields)) {
return false
}
} else if (other.requiredFields != null) {
return false
}
if (trustIssuers != null) {
if (other.trustIssuers == null) return false
if (!trustIssuers.contentEquals(other.trustIssuers)) return false
} else if (other.trustIssuers != null) return false
if (other.trustIssuers == null) {
return false
}
if (!trustIssuers.contentEquals(other.trustIssuers)) {
return false
}
} else if (other.trustIssuers != null) {
return false
}

return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class MercuryTests {
fun testSendMessage_shouldThrowError_whenServiceAbsent() = runTest {
val idDid = DID("did", "prism", "123")
val allAuthentication = DIDDocument.Authentication(arrayOf(), arrayOf())
val resolveDIDReturn = DIDDocument(idDid, arrayOf(/*service,*/ allAuthentication))
// val resolveDIDReturn = DIDDocument(idDid, arrayOf(/*service,*/ allAuthentication))
val resolveDIDReturn = DIDDocument(idDid, arrayOf(allAuthentication))
castorMock.resolveDIDReturn = resolveDIDReturn
val msg = Message(piuri = "", body = "", from = DID("test", "method", "id"), to = DID("test", "method", "id"))
assertFailsWith<MercuryError.NoValidServiceFoundError> { sut.sendMessage(msg) }
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.gradle.internal.os.OperatingSystem
import java.util.Base64

val publishedMavenId = "io.iohk.atala.prism.walletsdk"
val os: OperatingSystem = OperatingSystem.current()

plugins {
id("com.android.library") version "8.1.4" apply false
Expand Down Expand Up @@ -61,6 +63,11 @@ allprojects {
} else if (requested.group == "com.nimbusds") {
// Making sure we are using the latest version of `nimbus-jose-jwt` instead if 9.25.6
useTarget("com.nimbusds:nimbus-jose-jwt:9.31")
} else if (requested.group == "com.google.protobuf") {
// Because of Duplicate Classes issue happening on the sampleapp module
if (requested.name == "protobuf-javalite" || requested.name == "protobuf-java") {
useTarget("com.google.protobuf:protobuf-java:3.14.0")
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion protosLib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ val jarPathConf: Configuration by configurations.creating {

dependencies {
// This is needed for includes, ref: https://github.com/google/protobuf-gradle-plugin/issues/41#issuecomment-143884188
compileOnly("com.google.protobuf:protobuf-java:3.12.0")
compileOnly("com.google.protobuf:protobuf-java:3.14.0")
}

sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion sampleapp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp") version("1.9.22-1.0.16")
id("com.google.devtools.ksp") version "1.9.22-1.0.16"
}

apply(plugin = "kotlinx-atomicfu")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MessagesFragment : Fragment() {

// Set up the spinner with the options
context?.let {
val adapter = CustomArrayAdapter(it, R.layout.support_simple_spinner_dropdown_item, credentials)
val adapter = CustomArrayAdapter(it, android.R.layout.simple_spinner_dropdown_item, credentials)
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
dialogBinding.spinner.adapter = adapter

Expand Down

0 comments on commit ccfc556

Please sign in to comment.