From c26a34bea967c38bb0a305a8e328db6348d63cd0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 03:32:29 +0000 Subject: [PATCH] Update plugin com.diffplug.spotless to v6.22.0 --- build.gradle.kts | 2 +- src/main/kotlin/pullpitok/App.kt | 22 +++++++++++-------- src/main/kotlin/pullpitok/github/Event.kt | 5 ++++- .../kotlin/pullpitok/github/EventClient.kt | 16 +++++++++----- src/test/kotlin/pullpitok/AppTest.kt | 1 - .../kotlin/pullpitok/github/EventClientIT.kt | 6 ++--- .../pullpitok/github/EventClientTest.kt | 1 - 7 files changed, 31 insertions(+), 22 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4dc5348..f0b4fe7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { id("se.patrikerdes.use-latest-versions") version "0.2.18" id("com.github.ben-manes.versions") version "0.48.0" id("com.adarshr.test-logger") version "3.2.0" - id("com.diffplug.spotless") version "6.19.0" + id("com.diffplug.spotless") version "6.22.0" application } diff --git a/src/main/kotlin/pullpitok/App.kt b/src/main/kotlin/pullpitok/App.kt index 45ef8f0..7710529 100644 --- a/src/main/kotlin/pullpitok/App.kt +++ b/src/main/kotlin/pullpitok/App.kt @@ -18,10 +18,12 @@ fun main(args: Array) { .forEach { displayEvents(it, token) } } -internal fun invalidArguments(args: Array): Boolean = - args.size !in (1..2) || args[0] in setOf("", "-h", "--help") +internal fun invalidArguments(args: Array): Boolean = args.size !in (1..2) || args[0] in setOf("", "-h", "--help") -private fun displayEvents(repo: String, token: String?) { +private fun displayEvents( + repo: String, + token: String?, +) { val allEvents = mutableListOf() for (pageNumber in 1..10) { val events = EventClient("https", "api.github.com").githubEvents(repo, token, page = pageNumber) @@ -44,9 +46,10 @@ private fun displayEvents(repo: String, token: String?) { ) } -private fun perAuthor(events: List): Map> = events - .filter { it.type in Type.values().map(Type::name) } - .groupBy { it.actor.login } +private fun perAuthor(events: List): Map> = + events + .filter { it.type in Type.values().map(Type::name) } + .groupBy { it.actor.login } internal fun counters( eventsPerAuthor: Map>, @@ -56,9 +59,10 @@ internal fun counters( var counters = "" for (events in eventsPerAuthor.entries) { val author = events.key - val count = events.value - .filter(predicate) - .count() + val count = + events.value + .filter(predicate) + .count() if (count > 0) { counters += "\n\t\t$author: $count" } diff --git a/src/main/kotlin/pullpitok/github/Event.kt b/src/main/kotlin/pullpitok/github/Event.kt index 87c7e89..96c288c 100644 --- a/src/main/kotlin/pullpitok/github/Event.kt +++ b/src/main/kotlin/pullpitok/github/Event.kt @@ -1,15 +1,18 @@ package pullpitok.github data class Actor(val login: String) + data class Payload(val action: String) + data class Event(val id: String, val type: String, val actor: Actor, val payload: Payload) -@Suppress("ktlint:enum-entry-name-case") +@Suppress("ktlint:standard:enum-entry-name-case") enum class Action { created, closed, opened, } + enum class Type { PullRequestEvent, PullRequestReviewCommentEvent, diff --git a/src/main/kotlin/pullpitok/github/EventClient.kt b/src/main/kotlin/pullpitok/github/EventClient.kt index 95d296d..0f2471d 100644 --- a/src/main/kotlin/pullpitok/github/EventClient.kt +++ b/src/main/kotlin/pullpitok/github/EventClient.kt @@ -8,15 +8,19 @@ import java.net.http.HttpResponse.BodyHandlers import java.time.Duration class EventClient(private val protocol: String, private val hostname: String) { - private val client = HttpClient.newBuilder().build() - fun githubEvents(repo: String, token: String?, page: Int): List { + fun githubEvents( + repo: String, + token: String?, + page: Int, + ): List { val url = "$protocol://$hostname/repos/$repo/events?page=$page" - val request = HttpRequest.newBuilder() - .timeout(Duration.ofSeconds(30)) - .header("Content-Type", "application/json") - .uri(URI.create(url)) + val request = + HttpRequest.newBuilder() + .timeout(Duration.ofSeconds(30)) + .header("Content-Type", "application/json") + .uri(URI.create(url)) if (token != null) { request.header("Authorization", "token $token") } diff --git a/src/test/kotlin/pullpitok/AppTest.kt b/src/test/kotlin/pullpitok/AppTest.kt index d2b124c..8d36a34 100644 --- a/src/test/kotlin/pullpitok/AppTest.kt +++ b/src/test/kotlin/pullpitok/AppTest.kt @@ -9,7 +9,6 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue class AppTest { - @Test fun `no counters`() { assertEquals( diff --git a/src/test/kotlin/pullpitok/github/EventClientIT.kt b/src/test/kotlin/pullpitok/github/EventClientIT.kt index 57f4239..bc5f496 100644 --- a/src/test/kotlin/pullpitok/github/EventClientIT.kt +++ b/src/test/kotlin/pullpitok/github/EventClientIT.kt @@ -10,7 +10,6 @@ import org.junit.Test import kotlin.test.assertEquals class EventClientIT { - @JvmField @Rule var wiremock = WireMockRule() @@ -31,8 +30,9 @@ class EventClientIT { ), ), ) - val events = EventClient("http", "localhost:${wiremock.port()}") - .githubEvents(repo, "1234", page) + val events = + EventClient("http", "localhost:${wiremock.port()}") + .githubEvents(repo, "1234", page) assertEquals( events .filter { it.type == Type.PullRequestEvent.name } diff --git a/src/test/kotlin/pullpitok/github/EventClientTest.kt b/src/test/kotlin/pullpitok/github/EventClientTest.kt index c583cc6..6896170 100644 --- a/src/test/kotlin/pullpitok/github/EventClientTest.kt +++ b/src/test/kotlin/pullpitok/github/EventClientTest.kt @@ -4,7 +4,6 @@ import org.junit.Test import kotlin.test.assertEquals class EventClientTest { - private val eventClient = EventClient("http", "anyHost") @Test