Update scalafmt setting

use new syntax. prepare Scala 3.4
This commit is contained in:
xuwei-k
2023-12-30 08:05:04 +09:00
committed by kenji yoshida
parent 5d495cfa12
commit d73eacfa5d
12 changed files with 52 additions and 42 deletions

View File

@@ -12,3 +12,13 @@ continuationIndent.defnSite = 2
danglingParentheses.preset = true danglingParentheses.preset = true
runner.dialect = scala213source3 runner.dialect = scala213source3
rewrite.trailingCommas.style = keep rewrite.trailingCommas.style = keep
fileOverride {
"glob:**/*.sbt" {
runner.dialect = scala212
rewrite.scala3.convertToNewSyntax = false
}
}
rewrite.scala3.convertToNewSyntax = true
runner.dialectOverride.allowSignificantIndentation = false
runner.dialectOverride.allowAsForImportRename = false
runner.dialectOverride.allowStarWildcardImport = false

View File

@@ -112,13 +112,13 @@ trait DashboardControllerBase extends ControllerBase {
val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName) val condition = getOrCreateCondition(Keys.Session.DashboardIssues, filter, userName)
val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name) val userRepos = getUserRepositories(userName, true).map(repo => repo.owner -> repo.name)
val page = IssueSearchCondition.page(request) val page = IssueSearchCondition.page(request)
val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos: _*) val issues = searchIssue(condition, IssueSearchOption.Issues, (page - 1) * IssueLimit, IssueLimit, userRepos*)
html.issues( html.issues(
issues.map(issue => (issue, None)), issues.map(issue => (issue, None)),
page, page,
countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos: _*), countIssue(condition.copy(state = "open"), IssueSearchOption.Issues, userRepos*),
countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos: _*), countIssue(condition.copy(state = "closed"), IssueSearchOption.Issues, userRepos*),
filter match { filter match {
case "assigned" => condition.copy(assigned = Some(Some(userName))) case "assigned" => condition.copy(assigned = Some(Some(userName)))
case "mentioned" => condition.copy(mentioned = Some(userName)) case "mentioned" => condition.copy(mentioned = Some(userName))
@@ -149,7 +149,7 @@ trait DashboardControllerBase extends ControllerBase {
IssueSearchOption.PullRequests, IssueSearchOption.PullRequests,
(page - 1) * PullRequestLimit, (page - 1) * PullRequestLimit,
PullRequestLimit, PullRequestLimit,
allRepos: _* allRepos*
) )
val status = issues.map { issue => val status = issues.map { issue =>
issue.commitId.flatMap { commitId => issue.commitId.flatMap { commitId =>
@@ -160,8 +160,8 @@ trait DashboardControllerBase extends ControllerBase {
html.pulls( html.pulls(
issues.zip(status), issues.zip(status),
page, page,
countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos: _*), countIssue(condition.copy(state = "open"), IssueSearchOption.PullRequests, allRepos*),
countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos: _*), countIssue(condition.copy(state = "closed"), IssueSearchOption.PullRequests, allRepos*),
filter match { filter match {
case "assigned" => condition.copy(assigned = Some(Some(userName))) case "assigned" => condition.copy(assigned = Some(Some(userName)))
case "mentioned" => condition.copy(mentioned = Some(userName)) case "mentioned" => condition.copy(mentioned = Some(userName))

View File

@@ -549,7 +549,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
}) })
private def multiLineText(constraints: Constraint*): SingleValueType[Seq[String]] = private def multiLineText(constraints: Constraint*): SingleValueType[Seq[String]] =
new SingleValueType[Seq[String]](constraints: _*) { new SingleValueType[Seq[String]](constraints*) {
def convert(value: String, messages: Messages): Seq[String] = { def convert(value: String, messages: Messages): Seq[String] = {
if (value == null) { if (value == null) {
Nil Nil

View File

@@ -3,7 +3,7 @@ package gitbucket.core.model
protected[model] trait TemplateComponent { self: Profile => protected[model] trait TemplateComponent { self: Profile =>
import profile.api._ import profile.api._
trait BasicTemplate { self: Table[_] => trait BasicTemplate { self: Table[?] =>
val userName = column[String]("USER_NAME") val userName = column[String]("USER_NAME")
val repositoryName = column[String]("REPOSITORY_NAME") val repositoryName = column[String]("REPOSITORY_NAME")
@@ -18,7 +18,7 @@ protected[model] trait TemplateComponent { self: Profile =>
(this.userName === userName) && (this.repositoryName === repositoryName) (this.userName === userName) && (this.repositoryName === repositoryName)
} }
trait IssueTemplate extends BasicTemplate { self: Table[_] => trait IssueTemplate extends BasicTemplate { self: Table[?] =>
val issueId = column[Int]("ISSUE_ID") val issueId = column[Int]("ISSUE_ID")
def byIssue(owner: String, repository: String, issueId: Int) = def byIssue(owner: String, repository: String, issueId: Int) =
@@ -28,7 +28,7 @@ protected[model] trait TemplateComponent { self: Profile =>
byRepository(userName, repositoryName) && (this.issueId === issueId) byRepository(userName, repositoryName) && (this.issueId === issueId)
} }
trait LabelTemplate extends BasicTemplate { self: Table[_] => trait LabelTemplate extends BasicTemplate { self: Table[?] =>
val labelId = column[Int]("LABEL_ID") val labelId = column[Int]("LABEL_ID")
val labelName = column[String]("LABEL_NAME") val labelName = column[String]("LABEL_NAME")
@@ -42,7 +42,7 @@ protected[model] trait TemplateComponent { self: Profile =>
byRepository(owner, repository) && (this.labelName === labelName.bind) byRepository(owner, repository) && (this.labelName === labelName.bind)
} }
trait PriorityTemplate extends BasicTemplate { self: Table[_] => trait PriorityTemplate extends BasicTemplate { self: Table[?] =>
val priorityId = column[Int]("PRIORITY_ID") val priorityId = column[Int]("PRIORITY_ID")
val priorityName = column[String]("PRIORITY_NAME") val priorityName = column[String]("PRIORITY_NAME")
@@ -56,7 +56,7 @@ protected[model] trait TemplateComponent { self: Profile =>
byRepository(owner, repository) && (this.priorityName === priorityName.bind) byRepository(owner, repository) && (this.priorityName === priorityName.bind)
} }
trait MilestoneTemplate extends BasicTemplate { self: Table[_] => trait MilestoneTemplate extends BasicTemplate { self: Table[?] =>
val milestoneId = column[Int]("MILESTONE_ID") val milestoneId = column[Int]("MILESTONE_ID")
def byMilestone(owner: String, repository: String, milestoneId: Int) = def byMilestone(owner: String, repository: String, milestoneId: Int) =
@@ -66,7 +66,7 @@ protected[model] trait TemplateComponent { self: Profile =>
byRepository(userName, repositoryName) && (this.milestoneId === milestoneId) byRepository(userName, repositoryName) && (this.milestoneId === milestoneId)
} }
trait CommitTemplate extends BasicTemplate { self: Table[_] => trait CommitTemplate extends BasicTemplate { self: Table[?] =>
val commitId = column[String]("COMMIT_ID") val commitId = column[String]("COMMIT_ID")
def byCommit(owner: String, repository: String, commitId: String) = def byCommit(owner: String, repository: String, commitId: String) =
@@ -76,7 +76,7 @@ protected[model] trait TemplateComponent { self: Profile =>
byRepository(userName, repositoryName) && (this.commitId === commitId) byRepository(userName, repositoryName) && (this.commitId === commitId)
} }
trait BranchTemplate extends BasicTemplate { self: Table[_] => trait BranchTemplate extends BasicTemplate { self: Table[?] =>
val branch = column[String]("BRANCH") val branch = column[String]("BRANCH")
def byBranch(owner: String, repository: String, branchName: String) = def byBranch(owner: String, repository: String, branchName: String) =
byRepository(owner, repository) && (branch === branchName.bind) byRepository(owner, repository) && (branch === branchName.bind)

View File

@@ -307,7 +307,7 @@ object PluginRegistry {
conn, conn,
classLoader, classLoader,
DatabaseConfig.liquiDriver, DatabaseConfig.liquiDriver,
new Module(plugin.pluginId, plugin.versions: _*) new Module(plugin.pluginId, plugin.versions*)
) )
conn.commit() conn.commit()

View File

@@ -563,7 +563,7 @@ object MergeService {
): ObjectId = { ): ObjectId = {
val mergeCommit = new CommitBuilder() val mergeCommit = new CommitBuilder()
mergeCommit.setTreeId(treeId) mergeCommit.setTreeId(treeId)
mergeCommit.setParentIds(parents: _*) mergeCommit.setParentIds(parents*)
mergeCommit.setAuthor(committer) mergeCommit.setAuthor(committer)
mergeCommit.setCommitter(committer) mergeCommit.setCommitter(committer)
mergeCommit.setMessage(message) mergeCommit.setMessage(message)

View File

@@ -7,7 +7,7 @@ import gitbucket.core.controller.Context
import gitbucket.core.model.Profile.* import gitbucket.core.model.Profile.*
import gitbucket.core.model.Profile.profile.blockingApi.* import gitbucket.core.model.Profile.profile.blockingApi.*
import gitbucket.core.model.activity.OpenPullRequestInfo import gitbucket.core.model.activity.OpenPullRequestInfo
import gitbucket.core.model.{CommitComments as _, Session as _, *} import gitbucket.core.model.{CommitComments => _, Session => _, *}
import gitbucket.core.plugin.PluginRegistry import gitbucket.core.plugin.PluginRegistry
import gitbucket.core.service.RepositoryService.RepositoryInfo import gitbucket.core.service.RepositoryService.RepositoryInfo
import gitbucket.core.service.SystemSettingsService.SystemSettings import gitbucket.core.service.SystemSettingsService.SystemSettings

View File

@@ -120,14 +120,14 @@ trait RepositoryService {
deleteRepositoryOnModel(oldUserName, oldRepositoryName) deleteRepositoryOnModel(oldUserName, oldRepositoryName)
RepositoryWebHooks.insertAll( RepositoryWebHooks.insertAll(
webHooks.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* webHooks.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
RepositoryWebHookEvents.insertAll( RepositoryWebHookEvents.insertAll(
webHookEvents.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* webHookEvents.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
Milestones.insertAll(milestones.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _*) Milestones.insertAll(milestones.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*)
Priorities.insertAll(priorities.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _*) Priorities.insertAll(priorities.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*)
IssueId.insertAll(issueId.map(_.copy(_1 = newUserName, _2 = newRepositoryName)): _*) IssueId.insertAll(issueId.map(_.copy(_1 = newUserName, _2 = newRepositoryName))*)
val newMilestones = Milestones.filter(_.byRepository(newUserName, newRepositoryName)).list val newMilestones = Milestones.filter(_.byRepository(newUserName, newRepositoryName)).list
val newPriorities = Priorities.filter(_.byRepository(newUserName, newRepositoryName)).list val newPriorities = Priorities.filter(_.byRepository(newUserName, newRepositoryName)).list
@@ -145,31 +145,31 @@ trait RepositoryService {
.priorityId .priorityId
} }
) )
}: _*) }*)
PullRequests.insertAll( PullRequests.insertAll(
pullRequests.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* pullRequests.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
IssueComments.insertAll( IssueComments.insertAll(
issueComments.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* issueComments.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
Labels.insertAll(labels.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _*) Labels.insertAll(labels.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*)
CommitComments.insertAll( CommitComments.insertAll(
commitComments.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* commitComments.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
CommitStatuses.insertAll( CommitStatuses.insertAll(
commitStatuses.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* commitStatuses.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
ProtectedBranches.insertAll( ProtectedBranches.insertAll(
protectedBranches.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* protectedBranches.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
ProtectedBranchContexts.insertAll( ProtectedBranchContexts.insertAll(
protectedBranchContexts.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* protectedBranchContexts.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
DeployKeys.insertAll(deployKeys.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _*) DeployKeys.insertAll(deployKeys.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*)
ReleaseTags.insertAll(releases.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _*) ReleaseTags.insertAll(releases.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*)
ReleaseAssets.insertAll( ReleaseAssets.insertAll(
releaseAssets.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* releaseAssets.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
// Update source repository of pull requests // Update source repository of pull requests
@@ -193,12 +193,12 @@ trait RepositoryService {
userName = newUserName, userName = newUserName,
repositoryName = newRepositoryName repositoryName = newRepositoryName
) )
): _* )*
) )
// TODO Drop transferred owner from collaborators? // TODO Drop transferred owner from collaborators?
Collaborators.insertAll( Collaborators.insertAll(
collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName)): _* collaborators.map(_.copy(userName = newUserName, repositoryName = newRepositoryName))*
) )
// Move git repository // Move git repository

View File

@@ -19,13 +19,13 @@ object JDBCUtil {
implicit class RichConnection(private val conn: Connection) extends AnyVal { implicit class RichConnection(private val conn: Connection) extends AnyVal {
def update(sql: String, params: Any*): Int = { def update(sql: String, params: Any*): Int = {
execute(sql, params: _*) { stmt => execute(sql, params*) { stmt =>
stmt.executeUpdate() stmt.executeUpdate()
} }
} }
def find[T](sql: String, params: Any*)(f: ResultSet => T): Option[T] = { def find[T](sql: String, params: Any*)(f: ResultSet => T): Option[T] = {
execute(sql, params: _*) { stmt => execute(sql, params*) { stmt =>
Using.resource(stmt.executeQuery()) { rs => Using.resource(stmt.executeQuery()) { rs =>
if (rs.next) Some(f(rs)) else None if (rs.next) Some(f(rs)) else None
} }
@@ -33,7 +33,7 @@ object JDBCUtil {
} }
def select[T](sql: String, params: Any*)(f: ResultSet => T): Seq[T] = { def select[T](sql: String, params: Any*)(f: ResultSet => T): Seq[T] = {
execute(sql, params: _*) { stmt => execute(sql, params*) { stmt =>
Using.resource(stmt.executeQuery()) { rs => Using.resource(stmt.executeQuery()) { rs =>
val list = new ListBuffer[T] val list = new ListBuffer[T]
while (rs.next) { while (rs.next) {
@@ -45,7 +45,7 @@ object JDBCUtil {
} }
def selectInt(sql: String, params: Any*): Int = { def selectInt(sql: String, params: Any*): Int = {
execute(sql, params: _*) { stmt => execute(sql, params*) { stmt =>
Using.resource(stmt.executeQuery()) { rs => Using.resource(stmt.executeQuery()) { rs =>
if (rs.next) rs.getInt(1) else 0 if (rs.next) rs.getInt(1) else 0
} }

View File

@@ -42,7 +42,7 @@ trait Validations {
* ValueType for the java.util.Date property. * ValueType for the java.util.Date property.
*/ */
def date(constraints: Constraint*): SingleValueType[java.util.Date] = def date(constraints: Constraint*): SingleValueType[java.util.Date] =
new SingleValueType[java.util.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints): _*) { new SingleValueType[java.util.Date]((pattern("\\d{4}-\\d{2}-\\d{2}") +: constraints)*) {
def convert(value: String, messages: Messages): java.util.Date = def convert(value: String, messages: Messages): java.util.Date =
new java.text.SimpleDateFormat("yyyy-MM-dd").parse(value) new java.text.SimpleDateFormat("yyyy-MM-dd").parse(value)
} }

View File

@@ -29,7 +29,7 @@ class GitBucketCoreModuleSpec extends AnyFunSuite {
Seq("8.0", "5.7").foreach { tag => Seq("8.0", "5.7").foreach { tag =>
test(s"Migration MySQL $tag", ExternalDBTest) { test(s"Migration MySQL $tag", ExternalDBTest) {
val container = new MySQLContainer() { val container = new MySQLContainer() {
override val container: org.testcontainers.containers.MySQLContainer[_] = override val container: org.testcontainers.containers.MySQLContainer[?] =
new org.testcontainers.containers.MySQLContainer(s"mysql:$tag") { new org.testcontainers.containers.MySQLContainer(s"mysql:$tag") {
override def getDriverClassName = "org.mariadb.jdbc.Driver" override def getDriverClassName = "org.mariadb.jdbc.Driver"
override def getJdbcUrl: String = super.getJdbcUrl + "?permitMysqlScheme" override def getJdbcUrl: String = super.getJdbcUrl + "?permitMysqlScheme"

View File

@@ -115,7 +115,7 @@ object GitSpecUtil {
// creates merge commit // creates merge commit
val mergeCommit = new CommitBuilder() val mergeCommit = new CommitBuilder()
mergeCommit.setTreeId(merger.getResultTreeId) mergeCommit.setTreeId(merger.getResultTreeId)
mergeCommit.setParentIds(Array[ObjectId](mergeBaseTip, mergeTip): _*) mergeCommit.setParentIds(Array[ObjectId](mergeBaseTip, mergeTip)*)
mergeCommit.setAuthor(committer) mergeCommit.setAuthor(committer)
mergeCommit.setCommitter(committer) mergeCommit.setCommitter(committer)
mergeCommit.setMessage(message) mergeCommit.setMessage(message)