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

Commit

Permalink
fix(deps): update dependency com.slack.lint:slack-lint-checks to v0.6…
Browse files Browse the repository at this point in the history
….0 (#2697)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
  • Loading branch information
renovate[bot] and msfjarvis authored Sep 27, 2023
1 parent 403e378 commit 47d65d0
Show file tree
Hide file tree
Showing 35 changed files with 141 additions and 155 deletions.
79 changes: 1 addition & 78 deletions app/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.3.0-alpha01" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0-alpha01)" variant="all" version="8.3.0-alpha01">
<issues format="6" by="lint 8.3.0-alpha05" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0-alpha05)" variant="all" version="8.3.0-alpha05">

<issue
id="StopShip"
Expand All @@ -26,17 +26,6 @@
file="$GRADLE_USER_HOME/caches/modules-2/files-2.1/org.bouncycastle/bcpkix-jdk18on/1.75/5adfef8a71a0933454739264b56283cc73dd2383/bcpkix-jdk18on-1.75.jar"/>
</issue>

<issue
id="RawDispatchersUse"
message="Use SlackDispatchers."
errorLine1=" runBlocking(Dispatchers.Main) { suspendCoroutine { cont -> askForPassword(cont, isRetry) } }"
errorLine2=" ~~~~~~~~~~~~~~~~">
<location
file="src/main/java/app/passwordstore/util/git/sshj/SshjSessionFactory.kt"
line="60"
column="19"/>
</issue>

<issue
id="DenyListedApi"
message="Use Context#getDrawableCompat() instead"
Expand All @@ -59,39 +48,6 @@
column="31"/>
</issue>

<issue
id="DenyListedApi"
message="Use the structured concurrent CoroutineScope#launch and Flow#collect APIs instead of reactive Flow#onEach and Flow#launchIn. Suspend calls like Flow#collect can be refactored into standalone suspend funs and mixed in with regular control flow in a suspend context, but calls that invoke CoroutineScope#launch and Flow#collect at the same time hide the suspend context, encouraging the developer to continue working in the reactive domain."
errorLine1=" .launchIn(lifecycleScope)"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/ui/passwords/PasswordFragment.kt"
line="212"
column="8"/>
</issue>

<issue
id="DenyListedApi"
message="Use the structured concurrent CoroutineScope#launch and Flow#collect APIs instead of reactive Flow#onEach and Flow#launchIn. Suspend calls like Flow#collect can be refactored into standalone suspend funs and mixed in with regular control flow in a suspend context, but calls that invoke CoroutineScope#launch and Flow#collect at the same time hide the suspend context, encouraging the developer to continue working in the reactive domain."
errorLine1=" .launchIn(lifecycleScope)"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/ui/dialogs/PasswordGeneratorDialogFragment.kt"
line="68"
column="8"/>
</issue>

<issue
id="DenyListedApi"
message="Use the structured concurrent CoroutineScope#launch and Flow#collect APIs instead of reactive Flow#onEach and Flow#launchIn. Suspend calls like Flow#collect can be refactored into standalone suspend funs and mixed in with regular control flow in a suspend context, but calls that invoke CoroutineScope#launch and Flow#collect at the same time hide the suspend context, encouraging the developer to continue working in the reactive domain."
errorLine1=" .launchIn(lifecycleScope)"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/ui/folderselect/SelectFolderFragment.kt"
line="65"
column="8"/>
</issue>

<issue
id="MissingQuantity"
message="For locale &quot;it&quot; (Italian) the following quantity should also be defined: `many`"
Expand Down Expand Up @@ -227,37 +183,4 @@
column="4"/>
</issue>

<issue
id="UnknownNullness"
message="Should explicitly declare type here since implicit type does not specify nullness (Lazy&lt;Array&lt;(GitCommand&lt;out (Any or Any?)> or GitCommand&lt;out (Any or Any?)>?)>>)"
errorLine1=" override val commands by unsafeLazy {"
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/util/git/operation/BreakOutOfDetached.kt"
line="33"
column="16"/>
</issue>

<issue
id="UnknownNullness"
message="Should explicitly declare type here since implicit type does not specify nullness (Array&lt;(GitCommand&lt;out (Any or Any?)> or GitCommand&lt;out (Any or Any?)>?)>)"
errorLine1=" override val commands ="
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/util/git/operation/ResetToRemoteOperation.kt"
line="14"
column="16"/>
</issue>

<issue
id="UnknownNullness"
message="Should explicitly declare type here since implicit type does not specify nullness (Array&lt;(GitCommand&lt;out (Any or Any?)> or GitCommand&lt;out (Any or Any?)>?)>)"
errorLine1=" override val commands ="
errorLine2=" ~~~~~~~~">
<location
file="src/main/java/app/passwordstore/util/git/operation/SyncOperation.kt"
line="14"
column="16"/>
</issue>

</issues>
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ object PasswordRepository {
val dir = getRepositoryDirectory()
// Un-initialize the repo if the dir does not exist or is absolutely empty
settings.edit {
if (!dir.exists() || !dir.isDirectory || requireNotNull(dir.listFiles()).isEmpty()) {
if (
!dir.exists() ||
!dir.isDirectory ||
requireNotNull(dir.listFiles()) { "Failed to list files in ${dir.path}" }.isEmpty()
) {
putBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, false)
} else {
putBoolean(PreferenceKeys.REPOSITORY_INITIALIZED, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ import app.passwordstore.util.settings.PreferenceKeys
import com.github.michaelbull.result.getOrElse
import com.github.michaelbull.result.runCatching
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import reactivecircus.flowbinding.android.widget.afterTextChanges
import reactivecircus.flowbinding.android.widget.checkedChanges

Expand All @@ -55,17 +54,18 @@ class PasswordGeneratorDialogFragment : DialogFragment() {
binding.lengthNumber.setText(prefs.getInt(PreferenceKeys.LENGTH, 20).toString())
binding.passwordText.typeface = Typeface.MONOSPACE

merge(
binding.numerals.checkedChanges().skipInitialValue(),
binding.symbols.checkedChanges().skipInitialValue(),
binding.uppercase.checkedChanges().skipInitialValue(),
binding.lowercase.checkedChanges().skipInitialValue(),
binding.ambiguous.checkedChanges().skipInitialValue(),
binding.pronounceable.checkedChanges().skipInitialValue(),
binding.lengthNumber.afterTextChanges().skipInitialValue(),
)
.onEach { generate(binding.passwordText) }
.launchIn(lifecycleScope)
lifecycleScope.launch {
merge(
binding.numerals.checkedChanges().skipInitialValue(),
binding.symbols.checkedChanges().skipInitialValue(),
binding.uppercase.checkedChanges().skipInitialValue(),
binding.lowercase.checkedChanges().skipInitialValue(),
binding.ambiguous.checkedChanges().skipInitialValue(),
binding.pronounceable.checkedChanges().skipInitialValue(),
binding.lengthNumber.afterTextChanges().skipInitialValue(),
)
.collect { generate(binding.passwordText) }
}

return builder
.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ import com.github.michaelbull.result.runCatching
import dagger.hilt.android.AndroidEntryPoint
import java.io.File
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import me.zhanghai.android.fastscroll.FastScrollerBuilder

@AndroidEntryPoint
Expand Down Expand Up @@ -57,12 +56,16 @@ class SelectFolderFragment : Fragment(R.layout.password_recycler_view) {
FastScrollerBuilder(binding.passRecycler).build()
registerForContextMenu(binding.passRecycler)

val path = requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH))
val path =
requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH)) {
"Cannot navigate if ${PasswordStore.REQUEST_ARG_PATH} is not provided"
}
model.navigateTo(File(path), listMode = ListMode.DirectoriesOnly, pushPreviousLocation = false)
model.searchResult
.flowWithLifecycle(lifecycle)
.onEach { result -> recyclerAdapter.submitList(result.passwordItems) }
.launchIn(lifecycleScope)
lifecycleScope.launch {
model.searchResult.flowWithLifecycle(lifecycle).collect { result ->
recyclerAdapter.submitList(result.passwordItems)
}
}
}

override fun onAttach(context: Context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ class GitServerConfigActivity : BaseGitActivity() {

/** Clones the repository, the directory exists, deletes it */
private fun cloneRepository() {
val localDir = requireNotNull(PasswordRepository.getRepositoryDirectory())
val localDir =
requireNotNull(PasswordRepository.getRepositoryDirectory()) {
"Repository directory must be set before cloning"
}
val localDirFiles = localDir.listFiles() ?: emptyArray()
// Warn if non-empty folder unless it's a just-initialized store that has just a .git folder
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ import com.github.michaelbull.result.runCatching
import dagger.hilt.android.AndroidEntryPoint
import java.io.File
import javax.inject.Inject
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import me.zhanghai.android.fastscroll.FastScrollerBuilder

Expand Down Expand Up @@ -177,11 +175,13 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
recyclerAdapter.makeSelectable(recyclerView)
registerForContextMenu(recyclerView)

val path = requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH))
val path =
requireNotNull(requireArguments().getString(PasswordStore.REQUEST_ARG_PATH)) {
"Cannot navigate if ${PasswordStore.REQUEST_ARG_PATH} is not provided"
}
model.navigateTo(File(path), pushPreviousLocation = false)
model.searchResult
.flowWithLifecycle(lifecycle)
.onEach { result ->
lifecycleScope.launch {
model.searchResult.flowWithLifecycle(lifecycle).collect { result ->
// Only run animations when the new list is filtered, i.e., the user submitted a search,
// and not on folder navigation since the latter leads to too many removal animations.
(recyclerView.itemAnimator as OnOffItemAnimator).isEnabled = result.isFiltered
Expand Down Expand Up @@ -209,7 +209,7 @@ class PasswordFragment : Fragment(R.layout.password_recycler_view) {
}
}
}
.launchIn(lifecycleScope)
}
}

private val actionModeCallback =
Expand Down
25 changes: 21 additions & 4 deletions app/src/main/java/app/passwordstore/ui/passwords/PasswordStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,16 @@ class PasswordStore : BaseGitActivity() {
private val passwordMoveAction =
registerForActivityResult(StartActivityForResult()) { result ->
val intentData = result.data ?: return@registerForActivityResult
val filesToMove = requireNotNull(intentData.getStringArrayExtra("Files"))
val target = File(requireNotNull(intentData.getStringExtra("SELECTED_FOLDER_PATH")))
val filesToMove =
requireNotNull(intentData.getStringArrayExtra("Files")) {
"'Files' intent extra must be set"
}
val target =
File(
requireNotNull(intentData.getStringExtra("SELECTED_FOLDER_PATH")) {
"'SELECTED_FOLDER_PATH' intent extra must be set"
}
)
val repositoryPath = PasswordRepository.getRepositoryDirectory().absolutePath
if (!target.isDirectory) {
logcat(ERROR) { "Tried moving passwords to a non-existing folder." }
Expand All @@ -103,7 +111,12 @@ class PasswordStore : BaseGitActivity() {
}
val destinationFile = File(target.absolutePath + "/" + source.name)
val basename = source.nameWithoutExtension
val sourceLongName = getLongName(requireNotNull(source.parent), repositoryPath, basename)
val sourceLongName =
getLongName(
requireNotNull(source.parent) { "$file has no parent" },
repositoryPath,
basename
)
val destinationLongName = getLongName(target.absolutePath, repositoryPath, basename)
if (destinationFile.exists()) {
logcat(ERROR) { "Trying to move a file that already exists." }
Expand Down Expand Up @@ -132,7 +145,11 @@ class PasswordStore : BaseGitActivity() {
val source = File(filesToMove[0])
val basename = source.nameWithoutExtension
val sourceLongName =
getLongName(requireNotNull(source.parent), repositoryPath, basename)
getLongName(
requireNotNull(source.parent) { "$basename has no parent" },
repositoryPath,
basename
)
val destinationLongName = getLongName(target.absolutePath, repositoryPath, basename)
withContext(dispatcherProvider.main()) {
commitChange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private constructor(
// https://developer.android.com/reference/android/service/autofill/SaveInfo#FLAG_DELAY_SAVE
private fun makeSaveInfo(): SaveInfo? {
if (!canBeSaved) return null
check(saveFlags != null)
check(saveFlags != null) { "saveFlags must not be null" }
val idsToSave = scenario.fieldsToSave.toTypedArray()
if (idsToSave.isEmpty()) return null
var saveDataTypes = SaveInfo.SAVE_DATA_TYPE_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private constructor(
// https://developer.android.com/reference/android/service/autofill/SaveInfo#FLAG_DELAY_SAVE
private fun makeSaveInfo(): SaveInfo? {
if (!canBeSaved) return null
check(saveFlags != null)
check(saveFlags != null) { "saveFlags must not be null" }
val idsToSave = scenario.fieldsToSave.toTypedArray()
if (idsToSave.isEmpty()) return null
var saveDataTypes = SaveInfo.SAVE_DATA_TYPE_PASSWORD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class AutofillPublisherChangedException(val formOrigin: FormOrigin) :
) {

init {
require(formOrigin is FormOrigin.App)
require(formOrigin is FormOrigin.App) {
"${this::class.java.simpleName} is only applicable for apps"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import app.passwordstore.R
import app.passwordstore.data.repo.PasswordRepository
import app.passwordstore.util.extensions.unsafeLazy
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.eclipse.jgit.api.GitCommand
import org.eclipse.jgit.api.RebaseCommand
import org.eclipse.jgit.api.ResetCommand
import org.eclipse.jgit.lib.RepositoryState
Expand All @@ -30,7 +31,7 @@ class BreakOutOfDetached(callingActivity: AppCompatActivity) : GitOperation(call
git.checkout().setName(localBranch),
)

override val commands by unsafeLazy {
override val commands: Array<GitCommand<out Any>> by unsafeLazy {
if (merging) {
// We need to run some non-command operations first
repository.writeMergeCommitMsg(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.FragmentActivity
import app.passwordstore.R
import app.passwordstore.injection.prefs.GitPreferences
import app.passwordstore.util.coroutines.DispatcherProvider
import app.passwordstore.util.git.sshj.InteractivePasswordFinder
import app.passwordstore.util.settings.AuthMode
import app.passwordstore.util.settings.PreferenceKeys
Expand All @@ -32,7 +33,8 @@ import kotlin.coroutines.resume
class CredentialFinder(
private val callingActivity: FragmentActivity,
private val authMode: AuthMode,
) : InteractivePasswordFinder() {
dispatcherProvider: DispatcherProvider,
) : InteractivePasswordFinder(dispatcherProvider) {

private val hiltEntryPoint =
EntryPointAccessors.fromApplication(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
authMethod: SshAuthMethod,
credentialsProvider: CredentialsProvider? = null
) {
sshSessionFactory = SshjSessionFactory(authMethod, hostKeyFile, sshFacade)
sshSessionFactory =
SshjSessionFactory(authMethod, hostKeyFile, sshFacade, hiltEntryPoint.dispatcherProvider())
commands.filterIsInstance<TransportCommand<*, *>>().forEach { command ->
command.setTransportConfigCallback { transport: Transport ->
(transport as? SshTransport)?.sshSessionFactory = sshSessionFactory
Expand Down Expand Up @@ -217,7 +218,13 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
}
AuthMode.Password -> {
val httpsCredentialProvider =
HttpsCredentialsProvider(CredentialFinder(callingActivity, AuthMode.Password))
HttpsCredentialsProvider(
CredentialFinder(
callingActivity,
AuthMode.Password,
hiltEntryPoint.dispatcherProvider()
)
)
registerAuthProviders(SshAuthMethod.Password(authActivity), httpsCredentialProvider)
}
AuthMode.None -> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ package app.passwordstore.util.git.operation

import androidx.appcompat.app.AppCompatActivity
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode.TRACK
import org.eclipse.jgit.api.GitCommand
import org.eclipse.jgit.api.ResetCommand

class ResetToRemoteOperation(callingActivity: AppCompatActivity, remoteBranch: String) :
GitOperation(callingActivity) {

override val commands =
override val commands: Array<GitCommand<out Any>> =
arrayOf(
// Fetch everything from the origin remote
git.fetch().setRemote("origin").setRemoveDeletedRefs(true),
Expand Down
Loading

0 comments on commit 47d65d0

Please sign in to comment.