Skip to content

Commit

Permalink
[enhancement] Fix Lint warnings including: * Unused namespaces in XML…
Browse files Browse the repository at this point in the history
… * Add task configuration avoidance by using register when define a gradle task * Update protected visibility in final class to private as they are effectively the same * Add private modifier for variables where needed * Upgrade kotlin version & kotlin gradle plugin to 1.8.20 * Naming issues and others

[lint] Execute ktlintCheck prior to every git commit to scan for lint errors
  • Loading branch information
tuancoltech committed Oct 31, 2023
1 parent 5722184 commit 04f2ede
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
19 changes: 19 additions & 0 deletions app/app-scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
echo "*********************************************************"
echo "Running git pre-commit hook, ktlintCheck in progress..."
echo "*********************************************************"

./gradlew ktlintCheck

status=$?

if [ "$status" = 0 ] ; then
echo "Static analysis found no problems."
exit 0
else
echo "*********************************************************"
echo 1>&2 "ktlintCheck found violations it could not fix."
echo "Run ./gradlew ktlintFormat to fix formatting related issues..."
echo "*********************************************************"
exit 1
fi
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,5 @@ tasks.register('installGitHook', Copy) {
rename("pre-commit-$suffix", 'pre-commit')
fileMode 0775
}

build.dependsOn installGitHook
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import org.orbitmvi.orbit.syntax.simple.postSideEffect
import org.orbitmvi.orbit.syntax.simple.reduce
import org.orbitmvi.orbit.viewmodel.container
import java.nio.file.Path
import android.view.View

class ProgressWithText(val enabled: Boolean, val text: String = "")

data class FoldersState private constructor(
val devices: List<Path>,
val folders: Map<Path, List<Path>>,
val progressWithText: ProgressWithText
val progressWithText: ProgressWithText,
) {
companion object {
fun initial() =
Expand All @@ -52,7 +53,7 @@ class FoldersViewModel(
private val resourcesIndexRepo: ResourceIndexRepo,
private val preferences: Preferences,
private val permsHelper: PermissionsHelper,
private val devicePathsExtractor: DevicePathsExtractor
private val devicePathsExtractor: DevicePathsExtractor,
) : ViewModel(), ContainerHost<FoldersState, FoldersSideEffect> {

override val container: Container<FoldersState, FoldersSideEffect> = container(
Expand Down Expand Up @@ -139,7 +140,7 @@ class FoldersViewModel(
fun onForgetFavorite(
root: Path,
favorite: Path,
deleteFromMemory: Boolean
deleteFromMemory: Boolean,
) = intent {
reduce {
state.copy(
Expand Down Expand Up @@ -287,7 +288,7 @@ class FoldersViewModelFactory @AssistedInject constructor(
private val resourcesIndexRepo: ResourceIndexRepo,
private val preferences: Preferences,
private val permsHelper: PermissionsHelper,
private val devicePathsExtractor: DevicePathsExtractor
private val devicePathsExtractor: DevicePathsExtractor,
) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return FoldersViewModel(
Expand All @@ -303,7 +304,7 @@ class FoldersViewModelFactory @AssistedInject constructor(
@AssistedFactory
interface Factory {
fun create(
@Assisted rescanRoots: Boolean
@Assisted rescanRoots: Boolean,
): FoldersViewModelFactory
}
}

0 comments on commit 04f2ede

Please sign in to comment.