Skip to content

Commit

Permalink
Merge pull request #1394 from navikt/chore/upgrade-ktlint-gradle-plugin
Browse files Browse the repository at this point in the history
Chore/upgrade ktlint gradle plugin
  • Loading branch information
sondrele authored Apr 20, 2023
2 parents 8f627cc + be9b1ed commit 9d16a4b
Show file tree
Hide file tree
Showing 180 changed files with 742 additions and 768 deletions.
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
root = true

[*]
disabled_rules = no-wildcard-imports
end_of_line = lf
insert_final_newline = true
charset = utf-8
Expand All @@ -11,6 +10,9 @@ trim_trailing_whitespace = true
indent_size = 4
indent_style = space

# Custom config to override `ktlint` defaults
ktlint_standard_no-wildcard-imports = disabled

[*.{js,ts,tsx,json}]
indent_size = 2
indent_style = space
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.KtlintExtension

group = "no.nav.mulighetsrommet"
version = "0.0.1"
Expand All @@ -14,6 +15,13 @@ plugins {
}

allprojects {
// Apply ktlint for all projects
apply(plugin = "org.jlleitschuh.gradle.ktlint")

configure<KtlintExtension> {
version.set("0.48.2")
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}
Expand Down
5 changes: 0 additions & 5 deletions common/database/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
plugins {
`java-test-fixtures`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktlint)
}

ktlint {
disabledRules.addAll("no-wildcard-imports")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package no.nav.mulighetsrommet.database
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import no.nav.mulighetsrommet.slack_notifier.SlackNotifier
import no.nav.mulighetsrommet.slack.SlackNotifier
import org.flywaydb.core.Flyway
import org.slf4j.LoggerFactory
import kotlin.time.ExperimentalTime
import kotlin.time.measureTime

class FlywayDatabaseAdapter(
config: Config,
private val slackNotifier: SlackNotifier? = null
private val slackNotifier: SlackNotifier? = null,
) : DatabaseAdapter(config) {

data class Config(
Expand All @@ -23,12 +23,12 @@ class FlywayDatabaseAdapter(
override val password: Password,
override val maximumPoolSize: Int,
override val googleCloudSqlInstance: String? = null,
val migrationConfig: MigrationConfig = MigrationConfig()
val migrationConfig: MigrationConfig = MigrationConfig(),
) : DatabaseConfig

data class MigrationConfig(
val cleanDisabled: Boolean = true,
val strategy: InitializationStrategy = InitializationStrategy.Migrate
val strategy: InitializationStrategy = InitializationStrategy.Migrate,
)

enum class InitializationStrategy {
Expand All @@ -49,8 +49,8 @@ class FlywayDatabaseAdapter(
.configuration(
mapOf(
// Disable transactional locks in order to support concurrent indexes
"flyway.postgresql.transactional.lock" to "false"
)
"flyway.postgresql.transactional.lock" to "false",
),
)
.dataSource(config.jdbcUrl, config.user, config.password.value)
.apply {
Expand Down Expand Up @@ -94,9 +94,14 @@ class FlywayDatabaseAdapter(
val time = measureTime {
run()
}
logger.info("Flyway task finished in ${time}ms")
logger.info("Flyway task finished in $time")
} catch (e: Throwable) {
slackNotifier?.sendMessage("Async Flyway-migrering feilet. Sjekk med utviklerne på teamet om noen kjører en stor async migrering.")
slackNotifier?.sendMessage(
"""
Async Flyway-migrering feilet.
Sjekk med utviklerne på teamet om noen kjører en stor async migrering.
""".trimIndent(),
)
logger.warn("Flyway task was cancelled with exception", e)
throw e
}
Expand Down
6 changes: 0 additions & 6 deletions common/domain/.gitattributes

This file was deleted.

5 changes: 0 additions & 5 deletions common/domain/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ enum class Avslutningsstatus {
AVLYST,
AVBRUTT,
AVSLUTTET,
IKKE_AVSLUTTET;
IKKE_AVSLUTTET,
;

companion object {
fun fromArenastatus(arenaStatus: String): Avslutningsstatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sealed class TiltakshistorikkDbo {
@Serializable(with = LocalDateTimeSerializer::class)
override val tilDato: LocalDateTime? = null,
@Serializable(with = UUIDSerializer::class)
val tiltaksgjennomforingId: UUID
val tiltaksgjennomforingId: UUID,
) : TiltakshistorikkDbo()

@Serializable
Expand All @@ -48,6 +48,6 @@ sealed class TiltakshistorikkDbo {
val beskrivelse: String,
@Serializable(with = UUIDSerializer::class)
val tiltakstypeId: UUID,
val virksomhetsnummer: String
val virksomhetsnummer: String,
) : TiltakshistorikkDbo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ data class TiltakstypeDbo(
val fraDato: LocalDate,
@Serializable(with = LocalDateSerializer::class)
val tilDato: LocalDate,
val rettPaaTiltakspenger: Boolean
val rettPaaTiltakspenger: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import kotlinx.serialization.Serializable

@Serializable
data class ArenaTiltaksgjennomforingsstatusDto(
val status: String
val status: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class AvtaleAdminDto(
@Serializable
data class NavEnhet(
val enhetsnummer: String,
val navn: String? = null
val navn: String? = null,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ enum class Avtalestatus {
Planlagt,
Aktiv,
Avsluttet,
Avbrutt;
Avbrutt,
;

companion object {
fun resolveFromDatesAndAvslutningsstatus(
now: LocalDate,
startDato: LocalDate,
sluttDato: LocalDate,
avslutningsstatus: Avslutningsstatus
avslutningsstatus: Avslutningsstatus,
): Avtalestatus = when {
avslutningsstatus == Avslutningsstatus.AVBRUTT -> Avbrutt
avslutningsstatus == Avslutningsstatus.AVSLUTTET -> Avsluttet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import java.util.*
@Serializable
data class ExchangeArenaIdForIdResponse(
@Serializable(with = UUIDSerializer::class)
val id: UUID
val id: UUID,
)

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ data class TiltaksgjennomforingAdminDto(
@Serializable(with = UUIDSerializer::class)
val id: UUID,
val navn: String,
val arenaKode: String
val arenaKode: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ data class TiltaksgjennomforingDto(
@Serializable(with = LocalDateSerializer::class)
val sluttDato: LocalDate? = null,
val status: Tiltaksgjennomforingsstatus,
val virksomhetsnummer: String
val virksomhetsnummer: String,
) {
@Serializable
data class Tiltakstype(
@Serializable(with = UUIDSerializer::class)
val id: UUID,
val navn: String,
val arenaKode: String
val arenaKode: String,
)

companion object {
Expand All @@ -40,7 +40,7 @@ data class TiltaksgjennomforingDto(
startDato = tiltaksgjennomforing.startDato,
sluttDato = tiltaksgjennomforing.sluttDato,
status = tiltaksgjennomforing.status,
virksomhetsnummer = tiltaksgjennomforing.virksomhetsnummer
virksomhetsnummer = tiltaksgjennomforing.virksomhetsnummer,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data class TiltaksgjennomforingsArenadataDto(
val lopenr: Int?,
val virksomhetsnummer: String?,
val ansvarligNavEnhetId: String?,
val status: String
val status: String,
) {
companion object {
fun from(tiltaksgjennomforing: TiltaksgjennomforingAdminDto, status: String) = tiltaksgjennomforing.run {
Expand All @@ -17,7 +17,7 @@ data class TiltaksgjennomforingsArenadataDto(
lopenr = tiltaksnummer?.split("#")?.get(1)?.toInt(),
virksomhetsnummer = virksomhetsnummer,
ansvarligNavEnhetId = arenaAnsvarligEnhet,
status = status
status = status,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ enum class Tiltaksgjennomforingsstatus {
AVBRUTT,
AVLYST,
AVSLUTTET,
APENT_FOR_INNSOK;
APENT_FOR_INNSOK,
;

companion object {
fun fromDbo(
dagensDato: LocalDate,
startDato: LocalDate,
sluttDato: LocalDate?,
avslutningsStatus: Avslutningsstatus
avslutningsStatus: Avslutningsstatus,
): Tiltaksgjennomforingsstatus {
return when {
avslutningsStatus == Avslutningsstatus.AVLYST -> AVLYST
Expand All @@ -30,4 +31,3 @@ enum class Tiltaksgjennomforingsstatus {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class TiltakstypeDto(
@Serializable(with = LocalDateSerializer::class)
val tilDato: LocalDate,
val rettPaaTiltakspenger: Boolean,
val status: Tiltakstypestatus
val status: Tiltakstypestatus,
) {
companion object {
fun from(tiltakstype: TiltakstypeDbo) = tiltakstype.run {
Expand All @@ -37,10 +37,8 @@ data class TiltakstypeDto(
fraDato = fraDato,
tilDato = tilDato,
rettPaaTiltakspenger = rettPaaTiltakspenger,
status = Tiltakstypestatus.resolveFromDates(LocalDate.now(), fraDato, tilDato)
status = Tiltakstypestatus.resolveFromDates(LocalDate.now(), fraDato, tilDato),
)
}
}
}


5 changes: 0 additions & 5 deletions common/kafka/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ktlint)
}

ktlint {
disabledRules.addAll("no-wildcard-imports")
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class KafkaConsumerRepository(private val db: Database) : KafkaConsumerRepositor
record.key,
record.value,
record.headersJson,
record.timestamp
record.timestamp,
).asUpdate
return db.run(queryResult).toLong()
}
Expand Down Expand Up @@ -101,7 +101,7 @@ class KafkaConsumerRepository(private val db: Database) : KafkaConsumerRepositor
row.stringOrNull("headers_json"),
row.int("retries"),
row.sqlTimestampOrNull("last_retry"),
row.long("record_timestamp")
row.long("record_timestamp"),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package no.nav.mulighetsrommet.kafka

import kotlinx.coroutines.runBlocking
import no.nav.common.kafka.consumer.util.KafkaConsumerClientBuilder
import no.nav.common.kafka.consumer.util.KafkaConsumerClientBuilder.TopicConfig
import org.apache.kafka.common.serialization.Deserializer
import java.util.function.Consumer

abstract class KafkaTopicConsumer<K, V>(
val config: Config,
private val keyDeserializer: Deserializer<K>,
private val valueDeserializer: Deserializer<V>
private val valueDeserializer: Deserializer<V>,
) {

data class Config(
Expand All @@ -17,8 +17,8 @@ abstract class KafkaTopicConsumer<K, V>(
val initialRunningState: Boolean = false,
)

internal fun toTopicConfig(kafkaConsumerRepository: KafkaConsumerRepository): KafkaConsumerClientBuilder.TopicConfig<K, V> {
return KafkaConsumerClientBuilder.TopicConfig<K, V>()
internal fun toTopicConfig(kafkaConsumerRepository: KafkaConsumerRepository): TopicConfig<K, V> {
return TopicConfig<K, V>()
.withLogging()
.withStoreOnFailure(kafkaConsumerRepository)
.withConsumerConfig(
Expand All @@ -29,7 +29,7 @@ abstract class KafkaTopicConsumer<K, V>(
runBlocking {
consume(event.key(), event.value())
}
}
},
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ data class Topic(
val id: String,
val topic: String,
val type: TopicType,
val running: Boolean
val running: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ class TopicRepository(private val db: Database) {
id = string("id"),
topic = string("topic"),
type = TopicType.valueOf(string("type")),
running = boolean("running")
running = boolean("running"),
)
}
Loading

0 comments on commit 9d16a4b

Please # to comment.