diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index cad6a21..f9d0b8a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,7 +26,7 @@ If applicable, add screenshots to help explain your problem. **Smartphone (please complete the following information):** - Device: [e.g. Pixel 3a] - OS: [e.g. api 33] - - Version [e.g. 1.0.9] +- Version [e.g. 1.0.10] **Additional context** Add any other context about the problem here. diff --git a/.github/actions/prepare-env/action.yml b/.github/actions/prepare-env/action.yml index 11f0641..316978a 100644 --- a/.github/actions/prepare-env/action.yml +++ b/.github/actions/prepare-env/action.yml @@ -5,7 +5,7 @@ runs: using: composite steps: - name: Set up JDK 17 - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'corretto' diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1e652f8..16674da 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -7,30 +7,29 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up environment for Android build uses: ./.github/actions/prepare-env - name: Lint run: ./gradlew lintDebug - - name: Ktlint - run: ./gradlew ktlintCheck - name: Detekt run: ./gradlew detektMain detektTest - name: Build with Gradle run: ./gradlew buildDebug - instrumentation-tests: - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - - name: Set up environment for Android build - uses: ./.github/actions/prepare-env - - name: Instrumentation tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 33 - target: default - arch: x86_64 - script: ./gradlew connectedCheck --stacktrace + # https://github.com/ReactiveCircus/android-emulator-runner/issues/266 + # instrumentation-tests: + # runs-on: macos-latest + # steps: + # - uses: actions/checkout@v3 + # - name: Set up environment for Android build + # uses: ./.github/actions/prepare-env + # - name: Instrumentation tests + # uses: reactivecircus/android-emulator-runner@v2 + # with: + # api-level: 33 + # target: default + # arch: x86_64 + # script: ./gradlew connectedCheck --stacktrace analyze: name: CodeQL runs-on: ubuntu-latest @@ -46,9 +45,9 @@ jobs: language: [ 'java-kotlin' ] steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Set up environment for Android build @@ -56,6 +55,6 @@ jobs: - name: Build with Gradle run: ./gradlew buildDebug - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:${{matrix.language}}" diff --git a/.gitignore b/.gitignore index 8ccc4f8..764cf91 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .externalNativeBuild .cxx local.properties +/.kotlin diff --git a/README.md b/README.md index ce83720..8516b83 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ and the dependency itself ```gradle dependencies { - implementation 'com.github.GrzegorzBobryk:ViewBindingDelegate:1.0.9' + implementation 'com.github.GrzegorzBobryk:ViewBindingDelegate:1.0.10' } ``` diff --git a/build.gradle.kts b/build.gradle.kts index bc2e565..34bbe00 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.extensions.DetektExtension -import org.jlleitschuh.gradle.ktlint.KtlintExtension import pl.beavercoding.viewbindingdelegate.buildsrc.detektPlugins buildscript { @@ -14,23 +13,17 @@ buildscript { classpath(Libs.androidGradlePlugin) classpath(Libs.Kotlin.gradlePlugin) classpath(Libs.Androidx.Navigation.safeArgsPlugin) - classpath(Libs.Ktlint.ktlintGradlePlugin) classpath(Libs.Detekt.detektGradlePlugin) } } allprojects { - apply(plugin = Libs.Ktlint.ktlintPlugin) apply(plugin = Libs.Detekt.detektPlugin) dependencies { detektPlugins(Libs.Detekt.detektFormatting) } - configure { - debug.set(true) - } - configure { debug = true allRules = false @@ -52,5 +45,5 @@ tasks.withType().configureEach { } tasks.register("clean", Delete::class) { - delete(rootProject.buildDir) + delete(rootProject.layout.buildDirectory) } diff --git a/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/DependencyHandlerExt.kt b/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/DependencyHandlerExt.kt index 6e12462..28bcfd4 100644 --- a/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/DependencyHandlerExt.kt +++ b/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/DependencyHandlerExt.kt @@ -1,7 +1,6 @@ package pl.beavercoding.viewbindingdelegate.buildsrc import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.DependencyHandler import org.gradle.kotlin.dsl.DependencyHandlerScope diff --git a/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/Libs.kt b/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/Libs.kt index 73309f0..6036eb7 100644 --- a/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/Libs.kt +++ b/buildSrc/src/main/kotlin/pl/beavercoding/viewbindingdelegate/buildsrc/Libs.kt @@ -6,20 +6,20 @@ import org.gradle.kotlin.dsl.project import pl.beavercoding.viewbindingdelegate.buildsrc.implementation object Libs { - private const val androidGradlePluginVersion = "8.2.2" + private const val androidGradlePluginVersion = "8.5.1" const val androidGradlePlugin = "com.android.tools.build:gradle:$androidGradlePluginVersion" const val junit = "junit:junit:4.13.2" val java = JavaVersion.VERSION_1_8 object Androidx { - const val core = "androidx.core:core-ktx:1.12.0" - const val appcompat = "androidx.appcompat:appcompat:1.6.1" + const val core = "androidx.core:core-ktx:1.13.1" + const val appcompat = "androidx.appcompat:appcompat:1.7.0" const val constraintLayout = "androidx.constraintlayout:constraintlayout:2.1.4" const val viewBinding = "androidx.databinding:viewbinding:$androidGradlePluginVersion" const val recyclerView = "androidx.recyclerview:recyclerview:1.3.2" object Navigation { - private const val version = "2.7.6" + private const val version = "2.7.7" const val safeArgsPlugin = "androidx.navigation:navigation-safe-args-gradle-plugin:$version" const val fragment = "androidx.navigation:navigation-fragment-ktx:$version" @@ -27,36 +27,31 @@ object Libs { } object Test { - const val espresso = "androidx.test.espresso:espresso-core:3.5.1" - const val junitExt = "androidx.test.ext:junit-ktx:1.1.5" + const val espresso = "androidx.test.espresso:espresso-core:3.6.1" + const val junitExt = "androidx.test.ext:junit-ktx:1.2.1" } } object Google { - const val material = "com.google.android.material:material:1.11.0" + const val material = "com.google.android.material:material:1.12.0" } object Kotlin { - private const val version = "1.9.22" + private const val version = "2.0.10" const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib:$version" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$version" } object CanaryLeak { - private const val version = "2.13" + private const val version = "2.14" const val android = "com.squareup.leakcanary:leakcanary-android:$version" const val androidTests = "com.squareup.leakcanary:leakcanary-android-instrumentation:$version" } - object Ktlint { - const val ktlintGradlePlugin = "org.jlleitschuh.gradle:ktlint-gradle:12.0.3" - const val ktlintPlugin = "org.jlleitschuh.gradle.ktlint" - } - object Detekt { - private const val version = "1.23.4" + private const val version = "1.23.6" const val detektGradlePlugin = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$version" const val detektFormatting = "io.gitlab.arturbosch.detekt:detekt-formatting:$version" const val detektPlugin = "io.gitlab.arturbosch.detekt" diff --git a/config/detekt.yml b/config/detekt.yml index f0ffa93..46d843a 100644 --- a/config/detekt.yml +++ b/config/detekt.yml @@ -1,11 +1,101 @@ formatting: + # https://detekt.dev/docs/rules/formatting/#maximumlinelength + # docks are saying to keep MaxLineLength or MaximumLineLength but it is not working this way. + # ExampleAdapter.onCreateViewHolder is not working when we remove option below. + # Exceeded max line length (120) [MaximumLineLength] MaximumLineLength: active: true maxLineLength: 130 ArgumentListWrapping: active: true maxLineLength: 130 + TrailingCommaOnCallSite: + active: true + TrailingCommaOnDeclarationSite: + active: true + IfElseBracing: + active: true + ParameterListSpacing: + active: true + TryCatchFinallySpacing: + active: true + TypeArgumentListSpacing: + active: true + TypeParameterListSpacing: + active: true style: MaxLineLength: active: true maxLineLength: 130 + excludeRawStrings: true + AlsoCouldBeApply: + active: true + MandatoryBracesIfStatements: + active: true + consistent: true + CanBeNonNullable: + active: true + ClassOrdering: + active: true + CollapsibleIfStatements: + active: true + ExplicitCollectionElementAccessMethod: + active: true + ForbiddenAnnotation: + active: true + MandatoryBracesLoops: + active: true + NewLineAtEndOfFile: + active: true + OptionalUnit: + active: true + SpacingBetweenPackageAndImports: + active: true + TrailingWhitespace: + active: true + UnderscoresInNumericLiterals: + active: true + UnnecessaryBackticks: + active: true + UnnecessaryBracesAroundTrailingLambda: + active: true + UnnecessaryLet: + active: true + UnnecessaryParentheses: + active: true + UnusedImports: + active: true + UseEmptyCounterpart: + active: true + UseIfEmptyOrIfBlank: + active: true + UseSumOfInsteadOfFlatMapSize: + active: true +coroutines: + GlobalCoroutineUsage: + active: true + RedundantSuspendModifier: + active: true + SuspendFunWithCoroutineScopeReceiver: + active: true + SuspendFunWithFlowReturnType: + active: true +exceptions: + ObjectExtendsThrowable: + active: true +performance: + CouldBeSequence: + active: true +potential-bugs: + CastToNullableType: + active: true + ElseCaseInsteadOfExhaustiveWhen: + active: true + MissingPackageDeclaration: + active: true + NullCheckOnMutableProperty: + active: true + PropertyUsedBeforeDeclaration: + active: true + UnnecessaryNotNullCheck: + active: true diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7af6206..29e195a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Feb 06 14:36:24 CET 2023 +#Sun Aug 11 11:26:48 CEST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/sample/src/androidTest/kotlin/pl/beavercoding/viewbindingdelegate/MainActivityTest.kt b/sample/src/androidTest/kotlin/pl/beavercoding/viewbindingdelegate/MainActivityTest.kt index 31cf1b7..7251a00 100644 --- a/sample/src/androidTest/kotlin/pl/beavercoding/viewbindingdelegate/MainActivityTest.kt +++ b/sample/src/androidTest/kotlin/pl/beavercoding/viewbindingdelegate/MainActivityTest.kt @@ -36,7 +36,7 @@ internal class MainActivityTest { allOf( childAtPosition(hasDescendant(withText(resources.getString(R.string.example_1))), 0), - isDisplayed() + isDisplayed(), ) val materialButton = onView( @@ -46,12 +46,12 @@ internal class MainActivityTest { childAtPosition( childAtPosition( withId(R.id.nav_host_fragment), - 0 + 0, ), - 1 + 1, ), - isDisplayed() - ) + isDisplayed(), + ), ) materialButton.perform(click()) @@ -60,8 +60,8 @@ internal class MainActivityTest { withId(R.id.hello_world), withText(resources.getString(R.string.example_2)), withParent(withParent(withId(R.id.nav_host_fragment))), - isDisplayed() - ) + isDisplayed(), + ), ) textView2.check(matches(withText(resources.getString(R.string.example_2)))) @@ -72,12 +72,12 @@ internal class MainActivityTest { childAtPosition( childAtPosition( withId(R.id.nav_host_fragment), - 0 + 0, ), - 1 + 1, ), - isDisplayed() - ) + isDisplayed(), + ), ) materialButton2.perform(click()) @@ -86,8 +86,8 @@ internal class MainActivityTest { withId(R.id.hello_world), withText(resources.getString(R.string.example_3)), withParent(withParent(withId(R.id.nav_host_fragment))), - isDisplayed() - ) + isDisplayed(), + ), ) textView3.check(matches(withText(resources.getString(R.string.example_3)))) LeakAssertions.assertNoLeaks() diff --git a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/Example.kt b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/Example.kt index db9bd5b..262baf5 100644 --- a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/Example.kt +++ b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/Example.kt @@ -2,5 +2,5 @@ package pl.beavercoding.viewbindingdelegate internal data class Example( val id: Int, - val title: String + val title: String, ) diff --git a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleAdapter.kt b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleAdapter.kt index 7a02429..7407787 100644 --- a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleAdapter.kt +++ b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleAdapter.kt @@ -10,7 +10,7 @@ import pl.beavercoding.viewbindingdelegate.databinding.RowExampleBinding private typealias OnExampleClicked = (Example) -> Unit internal class ExampleAdapter( - private val onExampleClicked: OnExampleClicked + private val onExampleClicked: OnExampleClicked, ) : ListAdapter(DiffCallback()) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ExampleViewHolder.create(parent, onExampleClicked) @@ -19,7 +19,7 @@ internal class ExampleAdapter( internal class ExampleViewHolder private constructor( private val binding: RowExampleBinding, - private val onExampleClicked: OnExampleClicked + private val onExampleClicked: OnExampleClicked, ) : RecyclerView.ViewHolder(binding.root) { internal fun bind(example: Example) { @@ -34,7 +34,7 @@ internal class ExampleAdapter( companion object { internal fun create( parent: ViewGroup, - onExampleClicked: OnExampleClicked + onExampleClicked: OnExampleClicked, ): ExampleViewHolder { val binding = RowExampleBinding.inflate(LayoutInflater.from(parent.context), parent, false) return ExampleViewHolder(binding, onExampleClicked) diff --git a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleFragment1.kt b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleFragment1.kt index c0cb7f3..fe6d5c3 100644 --- a/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleFragment1.kt +++ b/sample/src/main/kotlin/pl/beavercoding/viewbindingdelegate/ExampleFragment1.kt @@ -21,7 +21,7 @@ internal class ExampleFragment1 : Fragment(R.layout.fragment_example_1) { val list = listOf( Example(R.id.first, getString(R.string.example_1)), Example(R.id.second, getString(R.string.example_1)), - Example(R.id.third, getString(R.string.example_1)) + Example(R.id.third, getString(R.string.example_1)), ) adapter.submitList(list) diff --git a/view-binder/build.gradle.kts b/view-binder/build.gradle.kts index 6995199..ec2147f 100644 --- a/view-binder/build.gradle.kts +++ b/view-binder/build.gradle.kts @@ -40,7 +40,7 @@ afterEvaluate { groupId = "com.github.grzegorzbobryk" artifactId = "view-binder" - version = "1.0.9" + version = "1.0.10" } } } diff --git a/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/fragmentViewBindingProperty.kt b/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/fragmentViewBindingProperty.kt index 8922fba..a5e987a 100644 --- a/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/fragmentViewBindingProperty.kt +++ b/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/fragmentViewBindingProperty.kt @@ -32,7 +32,7 @@ fun interface ViewBinder { */ @BinderInternalApi class FragmentViewBindingProperty( - private val viewBinder: ViewBinder + private val viewBinder: ViewBinder, ) : ReadOnlyProperty { private var viewBinding: T? = null diff --git a/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/recyclerExtensions.kt b/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/recyclerExtensions.kt index ac14d30..9f55d77 100644 --- a/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/recyclerExtensions.kt +++ b/view-binder/src/main/kotlin/pl/beavercoding/viewBinder/recyclerExtensions.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView * Safe setting new [RecyclerView.Adapter] that is leak resistant. Do NOT call it from pagers. */ fun RecyclerView.safeSetAdapter( - adapter: RecyclerView.Adapter + adapter: RecyclerView.Adapter, ) { this.adapter = adapter clearReferenceOnDetached()