[#873] Detekt enhance

* [#873] Detekt - consider MaxLineLength rule on

* [#882] Detekt Compose 0.1.10

* [#872] Detekt 1.23.0
This commit is contained in:
Honza Rychnovský 2023-06-19 08:59:00 +02:00 committed by GitHub
parent 0c23b60275
commit a71ea7577d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 345 additions and 164 deletions

View File

@ -1,5 +1,8 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="RIGHT_MARGIN" value="120" />
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<option name="SOFT_MARGINS" value="120" />
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>

View File

@ -44,7 +44,10 @@ dependencies {
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:${rootProperties.getProperty("DETEKT_VERSION")}")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProperties.getProperty("KOTLIN_VERSION")}")
implementation("wtf.emulator:gradle-plugin:${rootProperties.getProperty("EMULATOR_WTF_GRADLE_PLUGIN_VERSION")}")
implementation("org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin:${rootProperties.getProperty("KOVER_VERSION")}")
implementation(
"org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin:" +
rootProperties.getProperty("KOVER_VERSION")
)
}
// A slightly gross way to use the root gradle.properties as the single source of truth for version numbers

View File

@ -69,8 +69,7 @@ com.vdurmont:semver4j:3.1.0=runtimeClasspath
commons-codec:commons-codec:1.11=runtimeClasspath
commons-io:commons-io:2.12.0=runtimeClasspath
commons-logging:commons-logging:1.2=runtimeClasspath
io.github.detekt.sarif4k:sarif4k:0.0.1=runtimeClasspath
io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0=compileClasspath,runtimeClasspath
io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0=compileClasspath,runtimeClasspath
io.grpc:grpc-api:1.45.1=runtimeClasspath
io.grpc:grpc-context:1.45.1=runtimeClasspath
io.grpc:grpc-core:1.45.1=runtimeClasspath
@ -161,10 +160,6 @@ org.jetbrains.kotlin:kotlin-util-io:1.8.21=compileClasspath,runtimeClasspath
org.jetbrains.kotlin:kotlin-util-klib:1.8.21=runtimeClasspath
org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin:0.7.0-Alpha=compileClasspath,runtimeClasspath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=runtimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.1.0=runtimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.1.0=runtimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.1.0=runtimeClasspath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0=runtimeClasspath
org.jetbrains.kotlinx:kover-gradle-plugin:0.7.0-Alpha=compileClasspath,runtimeClasspath
org.jetbrains:annotations:13.0=compileClasspath,kotlinCompilerClasspath,kotlinCompilerPluginClasspathMain,runtimeClasspath
org.json:json:20230227=runtimeClasspath

View File

@ -84,9 +84,8 @@ com.vdurmont:semver4j:3.1.0=classpath
commons-codec:commons-codec:1.11=classpath
commons-io:commons-io:2.12.0=classpath
commons-logging:commons-logging:1.2=classpath
io.github.detekt.sarif4k:sarif4k:0.0.1=classpath
io.github.x-stream:mxparser:1.2.2=classpath
io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.22.0=classpath
io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0=classpath
io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.19.0=classpathCopy
io.gitlab.arturbosch.detekt:io.gitlab.arturbosch.detekt.gradle.plugin:1.20.0=classpathCopy2
io.grpc:grpc-api:1.45.1=classpath
@ -159,10 +158,6 @@ org.jetbrains.kotlin:kotlin-util-io:1.8.21=classpath
org.jetbrains.kotlin:kotlin-util-klib:1.8.21=classpath
org.jetbrains.kotlinx.kover:org.jetbrains.kotlinx.kover.gradle.plugin:0.7.0-Alpha=classpath
org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.5.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.1.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-core:1.1.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.1.0=classpath
org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0=classpath
org.jetbrains.kotlinx:kover-gradle-plugin:0.7.0-Alpha=classpath
org.jetbrains:annotations:13.0=classpath
org.json:json:20230227=classpath

View File

@ -10,7 +10,9 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOf
import kotlinx.datetime.Instant
class MergingConfigurationProvider(private val configurationProviders: PersistentList<ConfigurationProvider>) : ConfigurationProvider {
class MergingConfigurationProvider(
private val configurationProviders: PersistentList<ConfigurationProvider>
) : ConfigurationProvider {
override fun peekConfiguration(): Configuration {
return MergingConfiguration(configurationProviders.map { it.peekConfiguration() }.toPersistentList())
}

View File

@ -8,7 +8,8 @@ import kotlinx.datetime.Instant
*/
interface Configuration {
/**
* @return When the configuration was updated. Null indicates the configuration either doesn't refresh or has never been refreshed.
* @return When the configuration was updated. Null indicates the configuration either doesn't refresh or has
* never been refreshed.
*/
val updatedAt: Instant?

View File

@ -6,7 +6,10 @@ import kotlinx.datetime.Instant
// The configurationMapping is intended to be a public API for configuration implementations rather
// than a public API for configuration clients.
data class StringConfiguration(val configurationMapping: PersistentMap<String, String>, override val updatedAt: Instant?) : Configuration {
data class StringConfiguration(
val configurationMapping: PersistentMap<String, String>,
override val updatedAt: Instant?
) : Configuration {
override fun getBoolean(
key: ConfigKey,
@ -29,7 +32,8 @@ data class StringConfiguration(val configurationMapping: PersistentMap<String, S
}
} ?: defaultValue
override fun getString(key: ConfigKey, defaultValue: String) = configurationMapping.getOrElse(key.key) { defaultValue }
override fun getString(key: ConfigKey, defaultValue: String) =
configurationMapping.getOrElse(key.key) { defaultValue }
override fun hasKey(key: ConfigKey) = configurationMapping.containsKey(key.key)
}

View File

@ -21,8 +21,12 @@ class MergingConfigurationProviderTest {
fun peek_ordering() {
val configurationProvider = MergingConfigurationProvider(
persistentListOf(
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), null)),
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), null))
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), null)
),
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), null)
)
)
)
@ -34,12 +38,18 @@ class MergingConfigurationProviderTest {
fun getFlow_ordering() = runTest {
val configurationProvider = MergingConfigurationProvider(
persistentListOf(
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), null)),
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), null))
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), null)
),
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), null)
)
)
)
assertTrue(BooleanDefaultEntryFixture.newTrueEntry().getValue(configurationProvider.getConfigurationFlow().first()))
assertTrue(
BooleanDefaultEntryFixture.newTrueEntry().getValue(configurationProvider.getConfigurationFlow().first())
)
}
@Test
@ -62,8 +72,12 @@ class MergingConfigurationProviderTest {
val configurationProvider = MergingConfigurationProvider(
persistentListOf(
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), older)),
MockConfigurationProvider(StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), newer))
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to true.toString()), older)
),
MockConfigurationProvider(
StringConfiguration(persistentMapOf(BooleanDefaultEntryFixture.KEY.key to false.toString()), newer)
)
)
)

View File

@ -22,6 +22,9 @@ class IntegerDefaultEntryTest {
val expected = IntegerDefaultEntryFixture.DEFAULT_VALUE + 5
val entry = IntegerDefaultEntryFixture.newEntry()
assertEquals(expected, entry.getValue(MockConfiguration(mapOf(IntegerDefaultEntryFixture.KEY.key to expected.toString()))))
assertEquals(
expected,
entry.getValue(MockConfiguration(mapOf(IntegerDefaultEntryFixture.KEY.key to expected.toString())))
)
}
}

View File

@ -20,6 +20,9 @@ class StringDefaultEntryTest {
@Test
fun value_override() {
val entry = StringDefaultEntryFixture.newEntryEntry()
assertEquals("override", entry.getValue(MockConfiguration(mapOf(StringDefaultEntryFixture.KEY.key to "override"))))
assertEquals(
"override",
entry.getValue(MockConfiguration(mapOf(StringDefaultEntryFixture.KEY.key to "override")))
)
}
}

View File

@ -35,7 +35,8 @@ class MockConfiguration(private val configurationMapping: Map<String, String> =
}
} ?: defaultValue
override fun getString(key: ConfigKey, defaultValue: String) = configurationMapping.getOrElse(key.key) { defaultValue }
override fun getString(key: ConfigKey, defaultValue: String) =
configurationMapping.getOrElse(key.key) { defaultValue }
override fun hasKey(key: ConfigKey) = configurationMapping.containsKey(key.key)
}

View File

@ -21,7 +21,9 @@ class IntentConfigurationReceiver : BroadcastReceiver() {
existingConfiguration + (key to value)
}
IntentConfigurationProvider.setConfiguration(StringConfiguration(newConfiguration.toPersistentMap(), Clock.System.now()))
IntentConfigurationProvider.setConfiguration(
StringConfiguration(newConfiguration.toPersistentMap(), Clock.System.now())
)
}
}
}

View File

@ -101,8 +101,8 @@ ANDROID_COMPILE_SDK_VERSION=33
ANDROID_NDK_VERSION=23.0.7599858
ANDROID_GRADLE_PLUGIN_VERSION=8.0.2
DETEKT_VERSION=1.22.0
DETEKT_COMPOSE_RULES_VERSION=0.1.5
DETEKT_VERSION=1.23.0
DETEKT_COMPOSE_RULES_VERSION=0.1.10
EMULATOR_WTF_GRADLE_PLUGIN_VERSION=0.12.2
FIREBASE_CRASHLYTICS_BUILD_TOOLS_VERSION=2.9.4
FLANK_VERSION=23.04.0

View File

@ -12,7 +12,8 @@ data class BooleanPreferenceDefault(
try {
it.toBooleanStrict()
} catch (e: IllegalArgumentException) {
// [TODO #32]: Log coercion failure instead of just silently returning default
// TODO [#32]: Log coercion failure instead of just silently returning default
// TODO [#32]: https://github.com/zcash/secant-android-wallet/issues/32
defaultValue
}
} ?: defaultValue

View File

@ -11,7 +11,8 @@ data class IntegerPreferenceDefault(
try {
it.toInt()
} catch (e: NumberFormatException) {
// [TODO #32]: Log coercion failure instead of just silently returning default
// TODO [#32]: Log coercion failure instead of just silently returning default
// TODO [#32]: https://github.com/zcash/secant-android-wallet/issues/32
defaultValue
}
} ?: defaultValue

View File

@ -30,14 +30,18 @@ class BooleanPreferenceDefaultTest {
@Test
fun value_from_config_false() = runTest {
val entry = BooleanPreferenceDefaultFixture.newTrue()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to false.toString()) }
val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to false.toString())
}
assertFalse(entry.getValue(mockPreferenceProvider))
}
@Test
fun value_from_config_true() = runTest {
val entry = BooleanPreferenceDefaultFixture.newTrue()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to true.toString()) }
val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(BooleanPreferenceDefaultFixture.KEY.key to true.toString())
}
assertTrue(entry.getValue(mockPreferenceProvider))
}
}

View File

@ -25,7 +25,9 @@ class IntegerPreferenceDefaultTest {
val expected = IntegerPreferenceDefaultFixture.DEFAULT_VALUE + 5
val entry = IntegerPreferenceDefaultFixture.new()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(StringDefaultPreferenceFixture.KEY.key to expected.toString()) }
val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(StringDefaultPreferenceFixture.KEY.key to expected.toString())
}
assertEquals(expected, entry.getValue(mockPreferenceProvider))
}

View File

@ -23,7 +23,9 @@ class StringPreferenceDefaultTest {
fun value_override() = runTest {
val entry = StringDefaultPreferenceFixture.new()
val mockPreferenceProvider = MockPreferenceProvider { mutableMapOf(StringDefaultPreferenceFixture.KEY.key to "override") }
val mockPreferenceProvider = MockPreferenceProvider {
mutableMapOf(StringDefaultPreferenceFixture.KEY.key to "override")
}
assertEquals("override", entry.getValue(mockPreferenceProvider))
}

View File

@ -8,7 +8,9 @@ import kotlinx.coroutines.flow.flow
/**
* @param mutableMapFactory Emits a new mutable map. Thread safety depends on the factory implementation.
*/
class MockPreferenceProvider(mutableMapFactory: () -> MutableMap<String, String?> = { mutableMapOf() }) : PreferenceProvider {
class MockPreferenceProvider(
mutableMapFactory: () -> MutableMap<String, String?> = { mutableMapOf() }
) : PreferenceProvider {
private val map = mutableMapFactory()

View File

@ -6,5 +6,6 @@ import co.electriccoin.zcash.preference.model.entry.PreferenceKey
object IntegerPreferenceDefaultFixture {
val KEY = PreferenceKey("some_string_key") // $NON-NLS
const val DEFAULT_VALUE = 123
fun new(preferenceKey: PreferenceKey = KEY, value: Int = DEFAULT_VALUE) = IntegerPreferenceDefault(preferenceKey, value)
fun new(preferenceKey: PreferenceKey = KEY, value: Int = DEFAULT_VALUE) =
IntegerPreferenceDefault(preferenceKey, value)
}

View File

@ -6,5 +6,6 @@ import co.electriccoin.zcash.preference.model.entry.StringPreferenceDefault
object StringDefaultPreferenceFixture {
val KEY = PreferenceKey("some_string_key") // $NON-NLS
const val DEFAULT_VALUE = "some_default_value" // $NON-NLS
fun new(preferenceKey: PreferenceKey = KEY, value: String = DEFAULT_VALUE) = StringPreferenceDefault(preferenceKey, value)
fun new(preferenceKey: PreferenceKey = KEY, value: String = DEFAULT_VALUE) =
StringPreferenceDefault(preferenceKey, value)
}

View File

@ -25,7 +25,10 @@ class EncryptedPreferenceProviderTest {
@Before
fun checkUsingOrchestrator() {
check(!isRun) { "State appears to be retained between test method invocations; verify that Test Orchestrator is enabled and then re-run the tests" }
check(!isRun) {
"State appears to be retained between test method invocations; verify that Test Orchestrator " +
"is enabled and then re-run the tests"
}
isRun = true
}
@ -73,7 +76,10 @@ class EncryptedPreferenceProviderTest {
putString(StringDefaultPreferenceFixture.KEY, expectedValue)
}
val text = File(File(ApplicationProvider.getApplicationContext<Context>().dataDir, "shared_prefs"), "$FILENAME.xml").readText()
val text = File(
File(ApplicationProvider.getApplicationContext<Context>().dataDir, "shared_prefs"),
"$FILENAME.xml"
).readText()
assertFalse(text.contains(expectedValue))
assertFalse(text.contains(StringDefaultPreferenceFixture.KEY.key))
@ -81,6 +87,9 @@ class EncryptedPreferenceProviderTest {
companion object {
private val FILENAME = "encrypted_preference_test"
private suspend fun new() = AndroidPreferenceProvider.newEncrypted(ApplicationProvider.getApplicationContext(), FILENAME)
private suspend fun new() = AndroidPreferenceProvider.newEncrypted(
ApplicationProvider.getApplicationContext(),
FILENAME
)
}
}

View File

@ -23,7 +23,10 @@ class StandardPreferenceProviderTest {
@Before
fun checkUsingOrchestrator() {
check(!isRun) { "State appears to be retained between test method invocations; verify that Test Orchestrator is enabled and then re-run the tests" }
check(!isRun) {
"State appears to be retained between test method invocations; verify that Test Orchestrator " +
"is enabled and then re-run the tests"
}
isRun = true
}
@ -62,6 +65,9 @@ class StandardPreferenceProviderTest {
companion object {
private val FILENAME = "encrypted_preference_test"
private suspend fun new() = AndroidPreferenceProvider.newStandard(ApplicationProvider.getApplicationContext(), FILENAME)
private suspend fun new() = AndroidPreferenceProvider.newStandard(
ApplicationProvider.getApplicationContext(),
FILENAME
)
}
}

View File

@ -6,5 +6,8 @@ import co.electriccoin.zcash.preference.model.entry.StringPreferenceDefault
object StringDefaultPreferenceFixture {
val KEY = PreferenceKey("some_string_key") // $NON-NLS
const val DEFAULT_VALUE = "some_default_value" // $NON-NLS
fun new(preferenceKey: PreferenceKey = KEY, value: String = DEFAULT_VALUE) = StringPreferenceDefault(preferenceKey, value)
fun new(
preferenceKey: PreferenceKey = KEY,
value: String = DEFAULT_VALUE
) = StringPreferenceDefault(preferenceKey, value)
}

View File

@ -9,13 +9,19 @@ class ProcessNameCompatTest {
@SmallTest
@Test
fun searchForProcessName() {
assertEquals(TEST_PACKAGE_PROCESS, ProcessNameCompat.searchForProcessNameLegacy(ApplicationProvider.getApplicationContext()))
assertEquals(
TEST_PACKAGE_PROCESS,
ProcessNameCompat.searchForProcessNameLegacy(ApplicationProvider.getApplicationContext())
)
}
@SmallTest
@Test
fun getProcessName() {
assertEquals(TEST_PACKAGE_PROCESS, ProcessNameCompat.getProcessName(ApplicationProvider.getApplicationContext()))
assertEquals(
TEST_PACKAGE_PROCESS,
ProcessNameCompat.getProcessName(ApplicationProvider.getApplicationContext())
)
}
companion object {

View File

@ -5,7 +5,6 @@ naming:
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '[a-z][a-zA-Z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
ignoreAnnotated:
- 'Composable'
@ -13,22 +12,29 @@ style:
active: true
ForbiddenComment:
active: true
values:
- 'FIXME:'
- 'STOPSHIP:'
- 'TODO:'
allowedPatterns: '\[[^\]]\d+\]'
customMessage: 'Include issue number prefix for TODO comments, e.g. `TODO [#123]: Fix this later`'
comments:
- reason: 'Forbidden FIXME todo marker in comment, please fix the problem. Or include issue number prefix for
FIXME comments, e.g. `FIXME [#123]: Fix this later`'
value: 'FIXME'
- reason: 'Forbidden STOPSHIP todo marker in comment, please address the problem before shipping the code. Or
include issue number prefix for STOPSHIP comments, e.g. `STOPSHIP [#123]: Fix this later`'
value: 'STOPSHIP'
- reason: 'Forbidden TODO todo marker in comment, please do the changes. Or include issue number prefix for TODO
comments, e.g. `TODO [#123]: Fix this later`'
value: 'TODO'
allowedPatterns: '[TODO|FIXME|STOPSHIP]+\s\[#\d+\]:\s.+'
MaxLineLength:
active: false
active: true
NewLineAtEndOfFile:
active: false
UnusedPrivateMember:
active: true
allowedNames: '(_|ignored|expected|serialVersionUID)'
excludes: [ '**/*.kts' ]
ignoreAnnotated:
- 'Preview'
WildcardImport:
active: false
active: true
Compose:
ModifierMissing:

View File

@ -17,7 +17,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
@Preview
@Composable
fun ButtonComposablePreview() {
private fun ButtonComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
Column {

View File

@ -19,7 +19,7 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
@Preview
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = false) {
Chip(Index(0), "edict")
}

View File

@ -31,7 +31,6 @@ internal object Dark {
val tertiaryButton = Color.Transparent
val tertiaryButtonPressed = Color(0xB0C3D2BA)
// TODO how does the invisible button show a disabled state?
val navigationButton = Color(0xFFA7C0D9)
val navigationButtonPressed = Color(0xFFC8DCEF)
@ -70,7 +69,8 @@ internal object Light {
val textCaption = Color(0xFF2D3747)
val textChipIndex = Color(0xFFEE8592)
// TODO The button colors are wrong for light
// TODO [#159]: The button colors are wrong for light
// TODO [#159]: https://github.com/zcash/secant-android-wallet/issues/159
val primaryButton = Color(0xFF263357)
val primaryButtonPressed = Color(0xFFFFD800)
val primaryButtonDisabled = Color(0x33F4B728)
@ -95,7 +95,8 @@ internal object Light {
val overlay = Color(0x22000000)
val highlight = Color(0xFFFFD800)
// [TODO #159]: The colors are wrong for light theme
// TODO [#159]: The colors are wrong for light theme
// TODO [#159]: https://github.com/zcash/secant-android-wallet/issues/159
val addressHighlightBorder = Color(0xFF525252)
val addressHighlightUnified = Color(0xFFFFD800)
val addressHighlightSapling = Color(0xFF1BBFF6)

View File

@ -54,13 +54,13 @@ class FlowExtTest {
@FlakyTest
@Test
fun stressTest() = runBlocking {
for (i in 0..10) {
repeat(10) {
assertTrue { raceConditionTest(0.001.seconds) }
}
for (i in 0..10) {
repeat(10) {
assertTrue { raceConditionTest(0.0001.seconds) }
}
for (i in 0..10) {
repeat(10) {
assertTrue { raceConditionTest(0.00001.seconds) }
}
}

View File

@ -130,7 +130,12 @@ internal class MockSynchronizer : CloseableSynchronizer {
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
}
override suspend fun sendToAddress(usk: UnifiedSpendingKey, amount: Zatoshi, toAddress: String, memo: String): Long {
override suspend fun sendToAddress(
usk: UnifiedSpendingKey,
amount: Zatoshi,
toAddress: String,
memo: String
): Long {
return 1
}

View File

@ -119,7 +119,9 @@ class WalletAddressViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.wallet_address_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.wallet_address_back_content_description)
).also {
it.performClick()
}

View File

@ -36,8 +36,12 @@ class WalletDisplayValuesTest {
assertEquals(1f, values.progress.decimal)
assertEquals(walletSnapshot.totalBalance().toZecString(), values.zecAmountText)
assertTrue(values.statusText.startsWith(getStringResource(R.string.home_status_syncing_catchup)))
// TODO [#578] https://github.com/zcash/zcash-android-wallet-sdk/issues/578
// TODO [#578]: Provide Zatoshi -> USD fiat currency formatting
// TODO [#578]: https://github.com/zcash/zcash-android-wallet-sdk/issues/578
assertEquals(FiatCurrencyConversionRateState.Unavailable, values.fiatCurrencyAmountState)
assertEquals(getStringResource(R.string.fiat_currency_conversion_rate_unavailable), values.fiatCurrencyAmountText)
assertEquals(
getStringResource(R.string.fiat_currency_conversion_rate_unavailable),
values.fiatCurrencyAmountText
)
}
}

View File

@ -209,7 +209,9 @@ class LongOnboardingViewTest : UiTestPrerequisites() {
fun last_stage_click_import_wallet() {
val testSetup = newTestSetup(initialStage = OnboardingStage.Wallet)
val newWalletButton = composeTestRule.onNodeWithText(getStringResource(R.string.onboarding_4_import_existing_wallet))
val newWalletButton = composeTestRule.onNodeWithText(
getStringResource(R.string.onboarding_4_import_existing_wallet)
)
newWalletButton.performClick()
assertEquals(1, testSetup.getOnImportWalletCallbackCount())

View File

@ -47,7 +47,9 @@ class ShortOnboardingViewTest : UiTestPrerequisites() {
fun click_create_wallet() {
val testSetup = newTestSetup()
val newWalletButton = composeTestRule.onNodeWithText(getStringResource(R.string.onboarding_short_create_new_wallet))
val newWalletButton = composeTestRule.onNodeWithText(
getStringResource(R.string.onboarding_short_create_new_wallet)
)
newWalletButton.performClick()
assertEquals(1, testSetup.getOnCreateWalletCallbackCount())
@ -59,7 +61,9 @@ class ShortOnboardingViewTest : UiTestPrerequisites() {
fun click_import_wallet() {
val testSetup = newTestSetup()
val newWalletButton = composeTestRule.onNodeWithText(getStringResource(R.string.onboarding_short_import_existing_wallet))
val newWalletButton = composeTestRule.onNodeWithText(
getStringResource(R.string.onboarding_short_import_existing_wallet)
)
newWalletButton.performClick()
assertEquals(1, testSetup.getOnImportWalletCallbackCount())

View File

@ -47,7 +47,9 @@ class ReceiveViewTest {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.receive_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.receive_back_content_description)
).also {
it.performClick()
}

View File

@ -165,7 +165,10 @@ class RestoreViewTest : UiTestPrerequisites() {
@Test
@MediumTest
fun height_skip() {
val testSetup = newTestSetup(initialStage = RestoreStage.Birthday, initialWordsList = SeedPhraseFixture.new().split)
val testSetup = newTestSetup(
initialStage = RestoreStage.Birthday,
initialWordsList = SeedPhraseFixture.new().split
)
composeTestRule.onNodeWithText(getStringResource(R.string.restore_birthday_button_skip)).also {
it.performClick()
@ -304,7 +307,9 @@ class RestoreViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.restore_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.restore_back_content_description)
).also {
it.performClick()
}
@ -321,7 +326,9 @@ class RestoreViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.restore_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.restore_back_content_description)
).also {
it.performClick()
}
@ -342,7 +349,9 @@ class RestoreViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.restore_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.restore_back_content_description)
).also {
it.performClick()
}

View File

@ -32,7 +32,9 @@ class SettingsViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnBackCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.settings_back_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.settings_back_content_description)
).also {
it.performClick()
}
@ -44,10 +46,15 @@ class SettingsViewTest : UiTestPrerequisites() {
fun rescan() = runTest {
val testSetup = TestSetup(composeTestRule)
if (ConfigurationEntries.IS_RESCAN_ENABLED.getValue(StringConfiguration(emptyMap<String, String>().toPersistentMap(), null))) {
if (ConfigurationEntries.IS_RESCAN_ENABLED.getValue(
StringConfiguration(emptyMap<String, String>().toPersistentMap(), null)
)
) {
assertEquals(0, testSetup.getRescanCount())
composeTestRule.onNodeWithContentDescription(getStringResource(R.string.settings_overflow_content_description)).also {
composeTestRule.onNodeWithContentDescription(
getStringResource(R.string.settings_overflow_content_description)
).also {
it.performClick()
}

View File

@ -68,7 +68,10 @@ class SupportViewIntegrationTest : UiTestPrerequisites() {
restorationTester.emulateSavedInstanceStateRestore()
val dialogContent = getStringResourceWithArgs(R.string.support_confirmation_explanation, getStringResource(R.string.app_name))
val dialogContent = getStringResourceWithArgs(
R.string.support_confirmation_explanation,
getStringResource(R.string.app_name)
)
composeTestRule.onNodeWithText(dialogContent).also {
it.assertExists()
}

View File

@ -48,7 +48,10 @@ class SupportViewTest : UiTestPrerequisites() {
assertEquals(0, testSetup.getOnSendCount())
val dialogContent = getStringResourceWithArgs(R.string.support_confirmation_explanation, getStringResource(R.string.app_name))
val dialogContent = getStringResourceWithArgs(
R.string.support_confirmation_explanation,
getStringResource(R.string.app_name)
)
composeTestRule.onNodeWithText(dialogContent).also {
it.assertExists()
}
@ -88,7 +91,10 @@ class SupportViewTest : UiTestPrerequisites() {
it.performClick()
}
val dialogContent = getStringResourceWithArgs(R.string.support_confirmation_explanation, getStringResource(R.string.app_name))
val dialogContent = getStringResourceWithArgs(
R.string.support_confirmation_explanation,
getStringResource(R.string.app_name)
)
composeTestRule.onNodeWithText(dialogContent).also {
it.assertDoesNotExist()
}

View File

@ -8,4 +8,5 @@ fun getAppContext(): Context = ApplicationProvider.getApplicationContext()
fun getStringResource(@StringRes resId: Int) = getAppContext().getString(resId)
fun getStringResourceWithArgs(@StringRes resId: Int, vararg formatArgs: String) = getAppContext().getString(resId, *formatArgs)
fun getStringResourceWithArgs(@StringRes resId: Int, vararg formatArgs: String) =
getAppContext().getString(resId, *formatArgs)

View File

@ -7,12 +7,14 @@ object ConfigurationEntries {
val IS_APP_UPDATE_CHECK_ENABLED = BooleanConfigurationEntry(ConfigKey("is_update_check_enabled"), true)
/*
* The full onboarding flow is functional and tested, but it is disabled by default for an initially minimal feature set.
* The full onboarding flow is functional and tested, but it is disabled by default for an initially minimal
* feature set.
*/
val IS_SHORT_ONBOARDING_UX = BooleanConfigurationEntry(ConfigKey("is_short_onboarding_ux"), true)
/*
* The full new wallet flow is functional and tested, but it is disabled by default for an initially minimal feature set.
* The full new wallet flow is functional and tested, but it is disabled by default for an initially minimal
* feature set.
*/
val IS_SHORT_NEW_WALLET_BACKUP_UX = BooleanConfigurationEntry(ConfigKey("is_short_new_wallet_backup_ux"), true)

View File

@ -31,9 +31,9 @@ import co.electriccoin.zcash.ui.fixture.VersionInfoFixture
import co.electriccoin.zcash.ui.screen.about.model.VersionInfo
import co.electriccoin.zcash.ui.screen.support.model.ConfigInfo
@Preview
@Preview("About")
@Composable
fun AboutPreview() {
private fun AboutPreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
About(
@ -45,7 +45,6 @@ fun AboutPreview() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun About(
versionInfo: VersionInfo,

View File

@ -53,9 +53,9 @@ import co.electriccoin.zcash.ui.design.component.ListItem
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import kotlinx.coroutines.runBlocking
@Preview
@Preview("WalletAddresses")
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
WalletAddresses(

View File

@ -60,9 +60,9 @@ import co.electriccoin.zcash.ui.screen.backup.state.TestChoices
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList
@Preview(device = Devices.PIXEL_4)
@Preview(name = "LongNewWalletBackup", device = Devices.PIXEL_4)
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = false) {
GradientSurface {
LongNewWalletBackup(

View File

@ -37,9 +37,9 @@ import co.electriccoin.zcash.ui.design.component.PrimaryButton
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import kotlinx.collections.immutable.toPersistentList
@Preview(device = Devices.PIXEL_4)
@Preview(name = "ShortNewWalletBackup", device = Devices.PIXEL_4)
@Composable
fun ComposablePreviewShort() {
private fun ComposablePreviewShort() {
ZcashTheme(darkTheme = false) {
GradientSurface {
ShortNewWalletBackup(

View File

@ -23,9 +23,9 @@ import co.electriccoin.zcash.ui.design.component.TertiaryButton
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.screen.onboarding.view.Callout
@Preview
@Preview("DesignGuide")
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = false) {
DesignGuide()
}

View File

@ -29,7 +29,8 @@ data class WalletDisplayValues(
var progress = PercentDecimal.ZERO_PERCENT
val zecAmountText = walletSnapshot.totalBalance().toZecString()
var statusText = ""
// TODO [#578] https://github.com/zcash/zcash-android-wallet-sdk/issues/578
// TODO [#578]: Provide Zatoshi -> USD fiat currency formatting
// TODO [#578]: https://github.com/zcash/zcash-android-wallet-sdk/issues/578
// We'll ideally provide a "fresh" currencyConversion object here
val fiatCurrencyAmountState = walletSnapshot.spendableBalance().toFiatCurrencyState(
null,

View File

@ -78,9 +78,9 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.CoroutineScope
@Preview
@Preview("Home")
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
Home(
@ -105,7 +105,6 @@ fun ComposablePreview() {
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Suppress("LongParameterList")
@Composable
fun Home(
@ -221,7 +220,9 @@ private fun DebugMenu(
onClick = {
// Eventually this shouldn't rely on the Android implementation, but rather an expect/actual
// should be used at the crash API level.
GlobalCrashReporter.reportCaughtException(RuntimeException("Manually caught exception from debug menu"))
GlobalCrashReporter.reportCaughtException(
RuntimeException("Manually caught exception from debug menu")
)
expanded = false
}
)

View File

@ -24,6 +24,11 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) {
emitAll(StandardPreferenceKeys.IS_BACKGROUND_SYNC_ENABLED.observe(preferenceProvider))
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT.inWholeMilliseconds), null)
val configurationFlow: StateFlow<Configuration?> = AndroidConfigurationFactory.getInstance(application).getConfigurationFlow()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT.inWholeMilliseconds), null)
val configurationFlow: StateFlow<Configuration?> =
AndroidConfigurationFactory.getInstance(application).getConfigurationFlow()
.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(ANDROID_STATE_FLOW_TIMEOUT.inWholeMilliseconds),
null
)
}

View File

@ -259,7 +259,8 @@ sealed class SecretState {
/**
* Represents all kind of Synchronizer errors
*/
// TODO [#529] https://github.com/zcash/secant-android-wallet/issues/529
// TODO [#529]: Localize Synchronizer Errors
// TODO [#529]: https://github.com/zcash/secant-android-wallet/issues/529
sealed class SynchronizerError {
abstract fun getCauseMessage(): String?

View File

@ -49,9 +49,9 @@ import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.screen.onboarding.model.OnboardingStage
import co.electriccoin.zcash.ui.screen.onboarding.state.OnboardingState
@Preview
@Preview("LongOnboarding")
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
LongOnboarding(

View File

@ -37,9 +37,9 @@ import co.electriccoin.zcash.ui.design.component.PrimaryButton
import co.electriccoin.zcash.ui.design.component.TertiaryButton
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
@Preview
@Preview("ShortOnboarding")
@Composable
fun ShortOnboardingComposablePreview() {
private fun ShortOnboardingComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
ShortOnboarding(

View File

@ -41,9 +41,9 @@ import co.electriccoin.zcash.ui.screen.receive.util.JvmQrCodeGenerator
import kotlinx.coroutines.runBlocking
import kotlin.math.roundToInt
@Preview
@Preview("Receive")
@Composable
fun ComposablePreview() {
private fun ComposablePreview() {
ZcashTheme(darkTheme = true) {
GradientSurface {
Receive(

View File

@ -87,7 +87,7 @@ import kotlinx.coroutines.launch
@Preview("Restore Wallet")
@Composable
fun PreviewRestore() {
private fun PreviewRestore() {
ZcashTheme(darkTheme = true) {
GradientSurface {
RestoreWallet(
@ -118,7 +118,7 @@ fun PreviewRestore() {
@Preview("Restore Complete")
@Composable
fun PreviewRestoreComplete() {
private fun PreviewRestoreComplete() {
ZcashTheme(darkTheme = true) {
RestoreComplete(
onComplete = {}
@ -132,7 +132,7 @@ fun PreviewRestoreComplete() {
* @param restoreHeight A null height indicates no user input.
*/
@Suppress("LongParameterList", "LongMethod")
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun RestoreWallet(
zcashNetwork: ZcashNetwork,
@ -255,8 +255,8 @@ private fun RestoreTopAppBar(onBack: () -> Unit, isShowClear: Boolean, onClear:
)
}
// TODO [#672] Implement custom seed phrase pasting for wallet import
// TODO [#672] https://github.com/zcash/secant-android-wallet/issues/672
// TODO [#672]: Implement custom seed phrase pasting for wallet import
// TODO [#672]: https://github.com/zcash/secant-android-wallet/issues/672
@OptIn(ExperimentalComposeUiApi::class)
@Suppress("UNUSED_PARAMETER", "LongParameterList")

View File

@ -77,11 +77,11 @@ import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.guava.await
import kotlin.math.roundToInt
// TODO [#423]: QR scan screen elements transparency
// TODO [#423]: https://github.com/zcash/secant-android-wallet/issues/423
// TODO QR scan screen elements transparency
@Preview("Scan")
@Composable
fun PreviewScan() {
private fun PreviewScan() {
ZcashTheme(darkTheme = true) {
GradientSurface {
Scan(
@ -248,8 +248,8 @@ private fun ScanMainContent(
onScanStateChanged(ScanState.Permission)
}
ScanState.Scanning -> {
// TODO [#437]: Scan QR Screen Frame Analysing
// TODO [#437]: https://github.com/zcash/secant-android-wallet/issues/437
// TODO Scan QR Screen Frame Analysing
onScanStateChanged(ScanState.Scanning)
ScanCameraView(
onScanned = onScanned,

3