Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance: Bind extension to product flavor for robust type safety #1848

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

laynepenney
Copy link

Pull Request Description

This pull request includes two commits aimed at improving the codebase:


1. Enhance: Bind extension to product flavor for robust type safety

What Changed:
Refactored flavor configuration in NiaFlavor.kt by eliminating runtime type checks for ApplicationExtension and ApplicationProductFlavor. The new implementation leverages generics to explicitly bind the extension (E) to the product flavor (F), ensuring that configuration is unambiguous and type-safe at compile time.

Why:
This change removes unnecessary runtime checks and enhances compile-time safety.


2. Enhance: Enforce consistent formatting with Spotless plugin

What Changed:
Ran the Spotless plugin across the codebase to ensure that all code adheres to the established style guidelines. This commit is purely a formatting cleanup and does not affect functionality.

Why:
Consistent formatting improves code readability and maintainability, reinforcing the commitment to a clean and uniform codebase through the build-logic Gradle module.


Testing and Verification (CD into build-logic Directory)

Local Tests:
Verified changes by running tests on the DemoDebug variant using the command: ../gradlew build.

Formatting:
Applied code formatting using the command: ../gradlew --init-script ../gradle/init.gradle.kts spotlessApply.


Additional Context

This pull request is designed to strengthen type safety and clarity in the flavor configuration while also ensuring consistent code formatting throughout the build-logic Gradle module. Together, these changes contribute to a more robust and maintainable codebase.

@laynepenney laynepenney marked this pull request as ready for review March 22, 2025 20:11
This commit refactors flavor configuration in NiaFlavor.kt. The previous implementation relied on runtime type checks for ApplicationExtension and ApplicationProductFlavor, whereas the updated code leverages generics to explicitly bind the extension (E) to the product flavor (F). This change eliminates unnecessary runtime checks and enhances compile-time type safety. Additionally, the introduction of @JvmName(“configureFlavorsImpl”) resolves JVM signature clashes, streamlining our DSL and improving overall code clarity.
… plugin

This commit runs the Spotless plugin on `build-logic` to ensure that all code adheres to our style guidelines. As a follow-up to the recent flavor configuration refactor, this cleanup reinforces our commitment to a robust, readable, and maintainable codebase without altering functionality.
@laynepenney laynepenney force-pushed the enhance/extension-flavor-type-safety branch from bfc9160 to fe677ed Compare March 30, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant