mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-15 18:05:50 +01:00
add explicit types for implicit val
prepare Scala 3
This commit is contained in:
@@ -12,7 +12,7 @@ import gitbucket.core.util.JDBCUtil
|
||||
import io.github.gitbucket.solidbase.Solidbase
|
||||
import io.github.gitbucket.solidbase.migration.{LiquibaseMigration, Migration, SqlMigration}
|
||||
import io.github.gitbucket.solidbase.model.{Module, Version}
|
||||
import org.json4s.NoTypeHints
|
||||
import org.json4s.{Formats, NoTypeHints}
|
||||
import org.json4s.jackson.Serialization
|
||||
import org.json4s.jackson.Serialization.write
|
||||
|
||||
@@ -85,7 +85,7 @@ object GitBucketCoreModule
|
||||
"4.34.0",
|
||||
new Migration() {
|
||||
override def migrate(moduleId: String, version: String, context: util.Map[String, AnyRef]): Unit = {
|
||||
implicit val formats = Serialization.formats(NoTypeHints)
|
||||
implicit val formats: Formats = Serialization.formats(NoTypeHints)
|
||||
import JDBCUtil._
|
||||
|
||||
val conn = context.get(Solidbase.CONNECTION).asInstanceOf[Connection]
|
||||
|
||||
@@ -66,7 +66,7 @@ object ApiBranchProtection {
|
||||
}
|
||||
}
|
||||
|
||||
implicit val enforcementLevelSerializer = new CustomSerializer[EnforcementLevel](
|
||||
implicit val enforcementLevelSerializer: CustomSerializer[EnforcementLevel] = new CustomSerializer[EnforcementLevel](
|
||||
format =>
|
||||
(
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.eclipse.jgit.revwalk.RevCommit
|
||||
import org.eclipse.jgit.treewalk._
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.json4s.Formats
|
||||
|
||||
/**
|
||||
* Provides generic features for controller implementations.
|
||||
@@ -43,7 +44,7 @@ abstract class ControllerBase
|
||||
|
||||
private val logger = LoggerFactory.getLogger(getClass)
|
||||
|
||||
implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
implicit val jsonFormats: Formats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
|
||||
before("/api/v3/*") {
|
||||
contentType = formats("json")
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.apache.commons.io.{FileUtils, IOUtils}
|
||||
|
||||
import scala.util.Using
|
||||
import gitbucket.core.service.SystemSettingsService
|
||||
import slick.jdbc.JdbcBackend.Session
|
||||
|
||||
/**
|
||||
* Provides Ajax based file upload functionality.
|
||||
@@ -178,7 +179,7 @@ class FileUploadController
|
||||
}
|
||||
|
||||
private def onlyWikiEditable(owner: String, repository: String, loginAccount: Account)(action: => Any): Any = {
|
||||
implicit val session = Database.getSession(request)
|
||||
implicit val session: Session = Database.getSession(request)
|
||||
getRepository(owner, repository) match {
|
||||
case Some(x) =>
|
||||
x.repository.options.wikiOption match {
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.model
|
||||
trait AccountWebHookComponent extends TemplateComponent { self: Profile =>
|
||||
import profile.api._
|
||||
|
||||
private implicit val whContentTypeColumnType =
|
||||
private implicit val whContentTypeColumnType: BaseColumnType[WebHookContentType] =
|
||||
MappedColumnType.base[WebHookContentType, String](whct => whct.code, code => WebHookContentType.valueOf(code))
|
||||
|
||||
lazy val AccountWebHooks = TableQuery[AccountWebHooks]
|
||||
|
||||
@@ -4,7 +4,8 @@ trait CommitStatusComponent extends TemplateComponent { self: Profile =>
|
||||
import profile.api._
|
||||
import self._
|
||||
|
||||
implicit val commitStateColumnType = MappedColumnType.base[CommitState, String](b => b.name, i => CommitState(i))
|
||||
implicit val commitStateColumnType: BaseColumnType[CommitState] =
|
||||
MappedColumnType.base[CommitState, String](b => b.name, i => CommitState(i))
|
||||
|
||||
lazy val CommitStatuses = TableQuery[CommitStatuses]
|
||||
class CommitStatuses(tag: Tag) extends Table[CommitStatus](tag, "COMMIT_STATUS") with CommitTemplate {
|
||||
|
||||
@@ -10,7 +10,8 @@ trait Profile {
|
||||
/**
|
||||
* java.util.Date Mapped Column Types
|
||||
*/
|
||||
implicit val dateColumnType = MappedColumnType.base[java.util.Date, java.sql.Timestamp](
|
||||
implicit val dateColumnType: BaseColumnType[java.util.Date] =
|
||||
MappedColumnType.base[java.util.Date, java.sql.Timestamp](
|
||||
d => new java.sql.Timestamp(d.getTime),
|
||||
t => new java.util.Date(t.getTime)
|
||||
)
|
||||
@@ -18,7 +19,8 @@ trait Profile {
|
||||
/**
|
||||
* WebHookBase.Event Column Types
|
||||
*/
|
||||
implicit val eventColumnType = MappedColumnType.base[WebHook.Event, String](_.name, WebHook.Event.valueOf(_))
|
||||
implicit val eventColumnType: BaseColumnType[WebHook.Event] =
|
||||
MappedColumnType.base[WebHook.Event, String](_.name, WebHook.Event.valueOf(_))
|
||||
|
||||
/**
|
||||
* Extends Column to add conditional condition
|
||||
|
||||
@@ -3,7 +3,7 @@ package gitbucket.core.model
|
||||
trait RepositoryWebHookComponent extends TemplateComponent { self: Profile =>
|
||||
import profile.api._
|
||||
|
||||
implicit val whContentTypeColumnType =
|
||||
implicit val whContentTypeColumnType: BaseColumnType[WebHookContentType] =
|
||||
MappedColumnType.base[WebHookContentType, String](whct => whct.code, code => WebHookContentType.valueOf(code))
|
||||
|
||||
lazy val RepositoryWebHooks = TableQuery[RepositoryWebHooks]
|
||||
|
||||
@@ -22,7 +22,7 @@ import scala.collection.mutable.ListBuffer
|
||||
trait ActivityService {
|
||||
self: RequestCache =>
|
||||
|
||||
private implicit val formats = Serialization.formats(NoTypeHints)
|
||||
private implicit val formats: Formats = Serialization.formats(NoTypeHints)
|
||||
|
||||
private def writeLog(activity: Activity): Unit = {
|
||||
Using.resource(new FileOutputStream(ActivityLog, true)) { out =>
|
||||
|
||||
@@ -19,8 +19,9 @@ class ApiAuthenticationFilter extends Filter with AccessTokenService with Accoun
|
||||
override def destroy(): Unit = {}
|
||||
|
||||
override def doFilter(req: ServletRequest, res: ServletResponse, chain: FilterChain): Unit = {
|
||||
implicit val request = req.asInstanceOf[HttpServletRequest]
|
||||
implicit val session = req.getAttribute(Keys.Request.DBSession).asInstanceOf[slick.jdbc.JdbcBackend#Session]
|
||||
implicit val request: HttpServletRequest = req.asInstanceOf[HttpServletRequest]
|
||||
implicit val session: slick.jdbc.JdbcBackend#Session =
|
||||
req.getAttribute(Keys.Request.DBSession).asInstanceOf[slick.jdbc.JdbcBackend#Session]
|
||||
val response = res.asInstanceOf[HttpServletResponse]
|
||||
Option(request.getHeader("Authorization"))
|
||||
.map {
|
||||
|
||||
@@ -6,6 +6,7 @@ import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
|
||||
|
||||
import gitbucket.core.util.{FileUtil, StringUtil}
|
||||
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||
import org.json4s.Formats
|
||||
import org.json4s.jackson.Serialization._
|
||||
import org.apache.http.HttpStatus
|
||||
|
||||
@@ -17,7 +18,7 @@ import scala.util.Using
|
||||
*/
|
||||
class GitLfsTransferServlet extends HttpServlet {
|
||||
|
||||
private implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
private implicit val jsonFormats: Formats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
private val LongObjectIdLength = 32
|
||||
private val LongObjectIdStringLength = LongObjectIdLength * 2
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.Date
|
||||
|
||||
import scala.util.Using
|
||||
import gitbucket.core.api
|
||||
import gitbucket.core.api.JsonFormat.Context
|
||||
import gitbucket.core.model.WebHook
|
||||
import gitbucket.core.plugin.{GitRepositoryRouting, PluginRegistry}
|
||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||
@@ -42,6 +43,7 @@ import javax.servlet.ServletConfig
|
||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||
import org.eclipse.jgit.diff.DiffEntry.ChangeType
|
||||
import org.eclipse.jgit.internal.storage.file.FileRepository
|
||||
import org.json4s.Formats
|
||||
import org.json4s.jackson.Serialization._
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,7 @@ import org.json4s.jackson.Serialization._
|
||||
class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[GitRepositoryServlet])
|
||||
private implicit val jsonFormats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
private implicit val jsonFormats: Formats = gitbucket.core.api.JsonFormat.jsonFormats
|
||||
|
||||
override def init(config: ServletConfig): Unit = {
|
||||
setReceivePackFactory(new GitBucketReceivePackFactory())
|
||||
@@ -293,7 +295,7 @@ class CommitLogHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
val pushedIds = scala.collection.mutable.Set[String]()
|
||||
commands.asScala.foreach { command =>
|
||||
logger.debug(s"commandType: ${command.getType}, refName: ${command.getRefName}")
|
||||
implicit val apiContext = api.JsonFormat.Context(baseUrl, sshUrl)
|
||||
implicit val apiContext: Context = api.JsonFormat.Context(baseUrl, sshUrl)
|
||||
val refName = command.getRefName.split("/")
|
||||
val branchName = refName.drop(2).mkString("/")
|
||||
val commits = if (refName(1) == "tags") {
|
||||
@@ -469,7 +471,7 @@ class WikiCommitHook(owner: String, repository: String, pusher: String, baseUrl:
|
||||
Database() withTransaction { implicit session =>
|
||||
try {
|
||||
commands.asScala.headOption.foreach { command =>
|
||||
implicit val apiContext = api.JsonFormat.Context(baseUrl, sshUrl)
|
||||
implicit val apiContext: Context = api.JsonFormat.Context(baseUrl, sshUrl)
|
||||
val refName = command.getRefName.split("/")
|
||||
val commitIds = if (refName(1) == "tags") {
|
||||
None
|
||||
|
||||
@@ -38,7 +38,7 @@ object JGitUtil {
|
||||
|
||||
private val logger = LoggerFactory.getLogger(JGitUtil.getClass)
|
||||
|
||||
implicit val objectDatabaseReleasable = new Releasable[ObjectDatabase] {
|
||||
implicit val objectDatabaseReleasable: Releasable[ObjectDatabase] = new Releasable[ObjectDatabase] {
|
||||
override def release(resource: ObjectDatabase): Unit = resource.close()
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||
import gitbucket.core.service.{RepositoryService, RequestCache}
|
||||
import gitbucket.core.util.{FileUtil, JGitUtil, StringUtil}
|
||||
import org.apache.commons.codec.digest.DigestUtils
|
||||
import org.json4s.Formats
|
||||
import play.twirl.api.{Html, HtmlFormat}
|
||||
|
||||
/**
|
||||
@@ -387,7 +388,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
* Render a given object as the JSON string.
|
||||
*/
|
||||
def json(obj: AnyRef): String = {
|
||||
implicit val formats = org.json4s.DefaultFormats
|
||||
implicit val formats: Formats = org.json4s.DefaultFormats
|
||||
org.json4s.jackson.Serialization.write(obj)
|
||||
}
|
||||
|
||||
@@ -472,7 +473,7 @@ object helpers extends AvatarImageProvider with LinkConverter with RequestCache
|
||||
def diff(jsonString: String): Html = {
|
||||
import org.json4s._
|
||||
import org.json4s.jackson.JsonMethods._
|
||||
implicit val formats = DefaultFormats
|
||||
implicit val formats: Formats = DefaultFormats
|
||||
|
||||
val diff = parse(jsonString).extract[Seq[CommentDiffLine]]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user