Skip to content

Commit

Permalink
Add SpeziStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljohanneskraft committed Sep 21, 2024
1 parent 1adfb33 commit 0fb7343
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.stanford.spezi.modules.storage.local

Check warning on line 1 in modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

import org.junit.Test
import kotlin.random.Random

class LocalStorageTests {
data class Letter(val greeting: String)

@Test
fun localStorage() {
val localStorage = LocalStorage()

var greeting = "Hello Paul 👋"
for (index in 0..Random.nextInt(10)) {
greeting += "🚀"
}
val letter = Letter(greeting = greeting)
localStorage.store(letter, settings = LocalStorageSetting.Unencrypted)
val storedLetter: Letter = localStorage.read(settings = LocalStorageSetting.Unencrypted)

assert(letter.greeting == storedLetter.greeting)

localStorage.delete(Letter::class)
localStorage.delete(storageKey = "Letter")
}
}

Check warning on line 26 in modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt#L26 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt:26:2: warning: The file /github/workspace/modules/storage/src/androidTest/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageTests.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package edu.stanford.spezi.modules.storage.local

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

import android.content.Context
import androidx.security.crypto.EncryptedFile

Check warning on line 4 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L4 <detekt.NoUnusedImports>

Unused import
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:4:1: warning: Unused import (detekt.NoUnusedImports)

Check warning on line 4 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L4 <detekt.UnusedImports>

The import 'androidx.security.crypto.EncryptedFile' is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:4:1: warning: The import 'androidx.security.crypto.EncryptedFile' is unused. (detekt.UnusedImports)
import androidx.security.crypto.MasterKey
import dagger.hilt.android.qualifiers.ApplicationContext
import edu.stanford.spezi.core.coroutines.di.Dispatching
import edu.stanford.spezi.modules.storage.secure.SecureStorage
import kotlinx.coroutines.CoroutineDispatcher
import java.io.File
import javax.inject.Inject
import kotlin.reflect.KClass

class LocalStorage @Inject constructor(
@ApplicationContext val context: Context,
@Dispatching.IO private val ioDispatcher: CoroutineDispatcher,
) {

Check warning on line 17 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L17 <detekt.Indentation>

Unexpected indentation (4) (should be 0)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:17:1: warning: Unexpected indentation (4) (should be 0) (detekt.Indentation)
private val masterKey = MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
private val secureStorage = SecureStorage()

private inline fun <reified C: Any> store(

Check warning on line 23 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L23 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:23:34: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

Check warning on line 23 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L23 <detekt.UnusedPrivateMember>

Private function `store` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:23:41: warning: Private function `store` is unused. (detekt.UnusedPrivateMember)
// TODO: iOS has this only as a private helper function
element: C,
storageKey: String?,
settings: LocalStorageSetting,
encode: (C) -> ByteArray

Check warning on line 28 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L28 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:28:33: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): Unit {

Check warning on line 29 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L29 <detekt.NoUnitReturn>

Unnecessary "Unit" return type
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:29:8: warning: Unnecessary "Unit" return type (detekt.NoUnitReturn)
val file = file(storageKey, C::class)

val alreadyExistedBefore = file.exists()

// Called at the end of each execution path
// We can not use defer as the function can potentially throw an error.


Check warning on line 37 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L37 <detekt.NoConsecutiveBlankLines>

Needless blank line(s)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:37:1: warning: Needless blank line(s) (detekt.NoConsecutiveBlankLines)
val data = encode(element)

val keys = settings.keys(secureStorage)

Check warning on line 40 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L40 <detekt.Indentation>

Unexpected indentation (12) (should be 8)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:40:1: warning: Unexpected indentation (12) (should be 8) (detekt.Indentation)

// Determine if the data should be encrypted or not:
if (keys == null) {
file.writeBytes(data)
setResourceValues(alreadyExistedBefore, settings, file)
return
}

// TODO: Check if encryption is supported
//
// iOS:
// // Encryption enabled:
// guard SecKeyIsAlgorithmSupported (keys.publicKey, .encrypt, encryptionAlgorithm) else {
// throw LocalStorageError.encryptionNotPossible
// }
//
// var encryptError: Unmanaged<CFError>?
// guard let encryptedData = SecKeyCreateEncryptedData(
// keys.publicKey,
// encryptionAlgorithm,
// data as CFData, & encryptError) as Data? else {
// throw LocalStorageError.encryptionNotPossible
// }

val encryptedData = data
file.writeBytes(encryptedData)
setResourceValues(alreadyExistedBefore, settings, file)
}

private inline fun <reified C: Any> read( // TODO: iOS only has this as a private helper

Check warning on line 70 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L70 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:70:34: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

Check warning on line 70 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L70 <detekt.UnusedPrivateMember>

Private function `read` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:70:41: warning: Private function `read` is unused. (detekt.UnusedPrivateMember)
storageKey: String?,
settings: LocalStorageSetting,
decode: (ByteArray) -> C

Check warning on line 73 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L73 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:73:33: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): C {
val file = file(storageKey, C::class)
val keys = settings.keys(secureStorage = secureStorage)
?: return decode(file.readBytes())

val privateKey = keys.first
val publicKey = keys.second

// TODO: iOS decryption:
// guard SecKeyIsAlgorithmSupported(keys.privateKey, .decrypt, encryptionAlgorithm) else {
// throw LocalStorageError.decryptionNotPossible
// }

// var decryptError: Unmanaged<CFError>?
// guard let decryptedData = SecKeyCreateDecryptedData(keys.privateKey, encryptionAlgorithm, data as CFData, &decryptError) as Data? else {

Check warning on line 88 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L88 <detekt.MaxLineLength>

Line detected, which is longer than the defined maximum line length in the code style.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:88:1: warning: Line detected, which is longer than the defined maximum line length in the code style. (detekt.MaxLineLength)
// throw LocalStorageError.decryptionNotPossible
// }

return decode(file.readBytes())
}

private fun setResourceValues(
alreadyExistedBefore: Boolean,
settings: LocalStorageSetting,
file: File

Check warning on line 98 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L98 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:98:19: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
) {
try {
if (settings.excludedFromBackupValue) {
// TODO: Check how to exclude files from backup - may need more flexibility here though
}
} catch (error: Throwable) {

Check warning on line 104 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L104 <detekt.TooGenericExceptionCaught>

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:104:18: warning: The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. (detekt.TooGenericExceptionCaught)

Check warning on line 104 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L104 <detekt.SwallowedException>

The caught exception is swallowed. The original exception could be lost.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:104:18: warning: The caught exception is swallowed. The original exception could be lost. (detekt.SwallowedException)
// Revert a written file if it did not exist before.
if (!alreadyExistedBefore) {
file.delete()
}
throw LocalStorageError.CouldNotExcludedFromBackup
}
}

private inline fun <reified C : Any> file(storageKey: String? = null, type: KClass<C> = C::class): File {
val fileName = storageKey ?: type.qualifiedName ?: throw Error() // TODO: This should never happen, right?

Check warning on line 114 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L114 <detekt.TooGenericExceptionThrown>

Error is a too generic Exception. Prefer throwing specific exceptions that indicate a specific error case.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:114:60: warning: Error is a too generic Exception. Prefer throwing specific exceptions that indicate a specific error case. (detekt.TooGenericExceptionThrown)
val directory = File(context.filesDir, "edu.stanford.spezi/LocalStorage")

try {
if (!directory.exists())
directory.mkdirs()

Check warning on line 119 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L119 <detekt.MultiLineIfElse>

Missing { ... }
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:119:17: warning: Missing { ... } (detekt.MultiLineIfElse)
} catch (error: Throwable) {

Check warning on line 120 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L120 <detekt.TooGenericExceptionCaught>

The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:120:18: warning: The caught exception is too generic. Prefer catching specific exceptions to the case that is currently handled. (detekt.TooGenericExceptionCaught)
println("Failed to create directories: $error")
}

return File(context.filesDir, "edu.stanford.spezi/LocalStorage/$fileName.localstorage")
}
}

Check warning on line 126 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt#L126 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt:126:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorage.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.stanford.spezi.modules.storage.local

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

sealed class LocalStorageError: Error() {

Check warning on line 3 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L3 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:3:31: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
data object EncryptionNotPossible: LocalStorageError() {

Check warning on line 4 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L4 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:4:38: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
private fun readResolve(): Any = EncryptionNotPossible

Check warning on line 5 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L5 <detekt.UnusedPrivateMember>

Private function `readResolve` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:5:21: warning: Private function `readResolve` is unused. (detekt.UnusedPrivateMember)
}
data object CouldNotExcludedFromBackup: LocalStorageError() {

Check warning on line 7 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L7 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:7:43: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
private fun readResolve(): Any = CouldNotExcludedFromBackup // TODO: Weird naming

Check warning on line 8 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L8 <detekt.UnusedPrivateMember>

Private function `readResolve` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:8:21: warning: Private function `readResolve` is unused. (detekt.UnusedPrivateMember)
}
data object DecryptionNotPossible: LocalStorageError() {

Check warning on line 10 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L10 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:10:38: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
private fun readResolve(): Any = DecryptionNotPossible

Check warning on line 11 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L11 <detekt.UnusedPrivateMember>

Private function `readResolve` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:11:21: warning: Private function `readResolve` is unused. (detekt.UnusedPrivateMember)
}
}

Check warning on line 13 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt#L13 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt:13:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageError.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package edu.stanford.spezi.modules.storage.local

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

import edu.stanford.spezi.modules.storage.secure.SecureStorage
import edu.stanford.spezi.modules.storage.secure.SecureStorageScope
import javax.crypto.SecretKey

sealed class LocalStorageSetting { // TODO: Adopt android-specific names instead, as SecureEnclave and AccessGroup are iOS-specific
data class Unencrypted(
val excludedFromBackup: Boolean = true

Check warning on line 9 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L9 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:9:47: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): LocalStorageSetting()

Check warning on line 10 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L10 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:10:6: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

data class Encrypted(
val privateKey: SecretKey,
val publicKey: SecretKey,
val excludedFromBackup: Boolean

Check warning on line 15 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L15 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:15:40: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): LocalStorageSetting()

Check warning on line 16 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L16 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:16:6: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

data class EncyptedUsingSecureEnclave(
val userPresence: Boolean = false

Check warning on line 19 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L19 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:19:42: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): LocalStorageSetting()

Check warning on line 20 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L20 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:20:6: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

data class EncryptedUsingKeychain(
val userPresence: Boolean,
val excludedFromBackup: Boolean = true

Check warning on line 24 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L24 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:24:47: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): LocalStorageSetting()

Check warning on line 25 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L25 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:25:6: warning: Missing spacing before ":" (detekt.SpacingAroundColon)

val excludedFromBackupValue: Boolean get() =
when (this) {
is Unencrypted -> excludedFromBackup
is Encrypted -> excludedFromBackup
is EncryptedUsingKeychain -> excludedFromBackup
is EncyptedUsingSecureEnclave -> true
}

fun keys(secureStorage: SecureStorage): Pair<SecretKey, SecretKey>? {

Check warning on line 35 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L35 <detekt.ReturnCount>

Function keys has 4 return statements which exceeds the limit of 3.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:35:9: warning: Function keys has 4 return statements which exceeds the limit of 3. (detekt.ReturnCount)
val secureStorageScope = when (this) {
is Unencrypted -> return null
is Encrypted -> return Pair(privateKey, publicKey)
is EncyptedUsingSecureEnclave ->
SecureStorageScope.SecureEnclave(userPresence)
is EncryptedUsingKeychain ->
SecureStorageScope.Keychain(userPresence)
}

val tag = "LocalStorage.${secureStorageScope.identifier}"
try {
val privateKey = secureStorage.retrievePrivateKey(tag)
val publicKey = secureStorage.retrievePublicKey(tag)
if (privateKey != null && publicKey !== null)
return Pair(privateKey, publicKey)

Check warning on line 50 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L50 <detekt.MultiLineIfElse>

Missing { ... }
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:50:17: warning: Missing { ... } (detekt.MultiLineIfElse)
} catch (_: Throwable) {}

val privateKey = secureStorage.createKey(tag)
val publicKey = secureStorage.retrievePublicKey(tag)
?: throw LocalStorageError.EncryptionNotPossible
return Pair(privateKey, publicKey)
}
}

Check warning on line 58 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt#L58 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt:58:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/local/LocalStorageSetting.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package edu.stanford.spezi.modules.storage.secure

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

data class Credentials(
val username: String,
val password: String

Check warning on line 5 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt#L5 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt:5:25: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
)

Check warning on line 6 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt#L6 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt:6:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/Credentials.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package edu.stanford.spezi.modules.storage.secure

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

import java.security.KeyStore
import javax.crypto.SecretKey

class SecureStorage {
private val keyStore: KeyStore = KeyStore.getInstance("AndroidKeyStore").apply { load(null) }

fun createKey(
tag: String,
size: Int = 256,
storageScope: SecureStorageScope = SecureStorageScope.secureEnclave

Check warning on line 12 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L12 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:12:76: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): SecretKey {
// TODO: Implement
throw NotImplementedError()
}

fun retrievePrivateKey(tag: String): SecretKey? {
// TODO: Implement
throw NotImplementedError()
}

fun retrievePublicKey(tag: String): SecretKey? {
// TODO: Implement
throw NotImplementedError()
}

fun deleteKeys(tag: String) {
// TODO: Implement
throw NotImplementedError()
}

fun store(
credentials: Credentials,
server: String? = null,
removeDuplicate: Boolean = true,
storageScope: SecureStorageScope

Check warning on line 37 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L37 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:37:41: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
) {
// TODO: Implement
throw NotImplementedError()
}

fun deleteCredentials(
username: String,
server: String? = null,
accessGroup: String? = null

Check warning on line 46 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L46 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:46:36: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
) {
// TODO: Implement
throw NotImplementedError()
}

fun deleteAllCredentials(
itemTypes: SecureStorageItemTypes = SecureStorageItemTypes.all,
accessGroup: String? = null

Check warning on line 54 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L54 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:54:36: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
) {
// TODO: Implement
throw NotImplementedError()
}

fun updateCredentials(
username: String,
server: String? = null,
newCredentials: Credentials,
newServer: String? = null,
removeDuplicate: Boolean = true,
storageScope: SecureStorageScope = SecureStorageScope.keychain

Check warning on line 66 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L66 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:66:71: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
) {
// TODO: Implement
throw NotImplementedError()
}

fun retrieveCredentials(
username: String,
server: String? = null,
accessGroup: String? = null

Check warning on line 75 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L75 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:75:36: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): Credentials? {
// TODO: Implement
throw NotImplementedError()
}

fun retrieveAllCredentials(
server: String? = null,
accessGroup: String? = null

Check warning on line 83 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L83 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before ")"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:83:36: warning: Missing trailing comma before ")" (detekt.TrailingCommaOnDeclarationSite)
): List<Credentials> {
// TODO: Implement
throw NotImplementedError()
}
}

Check warning on line 88 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt#L88 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt:88:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorage.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.stanford.spezi.modules.storage.secure

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

sealed class SecureStorageError: Error() {

Check warning on line 3 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L3 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:3:32: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
data object NotFound: SecureStorageError() {

Check warning on line 4 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L4 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:4:25: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
private fun readResolve(): Any = NotFound

Check warning on line 5 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L5 <detekt.UnusedPrivateMember>

Private function `readResolve` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:5:21: warning: Private function `readResolve` is unused. (detekt.UnusedPrivateMember)
}

data class CreateFailed(val error: Error? = null): SecureStorageError()

Check warning on line 8 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L8 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:8:54: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
data object MissingEntitlement: SecureStorageError() {

Check warning on line 9 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L9 <detekt.SpacingAroundColon>

Missing spacing before ":"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:9:35: warning: Missing spacing before ":" (detekt.SpacingAroundColon)
private fun readResolve(): Any = MissingEntitlement

Check warning on line 10 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L10 <detekt.UnusedPrivateMember>

Private function `readResolve` is unused.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:10:21: warning: Private function `readResolve` is unused. (detekt.UnusedPrivateMember)
}
// TODO: Missing cases for keychainError(status: OSStatus)
}

Check warning on line 13 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt#L13 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt:13:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageError.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.stanford.spezi.modules.storage.secure

Check warning on line 1 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt#L1 <detekt.FinalNewline>

File must end with a newline (\n)
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt:1:1: warning: File must end with a newline (\n) (detekt.FinalNewline)

enum class SecureStorageItemType {
KEYS,
SERVER_CREDENTIALS,
NON_SERVER_CREDENTIALS

Check warning on line 6 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt#L6 <detekt.TrailingCommaOnDeclarationSite>

Missing trailing comma before "}"
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt:6:27: warning: Missing trailing comma before "}" (detekt.TrailingCommaOnDeclarationSite)
}

data class SecureStorageItemTypes(val types: Set<SecureStorageItemType>) {
companion object {
val keys = SecureStorageItemTypes(
setOf(
SecureStorageItemType.KEYS
)
)
val serverCredentials = SecureStorageItemTypes(
setOf(
SecureStorageItemType.SERVER_CREDENTIALS
)
)
val nonServerCredentials = SecureStorageItemTypes(
setOf(
SecureStorageItemType.NON_SERVER_CREDENTIALS
)
)
val credentials = SecureStorageItemTypes(
setOf(
SecureStorageItemType.SERVER_CREDENTIALS,
SecureStorageItemType.NON_SERVER_CREDENTIALS
)
)
val all = SecureStorageItemTypes(
SecureStorageItemType.entries.toSet()
)
}
}

Check warning on line 36 in modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt

View workflow job for this annotation

GitHub Actions / detekt

[detekt] modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt#L36 <detekt.NewLineAtEndOfFile>

The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt is not ending with a new line.
Raw output
/github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt:36:2: warning: The file /github/workspace/modules/storage/src/main/kotlin/edu/stanford/spezi/modules/storage/secure/SecureStorageItemTypes.kt is not ending with a new line. (detekt.NewLineAtEndOfFile)
Loading

0 comments on commit 0fb7343

Please sign in to comment.