Skip to content

Commit

Permalink
build(deps): bump to ktlint 1.5.0 & manual fixups
Browse files Browse the repository at this point in the history
Manually fixed up the result of
`./gradlew --rerun-tasks ktLintFormat`

I had issues with `libs.versions.toml`, so this was left as a TODO
  • Loading branch information
david-allison committed Dec 9, 2024
1 parent 418b760 commit e89df3d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
9 changes: 1 addition & 8 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@ end_of_line = crlf
[*.kt]
# We often have block comments representing implementation details after KDocs.
# This feels like an acceptable commenting strategy
ktlint_standard_no-consecutive-comments = disabled

# These can be removed once we upgrade to ktlint 1.5.0
# These are added in preparation for the move to gradle.ktlint 12.1.1

# Rule 'standard:parameter-list-wrapping' throws exception in file 'DeckConfig.kt' at position (0:0)
[*DeckConfig.kt]
ktlint_standard_parameter-list-wrapping = disabled
ktlint_standard_no-consecutive-comments = disabled
5 changes: 3 additions & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/MyAccount.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ open class MyAccount : AnkiActivity() {
usernameLoggedIn.text = username
toolbar =
loggedIntoMyAccountView.findViewById<Toolbar?>(R.id.toolbar)?.also { toolbar ->
toolbar.title =
getString(R.string.sync_account) // This can be cleaned up if all three main layouts are guaranteed to share the same toolbar object
// This can be cleaned up if all three main layouts are guaranteed
// to share the same toolbar object
toolbar.title = getString(R.string.sync_account)
setSupportActionBar(toolbar)
}
setContentView(loggedIntoMyAccountView)
Expand Down
3 changes: 1 addition & 2 deletions AnkiDroid/src/main/java/com/ichi2/libanki/DeckConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import com.ichi2.utils.deepClonedInto
import org.json.JSONObject
import timber.log.Timber

class DeckConfig
/**
* Creates a copy from [JSONObject] and use it as a string
*
* This function will perform deepCopy on the passed object
*
*/
(
class DeckConfig(
json: JSONObject,
) : JSONObject() {
var conf: Long
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/libanki/Notetypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Notetypes(
#############################################################
*/

@Suppress("ktlint:standard:property-naming")
@Suppress("ktlint:standard:backing-property-naming")
private var _cache: HashMap<int, NotetypeJson> = HashMap()

init {
Expand Down
7 changes: 7 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/libanki/TemplateManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,16 @@ class TemplateManager {
template: JSONObject? = null,
private var fillEmpty: Boolean = false,
) {
@Suppress("ktlint:standard:backing-property-naming")
private var _card: Card = card

@Suppress("ktlint:standard:backing-property-naming")
private var _note: Note = note

@Suppress("ktlint:standard:backing-property-naming")
private var _browser: Boolean = browser

@Suppress("ktlint:standard:backing-property-naming")
private var _template: JSONObject? = template

private var noteType: NotetypeJson = notetype ?: note.notetype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ abstract class AppCompatPreferenceActivity<PreferenceHack : AppCompatPreferenceA
PreferenceActivity(),
CoroutineScope by MainScope(),
SharedPreferences.OnSharedPreferenceChangeListener {
@Suppress("ktlint:standard:backing-property-naming")
private var _delegate: AppCompatDelegate? = null

fun isColInitialized() = ::col.isInitialized
Expand Down
6 changes: 3 additions & 3 deletions api/src/main/java/com/ichi2/anki/FlashCardsContract.kt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public object FlashCardsContract {
* used for accessing the data of a note using the URI
* "content://com.ichi2.anki.flashcards/notes/<ID>/data
*/
@Suppress("ConstPropertyName", "ktlint:standard:property-naming")
@Suppress("ConstPropertyName", "ktlint:standard:backing-property-naming")
public const val _ID: String = "_id"

// field is part of the default projection available to the clients
Expand Down Expand Up @@ -362,7 +362,7 @@ public object FlashCardsContract {
* used for accessing the data of the model using the URI
* `content://com.ichi2.anki.flashcards/models/<ID>`
*/
@Suppress("ConstPropertyName", "ktlint:standard:property-naming")
@Suppress("ConstPropertyName", "ktlint:standard:backing-property-naming")
public const val _ID: String = "_id"
public const val NAME: String = "name"
public const val FIELD_NAME: String = "field_name"
Expand Down Expand Up @@ -428,7 +428,7 @@ public object FlashCardsContract {
* reliably over subsequent queries. Especially if the number of cards or fields changes,
* the _ID will change too.
*/
@Suppress("ConstPropertyName", "ktlint:standard:property-naming")
@Suppress("ConstPropertyName", "ktlint:standard:backing-property-naming")
public const val _ID: String = "_id"

/**
Expand Down
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.slack.keeper.optInToKeeper
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.internal.jvm.Jvm
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream
import kotlin.math.max

// Top-level build file where you can add configuration options common to all sub-projects/modules.
Expand All @@ -29,7 +28,11 @@ val fatalWarnings = !(localProperties["fatal_warnings"] == "false")

// Here we extract per-module "best practices" settings to a single top-level evaluation
subprojects {
// TODO: should be able to use libs.versions.toml here
apply(plugin = "org.jlleitschuh.gradle.ktlint")
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
version.set("1.5.0")
}

afterEvaluate {
if (hasProperty("android")) {
Expand Down

0 comments on commit e89df3d

Please sign in to comment.