Skip to content

Commit

Permalink
Bump org.jlleitschuh.gradle.ktlint from 11.0.0 to 11.5.0 (#806)
Browse files Browse the repository at this point in the history
Bumps org.jlleitschuh.gradle.ktlint from 11.0.0 to 11.5.0.
Also runs ktlint formatting to fix the formatting errors preventing the CI to pass with the new version.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle.ktlint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: violine1101 <[email protected]>
  • Loading branch information
dependabot[bot] and violine1101 authored Jul 15, 2023
1 parent 693484a commit 31b889b
Show file tree
Hide file tree
Showing 21 changed files with 155 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[*.{kt, kts}]
disabled_rules = import-ordering
ktlint_disabled_rules = import-ordering
continuation_indent_size=4
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.8.21"
id("org.jlleitschuh.gradle.ktlint") version "11.0.0"
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
application
id("io.gitlab.arturbosch.detekt") version "1.23.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ private fun JiraClient.getCurrentUser(): User {
) {}
}

@Suppress("ForbiddenComment")
/**
* Get a list of tickets matching a JQL query.
* TODO: Actually return the tickets themselves instead of only ticket IDs.
Expand All @@ -69,6 +68,7 @@ private fun JiraClient.getCurrentUser(): User {
*
* @return a list of strings indicating ticket IDs that are contained in the given jql filter.
*/
@Suppress("ForbiddenComment")
fun getIssuesFromJql(jiraClient: JiraClient, jql: String, amount: Int) = runBlocking {
Either.catch {
val searchResult = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,23 +136,32 @@ fun JiraIssue.toDomain(
createComment(
context,
HelperMessageService.getMessageWithBotSignature(
project.key, messageKey, variable, language
project.key,
messageKey,
variable,
language
)
)
},
addDupeMessage = { (messageKey, variable, language) ->
createComment(
context,
HelperMessageService.getMessageWithDupeBotSignature(
project.key, messageKey, variable, language
project.key,
messageKey,
variable,
language
)
)
},
addRestrictedComment = { (messageKey, variable, language) ->
addRestrictedComment(
context,
HelperMessageService.getMessageWithBotSignature(
project.key, messageKey, variable, language
project.key,
messageKey,
variable,
language
),
"helper"
)
Expand All @@ -161,7 +170,9 @@ fun JiraIssue.toDomain(
createComment(
context,
HelperMessageService.getMessageWithBotSignature(
project.key, config[Arisa.Modules.Language.message], lang = language
project.key,
config[Arisa.Modules.Language.message],
lang = language
)
)
},
Expand Down Expand Up @@ -222,7 +233,8 @@ fun JiraComment.toDomain(
}

fun JiraUser.toDomain(jiraClient: JiraClient, config: Config) = User(
name, displayName,
name,
displayName,
::getUserGroups.partially1(jiraClient).partially1(name),
::isNewUser.partially1(jiraClient).partially1(name)
) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/io/github/mojira/arisa/modules/CrashModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ class CrashModule(
}

private fun assertNoValidCrash(crashes: List<AttachmentUtils.CrashAttachment>) =
if (crashes.all { isModded(it.crash) || getDuplicateLink(it.crash) != null })
if (crashes.all { isModded(it.crash) || getDuplicateLink(it.crash) != null }) {
Unit.right()
else
} else {
OperationNotNeededModuleResponse.left()
}
}
12 changes: 8 additions & 4 deletions src/main/kotlin/io/github/mojira/arisa/modules/Helpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ fun assertAfter(instant1: Instant, instant2: Instant) = if (instant1.isAfter(ins
}

fun String?.getOrDefault(default: String) =
if (isNullOrBlank())
if (isNullOrBlank()) {
default
else
} else {
this
}

fun String?.getOrDefaultNull(default: String) =
this ?: default
Expand Down Expand Up @@ -232,8 +233,11 @@ fun MutableList<String>.concatLinkName() {
return
}
val linkName = linkNameList.joinToString(separator = " ")
val newList = if (linkName.isEmpty()) this.toMutableList()
else this.drop(linkName.count { it == ' ' } + 1).toMutableList()
val newList = if (linkName.isEmpty()) {
this.toMutableList()
} else {
this.drop(linkName.count { it == ' ' } + 1).toMutableList()
}
newList.add(0, linkName)
this.clear()
this.addAll(newList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@ class KeepPlatformModule(
}

private fun Issue.getPlatformValue() =
if (project.key == "MCD") dungeonsPlatform
else if (project.key == "MCLG") legendsPlatform
else platform
if (project.key == "MCD") {
dungeonsPlatform
} else if (project.key == "MCLG") {
legendsPlatform
} else {
platform
}

private fun isPlatformChange(project: String, item: ChangeLogItem) =
item.field == (
if (project == "MCD") "Dungeons Platform"
else if (project == "MCLG") "Legends Platform"
else "Platform"
if (project == "MCD") {
"Dungeons Platform"
} else if (project == "MCLG") {
"Legends Platform"
} else {
"Platform"
}
)

private fun changedByVolunteer(item: ChangeLogItem) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ class KeepPrivateModule(
}

private fun assertIsPublic(securityLevel: String?, privateLevel: String) =
if (securityLevel == privateLevel)
if (securityLevel == privateLevel) {
OperationNotNeededModuleResponse.left()
else
} else {
Unit.right()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ class LanguageModule(
}

private fun assertIsPublic(securityLevel: String?, privateLevel: String) =
if (securityLevel == privateLevel)
if (securityLevel == privateLevel) {
OperationNotNeededModuleResponse.left()
else
} else {
Unit.right()
}

private fun assertLanguageIsNotAllowed(allowedLanguages: List<String>, language: String) = when {
allowedLanguages.any { language == it } -> OperationNotNeededModuleResponse.left()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ class MultiplePlatformsModule(
}

private fun getPlatformWhitelist(project: String) =
if (project == "MCD") dungeonsPlatformWhitelist
else if (project == "MCLG") legendsPlatformWhitelist
else platformWhitelist
if (project == "MCD") {
dungeonsPlatformWhitelist
} else if (project == "MCLG") {
legendsPlatformWhitelist
} else {
platformWhitelist
}

private fun Issue.getPlatformValue() =
if (project.key == "MCD") dungeonsPlatform
else if (project.key == "MCLG") legendsPlatform
else platform
if (project.key == "MCD") {
dungeonsPlatform
} else if (project.key == "MCLG") {
legendsPlatform
} else {
platform
}

private fun isDuplicatedWithDifferentPlatforms(
platform: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ class PrivateDuplicateModule(
private fun isDuplicatesLink(link: Link): Boolean = link.type == "Duplicate" && link.outwards

private fun assertIsPublic(securityLevel: String?, privateLevel: String) =
if (securityLevel == privateLevel)
if (securityLevel == privateLevel) {
OperationNotNeededModuleResponse.left()
else
} else {
Unit.right()
}

private fun assertParentPrivate(securityLevel: String?, privateLevel: String) =
if (securityLevel == privateLevel)
if (securityLevel == privateLevel) {
Unit.right()
else
} else {
OperationNotNeededModuleResponse.left()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class RemoveBotCommentModule(

override fun invoke(issue: Issue, lastRun: Instant): Either<ModuleError, ModuleResponse> = with(issue) {
Either.fx {

// Only consider new comments
val newComments = comments.filter {
it.updated.isAfter(lastRun)
Expand Down
16 changes: 10 additions & 6 deletions src/main/kotlin/io/github/mojira/arisa/modules/RemoveSpamModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ class RemoveSpamModule(private val patternConfigs: List<SpamPatternConfig>) : Mo
private fun checkIssue(issue: Issue, lastRun: Instant): List<() -> Unit> {
val shouldTakeAction = isBugreportNew(issue, lastRun) && isBugreportSpam(issue)

return if (shouldTakeAction)
return if (shouldTakeAction) {
listOf {
issue.putInSpamBin()
}
else
} else {
emptyList()
}
}

private fun isBugreportNew(issue: Issue, lastRun: Instant) =
Expand All @@ -71,10 +72,13 @@ class RemoveSpamModule(private val patternConfigs: List<SpamPatternConfig>) : Mo
val groups = reporter.getGroups() ?: listOf()
val userIsVolunteer = groups.any { listOf("helper", "global-moderators", "staff").contains(it) }

return if (userIsVolunteer) false
else isTextSpam(issue.summary ?: "") ||
isTextSpam(issue.description ?: "") ||
isTextSpam(issue.environment ?: "")
return if (userIsVolunteer) {
false
} else {
isTextSpam(issue.summary ?: "") ||
isTextSpam(issue.description ?: "") ||
isTextSpam(issue.environment ?: "")
}
}

private fun Issue.putInSpamBin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ class ReopenAwaitingModule(
(
comment.body?.contains(
HelperMessageService.getMessageWithBotSignature(
project.key, message, null, "en"
project.key,
message,
null,
"en"
)
) ?: false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ abstract class ModuleRegistry(protected val config: Config) {

val debugWhitelist = config[Arisa.Debug.ticketWhitelist]

return if (debugWhitelist == null) registryJql
else "key IN (${debugWhitelist.joinToString()}) AND ($registryJql)"
return if (debugWhitelist == null) {
registryJql
} else {
"key IN (${debugWhitelist.joinToString()}) AND ($registryJql)"
}
}

fun getFullJql(timeframe: ExecutionTimeframe, failedTickets: Collection<String>): String {
Expand Down
17 changes: 12 additions & 5 deletions src/test/kotlin/io/github/mojira/arisa/LastRunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class LastRunTest : StringSpec({
{"user": "Monty Python", "since": "3000000", "until": "4000000"},
{"user": "Nigerian Prince", "since": "5000000", "until": "6000000"}
]
}""".trimMargin()
}
""".trimMargin()
}

lastRun.time shouldBe time
Expand Down Expand Up @@ -154,7 +155,8 @@ class LastRunTest : StringSpec({
val lastRun = LastRun(
{
LastRunFile(
time, emptySet(),
time,
emptySet(),
listOf(
Shadowban(
user = "Spammer Mc Spamface",
Expand Down Expand Up @@ -199,7 +201,8 @@ class LastRunTest : StringSpec({
val lastRun = LastRun(
{
LastRunFile(
time, emptySet(),
time,
emptySet(),
listOf(
Shadowban(
user = "Spammer Mc Spamface",
Expand Down Expand Up @@ -246,11 +249,15 @@ class LastRunTest : StringSpec({

"legacy last-run file upgrade should work properly" {
LastRunFileService.convertLegacyFile("123456789,MC-1234,WEB-234") shouldBe LastRunFile(
Instant.ofEpochMilli(123456789), setOf("MC-1234", "WEB-234"), emptyList()
Instant.ofEpochMilli(123456789),
setOf("MC-1234", "WEB-234"),
emptyList()
)

LastRunFileService.convertLegacyFile("123456789") shouldBe LastRunFile(
Instant.ofEpochMilli(123456789), emptySet(), emptyList()
Instant.ofEpochMilli(123456789),
emptySet(),
emptyList()
)

val now = Instant.now()
Expand Down
Loading

0 comments on commit 31b889b

Please sign in to comment.