Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit e60a0f0

Browse files
author
Chris Banes
committed
Run code style checks on pre-submit
We now use the Spotless plugin to run ktlint and keep our code style in check. It also does copyright header checking. This CL also updates the build script to run the `check` task which will invoke spotless and lint, to make sure we don't commit things that shouldn't be. Change-Id: Ief6510eb8018ec4d40f996fbec3beb7fb6aef005
1 parent 6d4a67e commit e60a0f0

File tree

13 files changed

+46
-17
lines changed

13 files changed

+46
-17
lines changed

build.gradle

+13-2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ buildscript {
9595
}
9696
}
9797

98+
plugins {
99+
id "com.diffplug.gradle.spotless" version "3.17.0"
100+
}
101+
98102
allprojects {
99103
repositories {
100104
google()
@@ -113,6 +117,13 @@ allprojects {
113117
}
114118
}
115119

116-
task clean(type: Delete) {
117-
delete rootProject.buildDir
120+
subprojects {
121+
apply plugin: 'com.diffplug.gradle.spotless'
122+
spotless {
123+
kotlin {
124+
target "**/*.kt"
125+
ktlint("0.29.0")
126+
licenseHeaderFile project.rootProject.file('copyright.kt')
127+
}
128+
}
118129
}

copyright.kt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright $YEAR Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+

mobile/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ android {
100100
}
101101

102102
lintOptions {
103+
// Running lint over the debug variant is enough
104+
checkReleaseBuilds false
105+
103106
disable "InvalidPackage", "MissingTranslation"
104107
}
105108

mobile/src/main/java/com/google/samples/apps/iosched/di/ActivityBindingModule.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.samples.apps.iosched.di
1718

1819
import com.google.samples.apps.iosched.shared.di.ActivityScoped

mobile/src/main/java/com/google/samples/apps/iosched/ui/MainActivity.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.samples.apps.iosched.ui
1718

1819
import android.app.Activity

mobile/src/main/java/com/google/samples/apps/iosched/ui/signin/NotificationsPreferenceDialogFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class NotificationsPreferenceDialogFragment : DaggerAppCompatDialogFragment() {
3939
return MaterialAlertDialogBuilder(requireContext())
4040
.setTitle(R.string.notifications_preference_dialog_title)
4141
.setMessage(R.string.notifications_preference_dialog_content)
42-
.setNegativeButton(R.string.no) { _, _ -> notificationsPrefSaveActionUseCase(false) }
42+
.setNegativeButton(R.string.no) { _, _ -> notificationsPrefSaveActionUseCase(false) }
4343
.setPositiveButton(R.string.yes) { _, _ -> notificationsPrefSaveActionUseCase(true) }
4444
.setOnDismissListener { notificationsPrefShownActionUseCase(true) }
4545
.create()

mobile/src/main/java/com/google/samples/apps/iosched/ui/signin/SignOutDialogFragment.kt

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import com.google.samples.apps.iosched.shared.result.EventObserver
2525
import com.google.samples.apps.iosched.shared.util.viewModelProvider
2626
import com.google.samples.apps.iosched.ui.signin.SignInEvent.RequestSignOut
2727
import com.google.samples.apps.iosched.util.signin.SignInHandler
28-
import dagger.android.AndroidInjector
2928
import dagger.android.support.DaggerAppCompatDialogFragment
3029
import javax.inject.Inject
3130

mobile/src/main/java/com/google/samples/apps/iosched/util/FirebaseAnalyticsHelper.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2014 Google Inc. All rights reserved.
2+
* Copyright 2019 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,

mobile/src/main/java/com/google/samples/apps/iosched/widget/transition/Rotate.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
/*
2-
* Copyright (C) 2018 The Android Open Source Project
2+
* Copyright 2018 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
8+
* https://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.samples.apps.iosched.widget.transition
1718

1819
import android.animation.Animator

model/src/main/java/com/google/samples/apps/iosched/model/Block.kt

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.google.samples.apps.iosched.model
1718

1819
import org.threeten.bp.ZonedDateTime

shared/src/main/java/com/google/samples/apps/iosched/shared/fcm/IoschedFirebaseInstanceIDService.kt

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package com.google.samples.apps.iosched.shared.fcm
1818

1919
import com.google.firebase.iid.FirebaseInstanceId
2020

21-
import timber.log.Timber
22-
2321
/**
2422
* Service that receives new FCM ID Tokens.
2523
*/

tv/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ android {
5151
matchingFallbacks = ['debug']
5252
}
5353

54+
5455
debug {
5556
manifestPlaceholders = [crashlyticsEnabled: false]
5657
}
@@ -60,6 +61,9 @@ android {
6061
}
6162

6263
lintOptions {
64+
// Running lint over the debug variant is enough
65+
checkReleaseBuilds false
66+
6367
disable "InvalidPackage", "MissingTranslation"
6468
}
6569

tv/src/main/java/com/google/samples/apps/iosched/tv/ui/sessiondetail/SessionDetailFragment.kt

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.samples.apps.iosched.tv.ui.sessiondetail
1818

1919
import android.content.Context
20-
import android.graphics.Bitmap
2120
import android.os.Bundle
2221
import android.widget.Toast
2322
import androidx.core.content.ContextCompat
@@ -28,16 +27,11 @@ import androidx.leanback.widget.ClassPresenterSelector
2827
import androidx.leanback.widget.DetailsOverviewRow
2928
import androidx.leanback.widget.DiffCallback
3029
import androidx.leanback.widget.FullWidthDetailsOverviewRowPresenter
31-
import androidx.leanback.widget.FullWidthDetailsOverviewSharedElementHelper
3230
import androidx.leanback.widget.HeaderItem
3331
import androidx.leanback.widget.ListRow
3432
import androidx.leanback.widget.ListRowPresenter
3533
import androidx.leanback.widget.OnActionClickedListener
3634
import androidx.lifecycle.Observer
37-
import com.bumptech.glide.Glide
38-
import com.bumptech.glide.request.RequestOptions
39-
import com.bumptech.glide.request.target.SimpleTarget
40-
import com.bumptech.glide.request.transition.Transition
4135
import com.google.samples.apps.iosched.model.Session
4236
import com.google.samples.apps.iosched.model.Speaker
4337
import com.google.samples.apps.iosched.shared.util.SpeakerUtils
@@ -53,7 +47,7 @@ import com.google.samples.apps.iosched.tv.util.toArrayObjectAdapter
5347
import javax.inject.Inject
5448

5549
private const val ACTION_WATCH = 1L
56-
//private const val ACTION_STAR = 2L
50+
// private const val ACTION_STAR = 2L
5751

5852
/**
5953
* Displays the details for a [Session].

0 commit comments

Comments
 (0)