Skip to content

Commit c1adf5b

Browse files
authored
Switch from ktlint to ktfmt (#4318)
Additionally upgrade google-java-format to latest version.
1 parent d4cc84d commit c1adf5b

File tree

79 files changed

+5758
-5370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5758
-5370
lines changed

appcheck/firebase-appcheck/ktx/src/androidTest/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheckTests.kt

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,70 +37,70 @@ const val EXISTING_APP = "existing"
3737

3838
@RunWith(AndroidJUnit4ClassRunner::class)
3939
abstract class BaseTestCase {
40-
@Before
41-
fun setUp() {
42-
Firebase.initialize(
43-
ApplicationProvider.getApplicationContext(),
44-
FirebaseOptions.Builder()
45-
.setApplicationId(APP_ID)
46-
.setApiKey(API_KEY)
47-
.setProjectId("123")
48-
.build()
49-
)
40+
@Before
41+
fun setUp() {
42+
Firebase.initialize(
43+
ApplicationProvider.getApplicationContext(),
44+
FirebaseOptions.Builder()
45+
.setApplicationId(APP_ID)
46+
.setApiKey(API_KEY)
47+
.setProjectId("123")
48+
.build()
49+
)
5050

51-
Firebase.initialize(
52-
ApplicationProvider.getApplicationContext(),
53-
FirebaseOptions.Builder()
54-
.setApplicationId(APP_ID)
55-
.setApiKey(API_KEY)
56-
.setProjectId("123")
57-
.build(),
58-
EXISTING_APP
59-
)
60-
}
51+
Firebase.initialize(
52+
ApplicationProvider.getApplicationContext(),
53+
FirebaseOptions.Builder()
54+
.setApplicationId(APP_ID)
55+
.setApiKey(API_KEY)
56+
.setProjectId("123")
57+
.build(),
58+
EXISTING_APP
59+
)
60+
}
6161

62-
@After
63-
fun cleanUp() {
64-
FirebaseApp.clearInstancesForTest()
65-
}
62+
@After
63+
fun cleanUp() {
64+
FirebaseApp.clearInstancesForTest()
65+
}
6666
}
6767

6868
@RunWith(AndroidJUnit4ClassRunner::class)
6969
class FirebaseAppCheckTests : BaseTestCase() {
70-
@Test
71-
fun appCheck_default_callsDefaultGetInstance() {
72-
assertThat(Firebase.appCheck).isSameInstanceAs(FirebaseAppCheck.getInstance())
73-
}
70+
@Test
71+
fun appCheck_default_callsDefaultGetInstance() {
72+
assertThat(Firebase.appCheck).isSameInstanceAs(FirebaseAppCheck.getInstance())
73+
}
7474

75-
@Test
76-
fun appCheck_with_custom_firebaseapp_calls_GetInstance() {
77-
val app = Firebase.app(EXISTING_APP)
78-
assertThat(Firebase.appCheck(app))
79-
.isSameInstanceAs(FirebaseAppCheck.getInstance(app))
80-
}
75+
@Test
76+
fun appCheck_with_custom_firebaseapp_calls_GetInstance() {
77+
val app = Firebase.app(EXISTING_APP)
78+
assertThat(Firebase.appCheck(app)).isSameInstanceAs(FirebaseAppCheck.getInstance(app))
79+
}
8180

82-
@Test
83-
fun appCheckToken_destructuring_declaration_works() {
84-
val mockAppCheckToken = object : AppCheckToken() {
85-
override fun getToken(): String = "randomToken"
81+
@Test
82+
fun appCheckToken_destructuring_declaration_works() {
83+
val mockAppCheckToken =
84+
object : AppCheckToken() {
85+
override fun getToken(): String = "randomToken"
8686

87-
override fun getExpireTimeMillis(): Long = 23121997
88-
}
87+
override fun getExpireTimeMillis(): Long = 23121997
88+
}
8989

90-
val (token, expiration) = mockAppCheckToken
90+
val (token, expiration) = mockAppCheckToken
9191

92-
assertThat(token).isEqualTo(mockAppCheckToken.token)
93-
assertThat(expiration).isEqualTo(mockAppCheckToken.expireTimeMillis)
94-
}
92+
assertThat(token).isEqualTo(mockAppCheckToken.token)
93+
assertThat(expiration).isEqualTo(mockAppCheckToken.expireTimeMillis)
94+
}
9595
}
9696

9797
internal const val LIBRARY_NAME: String = "fire-app-check-ktx"
9898

9999
@RunWith(AndroidJUnit4ClassRunner::class)
100100
class LibraryVersionTest : BaseTestCase() {
101-
@Test
102-
fun libraryRegistrationAtRuntime() {
103-
val publisher = Firebase.app.get(UserAgentPublisher::class.java)
104-
assertThat(publisher.userAgent).contains(LIBRARY_NAME)
105-
}
101+
@Test
102+
fun libraryRegistrationAtRuntime() {
103+
val publisher = Firebase.app.get(UserAgentPublisher::class.java)
104+
assertThat(publisher.userAgent).contains(LIBRARY_NAME)
105+
}
106106
}

appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import com.google.firebase.platforminfo.LibraryVersionComponent
2525

2626
/** Returns the [FirebaseAppCheck] instance of the default [FirebaseApp]. */
2727
val Firebase.appCheck: FirebaseAppCheck
28-
get() = FirebaseAppCheck.getInstance()
28+
get() = FirebaseAppCheck.getInstance()
2929

3030
/** Returns the [FirebaseAppCheck] instance of a given [FirebaseApp]. */
3131
fun Firebase.appCheck(app: FirebaseApp) = FirebaseAppCheck.getInstance(app)
@@ -48,6 +48,6 @@ internal const val LIBRARY_NAME: String = "fire-app-check-ktx"
4848

4949
/** @suppress */
5050
class FirebaseAppCheckKtxRegistrar : ComponentRegistrar {
51-
override fun getComponents(): List<Component<*>> =
52-
listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME))
51+
override fun getComponents(): List<Component<*>> =
52+
listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME))
5353
}

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ buildscript {
3939
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0'
4040
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'
4141
classpath 'com.google.gms:google-services:4.3.3'
42-
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.2.1'
42+
classpath "com.ncorti.ktfmt.gradle:plugin:0.11.0"
4343
}
4444
}
4545

@@ -87,7 +87,11 @@ configure(subprojects) {
8787
}
8888
}
8989

90-
apply plugin: "org.jlleitschuh.gradle.ktlint"
90+
apply plugin: "com.ncorti.ktfmt.gradle"
91+
92+
ktfmt {
93+
googleStyle()
94+
}
9195
}
9296

9397
task clean(type: Delete) {

buildSrc/build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
plugins {
16-
id("org.jlleitschuh.gradle.ktlint") version "9.2.1"
16+
id("com.ncorti.ktfmt.gradle") version "0.11.0"
1717
id("com.github.sherter.google-java-format") version "0.9"
1818
`kotlin-dsl`
1919
}
@@ -32,7 +32,11 @@ repositories {
3232
val perfPluginVersion = System.getenv("FIREBASE_PERF_PLUGIN_VERSION") ?: "1.4.1"
3333

3434
googleJavaFormat {
35-
toolVersion = "1.10.0"
35+
toolVersion = "1.15.0"
36+
}
37+
38+
ktfmt {
39+
googleStyle()
3640
}
3741

3842
dependencies {

buildSrc/src/main/java/com/google/firebase/gradle/NdkBinaryFixTask.kt

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,22 @@ import org.gradle.api.tasks.OutputFile
2424
import org.gradle.api.tasks.TaskAction
2525

2626
abstract class NdkBinaryFixTask : DefaultTask() {
27-
@get:InputFile
28-
abstract val inputFile: RegularFileProperty
27+
@get:InputFile abstract val inputFile: RegularFileProperty
2928

30-
@get:OutputFile
31-
val outputFile: File
32-
get() = inputFile.get().asFile.let {
33-
File(it.parentFile, "lib${it.name}.so")
34-
}
29+
@get:OutputFile
30+
val outputFile: File
31+
get() = inputFile.get().asFile.let { File(it.parentFile, "lib${it.name}.so") }
3532

36-
@get:Internal
37-
val into: String
38-
get() = "jni/${outputFile.parentFile.name}"
33+
@get:Internal
34+
val into: String
35+
get() = "jni/${outputFile.parentFile.name}"
3936

40-
@TaskAction
41-
fun run() {
42-
Files.copy(
43-
inputFile.get().asFile.toPath(),
44-
outputFile.toPath(),
45-
StandardCopyOption.REPLACE_EXISTING
46-
)
47-
}
37+
@TaskAction
38+
fun run() {
39+
Files.copy(
40+
inputFile.get().asFile.toPath(),
41+
outputFile.toPath(),
42+
StandardCopyOption.REPLACE_EXISTING
43+
)
44+
}
4845
}

0 commit comments

Comments
 (0)