Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 6f3f7e4

Browse files
committed
refactor: adopt Kotlin 1.9's data objects
1 parent 378ce98 commit 6f3f7e4

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

app/src/main/java/app/passwordstore/util/auth/BiometricAuthenticator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ object BiometricAuthenticator {
3737
* An incorrect biometric was entered, but the prompt UI is offering the option to retry the
3838
* operation.
3939
*/
40-
object Retry : Result()
40+
data object Retry : Result()
4141

4242
/** The biometric hardware is unavailable or disabled on a software or hardware level. */
43-
object HardwareUnavailableOrDisabled : Result()
43+
data object HardwareUnavailableOrDisabled : Result()
4444

4545
/** The prompt was dismissed. */
46-
object Cancelled : Result()
46+
data object Cancelled : Result()
4747
}
4848

4949
fun canAuthenticate(activity: FragmentActivity): Boolean {

app/src/main/java/app/passwordstore/util/git/ErrorMessages.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ sealed class GitException(@StringRes res: Int, vararg fmt: String) :
2828
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PullCommand]. */
2929
sealed class PullException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
3030

31-
object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
31+
data object PullRebaseFailed : PullException(R.string.git_pull_rebase_fail_error)
3232

33-
object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
33+
data object PullMergeFailed : PullException(R.string.git_pull_merge_fail_error)
3434
}
3535

3636
/** Encapsulates possible errors from a [org.eclipse.jgit.api.PushCommand]. */
3737
sealed class PushException(@StringRes res: Int, vararg fmt: String) : GitException(res, *fmt) {
3838

39-
object NonFastForward : PushException(R.string.git_push_nff_error)
39+
data object NonFastForward : PushException(R.string.git_push_nff_error)
4040

41-
object RemoteRejected : PushException(R.string.git_push_other_error)
41+
data object RemoteRejected : PushException(R.string.git_push_other_error)
4242

4343
class Generic(message: String) : PushException(R.string.git_push_generic_error, message)
4444
}

app/src/main/java/app/passwordstore/util/settings/GitSettings.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ constructor(
135135
class AuthModeMismatch(val newProtocol: Protocol, val validModes: List<AuthMode>) :
136136
UpdateConnectionSettingsResult()
137137

138-
object Valid : UpdateConnectionSettingsResult()
138+
data object Valid : UpdateConnectionSettingsResult()
139139

140-
object FailedToParseUrl : UpdateConnectionSettingsResult()
140+
data object FailedToParseUrl : UpdateConnectionSettingsResult()
141141
}
142142

143143
fun updateConnectionSettingsIfValid(

crypto-common/src/main/kotlin/app/passwordstore/crypto/errors/CryptoException.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ public sealed class CryptoException(message: String? = null, cause: Throwable? =
99
public sealed class KeyManagerException(message: String? = null) : CryptoException(message)
1010

1111
/** Store contains no keys. */
12-
public object NoKeysAvailableException : KeyManagerException("No keys were found")
12+
public data object NoKeysAvailableException : KeyManagerException("No keys were found")
1313

1414
/** Key directory does not exist or cannot be accessed. */
15-
public object KeyDirectoryUnavailableException :
15+
public data object KeyDirectoryUnavailableException :
1616
KeyManagerException("Key directory does not exist")
1717

1818
/** Failed to delete given key. */
19-
public object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
19+
public data object KeyDeletionFailedException : KeyManagerException("Couldn't delete the key file")
2020

2121
/** Failed to parse the key as a known type. */
22-
public object InvalidKeyException :
22+
public data object InvalidKeyException :
2323
KeyManagerException("Given key cannot be parsed as a known key type")
2424

2525
/** Key failed the [app.passwordstore.crypto.KeyUtils.isKeyUsable] test. */
26-
public object UnusableKeyException :
26+
public data object UnusableKeyException :
2727
KeyManagerException("Given key is not usable for encryption - is it using AEAD?")
2828

2929
/** No key matching `keyId` could be found. */
@@ -42,7 +42,7 @@ public sealed class CryptoHandlerException(message: String? = null, cause: Throw
4242
public class IncorrectPassphraseException(cause: Throwable) : CryptoHandlerException(null, cause)
4343

4444
/** No keys were passed to the encrypt/decrypt operation. */
45-
public object NoKeysProvidedException : CryptoHandlerException(null, null)
45+
public data object NoKeysProvidedException : CryptoHandlerException(null, null)
4646

4747
/** An unexpected error that cannot be mapped to a known type. */
4848
public class UnknownError(cause: Throwable) : CryptoHandlerException(null, cause)

0 commit comments

Comments
 (0)