Skip to content

Commit

Permalink
Merge pull request #262 from hossain-khan/renovate/org.jmailen.kotlin…
Browse files Browse the repository at this point in the history
…ter-3.x

Update plugin org.jmailen.kotlinter to v3.16.0
  • Loading branch information
hossain-khan authored Jan 2, 2024
2 parents bf68171 + 00eb481 commit 7f22cf7
Show file tree
Hide file tree
Showing 47 changed files with 161 additions and 153 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
// For build.gradle.kts (Kotlin DSL)
// https://kotlinlang.org/docs/releases.html#release-details
kotlin("jvm") version "1.9.22"
id("org.jmailen.kotlinter") version "3.12.0"
id("org.jmailen.kotlinter") version "3.16.0"
// https://kotlinlang.org/docs/ksp-quickstart.html#use-your-own-processor-in-a-project
// id("com.google.devtools.ksp") version "1.9.20-1.0.6" // Not needed yet.
application
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/PrStatsApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PrStatsApplication : KoinComponent {
pullRequestStatsRepo.stats(
repoOwner = repoOwner,
repoId = repoId,
prNumber = prNumber
prNumber = prNumber,
)
} catch (e: Exception) {
val error = errorProcessor.getDetailedError(e)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/StatsGeneratorApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StatsGeneratorApplication(
* Get all the available stats formatters - such as ASCII table, CSV writer and so on.
* @see StatsFormatter
*/
private val formatters: List<StatsFormatter>
private val formatters: List<StatsFormatter>,
) : KoinComponent {

/**
Expand Down
22 changes: 11 additions & 11 deletions src/main/kotlin/dev/hossain/githubstats/PrAuthorStatsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PrAuthorStatsService constructor(
private val pullRequestStatsRepo: PullRequestStatsRepo,
private val issueSearchPager: IssueSearchPagerService,
private val appConfig: AppConfig,
private val errorProcessor: ErrorProcessor
private val errorProcessor: ErrorProcessor,
) {

/**
Expand All @@ -39,7 +39,7 @@ class PrAuthorStatsService constructor(
* ```
*/
suspend fun authorStats(
prAuthorUserId: String
prAuthorUserId: String,
): AuthorStats {
val (repoOwner, repoId, _, dateLimitAfter, dateLimitBefore) = appConfig.get()

Expand All @@ -50,8 +50,8 @@ class PrAuthorStatsService constructor(
repoId = repoId,
author = prAuthorUserId,
dateAfter = dateLimitAfter,
dateBefore = dateLimitBefore
).toQuery()
dateBefore = dateLimitBefore,
).toQuery(),
).filter {
// Makes sure it is a PR, not an issue
it.pull_request != null
Expand All @@ -72,7 +72,7 @@ class PrAuthorStatsService constructor(
pullRequestStatsRepo.stats(
repoOwner = repoOwner,
repoId = repoId,
prNumber = pr.number
prNumber = pr.number,
)
} catch (e: Exception) {
val error = errorProcessor.getDetailedError(e)
Expand All @@ -90,7 +90,7 @@ class PrAuthorStatsService constructor(
val authorPrStats = aggregatePrAuthorsPrStats(prAuthorUserId, allMergedPrsByAuthor, mergedPrsStatsList)
Log.i(
"ℹ️ The author '$prAuthorUserId' has created ${authorPrStats.totalPrsCreated} PRs that successfully got merged." +
"\nTotal Comments Received - Code Review: ${authorPrStats.totalCodeReviewComments}, PR Comment: ${authorPrStats.totalIssueComments}, Review+Re-review: ${authorPrStats.totalPrSubmissionComments}"
"\nTotal Comments Received - Code Review: ${authorPrStats.totalCodeReviewComments}, PR Comment: ${authorPrStats.totalIssueComments}, Review+Re-review: ${authorPrStats.totalPrSubmissionComments}",
)

val authorReviewStats: List<AuthorReviewStats> =
Expand All @@ -103,7 +103,7 @@ class PrAuthorStatsService constructor(
private fun aggregatePrAuthorReviewStats(
mergedPrsStatsList: List<PrStats>,
repoId: String,
prAuthorUsedId: String
prAuthorUsedId: String,
): List<AuthorReviewStats> {
// Builds a map of reviewer ID to list PRs they have reviewed for the PR-Author
val userReviews = mutableMapOf<UserId, List<ReviewStats>>()
Expand All @@ -117,7 +117,7 @@ class PrAuthorStatsService constructor(
initialResponseTime = stats.initialResponseTime[userId] ?: time,
prComments = stats.comments[userId] ?: noComments(userId),
prReadyOn = stats.prReadyOn,
prMergedOn = stats.prMergedOn
prMergedOn = stats.prMergedOn,
)
if (userReviews.containsKey(userId)) {
userReviews[userId] = userReviews[userId]!!.plus(reviewStats)
Expand All @@ -142,7 +142,7 @@ class PrAuthorStatsService constructor(
average = averageReviewTime,
totalReviews = totalReviews,
totalComments = totalReviewComments,
stats = reviewStats
stats = reviewStats,
)
}.sortedByDescending { it.totalReviews }

Expand All @@ -160,7 +160,7 @@ class PrAuthorStatsService constructor(
private fun aggregatePrAuthorsPrStats(
prAuthorUserId: String,
allMergedPrsByAuthor: List<Issue>,
mergedPrsStatsList: List<PrStats>
mergedPrsStatsList: List<PrStats>,
): AuthorPrStats {
// Builds author's stats for all PRs made by the author
val totalPrsCreated = allMergedPrsByAuthor.size
Expand All @@ -185,7 +185,7 @@ class PrAuthorStatsService constructor(
totalPrsCreated = totalPrsCreated,
totalIssueComments = totalIssueComments,
totalPrSubmissionComments = totalPrSubmissionComments,
totalCodeReviewComments = totalCodeReviewComments
totalCodeReviewComments = totalCodeReviewComments,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class PrReviewerStatsService constructor(
private val pullRequestStatsRepo: PullRequestStatsRepo,
private val issueSearchPager: IssueSearchPagerService,
private val appConfig: AppConfig,
private val errorProcessor: ErrorProcessor
private val errorProcessor: ErrorProcessor,
) {
suspend fun reviewerStats(
prReviewerUserId: String
prReviewerUserId: String,
): ReviewerReviewStats {
val (repoOwner, repoId, _, dateLimitAfter, dateLimitBefore) = appConfig.get()

Expand All @@ -36,8 +36,8 @@ class PrReviewerStatsService constructor(
repoId = repoId,
reviewer = prReviewerUserId,
dateAfter = dateLimitAfter,
dateBefore = dateLimitBefore
).toQuery()
dateBefore = dateLimitBefore,
).toQuery(),
).filter {
// Makes sure it is a PR, not an issue
it.pull_request != null
Expand All @@ -58,7 +58,7 @@ class PrReviewerStatsService constructor(
pullRequestStatsRepo.stats(
repoOwner = repoOwner,
repoId = repoId,
prNumber = pr.number
prNumber = pr.number,
)
} catch (e: Exception) {
val error = errorProcessor.getDetailedError(e)
Expand Down Expand Up @@ -88,7 +88,7 @@ class PrReviewerStatsService constructor(
initialResponseTime = stats.initialResponseTime[prReviewerUserId] ?: prApprovalTime,
prComments = stats.comments[prReviewerUserId] ?: noComments(prReviewerUserId),
prReadyOn = stats.prReadyOn,
prMergedOn = stats.prMergedOn
prMergedOn = stats.prMergedOn,
)
}

Expand Down Expand Up @@ -126,7 +126,7 @@ class PrReviewerStatsService constructor(
},
totalReviews = reviewerPrReviewStatsList.size,
reviewedPrStats = reviewerPrReviewStatsList,
reviewedForPrStats = reviewerReviewedFor
reviewedForPrStats = reviewerReviewedFor,
)
}
}
16 changes: 8 additions & 8 deletions src/main/kotlin/dev/hossain/githubstats/ReviewStats.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ data class PrStats(
/**
* Date and time when the PR was merged successfully.
*/
val prMergedOn: Instant
val prMergedOn: Instant,
)

/**
Expand Down Expand Up @@ -86,15 +86,15 @@ data class ReviewStats constructor(
/**
* Date and time when the PR was merged successfully.
*/
val prMergedOn: Instant
val prMergedOn: Instant,
)

/**
* Class containing different type of stats for PR Author.
*/
data class AuthorStats(
val prStats: AuthorPrStats,
val reviewStats: List<AuthorReviewStats>
val reviewStats: List<AuthorReviewStats>,
)

/**
Expand All @@ -114,7 +114,7 @@ data class AuthorReviewStats(
val average: Duration,
val totalReviews: Int,
val totalComments: Int,
val stats: List<ReviewStats>
val stats: List<ReviewStats>,
)

/**
Expand All @@ -128,7 +128,7 @@ data class AuthorPrStats(
val totalPrsCreated: Int,
val totalIssueComments: Int,
val totalPrSubmissionComments: Int,
val totalCodeReviewComments: Int
val totalCodeReviewComments: Int,
) {
/**
* Checks if stats is empty, then it's likely not worth showing.
Expand Down Expand Up @@ -187,7 +187,7 @@ data class ReviewerReviewStats(
* - john -> [PR#112 Stats, PR#931 Stats] (Meaning: The reviewer has reviewed 2 PRs created by `john`)
* - kirk -> [PR#341 Stats, PR#611 Stats, PR#839 Stats] (Meaning: The reviewer has reviewed 3 PRs created by `kirk`)
*/
val reviewedForPrStats: Map<UserId, List<PrStats>>
val reviewedForPrStats: Map<UserId, List<PrStats>>,
)

/**
Expand All @@ -213,7 +213,7 @@ data class UserPrComment(
* Total PR review comment that either is [ReviewState.COMMENTED] or [ReviewState.CHANGE_REQUESTED] which
* is used when reviewer submits a review after reviewing the PR.
*/
val prReviewSubmissionComment: Int
val prReviewSubmissionComment: Int,
) {
companion object {
/**
Expand All @@ -223,7 +223,7 @@ data class UserPrComment(
user = userId,
issueComment = 0,
codeReviewComment = 0,
prReviewSubmissionComment = 0
prReviewSubmissionComment = 0,
)
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/dev/hossain/githubstats/di/Koin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,35 @@ val appModule = module {
PullRequestStatsRepoImpl(
githubApiService = get(),
timelinesPager = get(),
userTimeZone = get()
userTimeZone = get(),
)
}
factory {
IssueSearchPagerService(
githubApiService = get(),
errorProcessor = get()
errorProcessor = get(),
)
}
factory {
TimelineEventsPagerService(
githubApiService = get(),
errorProcessor = get()
errorProcessor = get(),
)
}
factory {
PrReviewerStatsService(
pullRequestStatsRepo = get(),
issueSearchPager = get(),
appConfig = get(),
errorProcessor = get()
errorProcessor = get(),
)
}
factory {
PrAuthorStatsService(
pullRequestStatsRepo = get(),
issueSearchPager = get(),
appConfig = get(),
errorProcessor = get()
errorProcessor = get(),
)
}
single { ErrorProcessor() }
Expand All @@ -80,7 +80,7 @@ val appModule = module {
prAuthorStatsService = get(),
resources = get(),
appConfig = get(),
formatters = getAll()
formatters = getAll(),
)
}

Expand Down
Loading

0 comments on commit 7f22cf7

Please sign in to comment.