~jan0sch/smederee

Showing details for patch a897838a717551ef2c69519fba6dae53e50348c3.
2023-03-22 (Wed), 4:40 PM - Jens Grassel - a897838a717551ef2c69519fba6dae53e50348c3

Code Cleanup

- remove unused imports and variables
- add some debug logging
Summary of changes
6 files modified with 26 lines added and 21 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala with 1 added and 4 removed lines
  • modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala with 24 added and 6 removed lines
  • modules/hub/src/main/scala/de/smederee/ssh/DoobieSshAuthenticationRepository.scala with 0 added and 2 removed lines
  • modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala with 0 added and 6 removed lines
  • modules/hub/src/main/scala/de/smederee/tickets/LabelRoutes.scala with 1 added and 1 removed lines
  • modules/hub/src/main/scala/de/smederee/tickets/MilestoneRoutes.scala with 0 added and 2 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/AuthenticationRoutes.scala	2025-01-31 10:41:02.142413897 +0000
@@ -74,10 +74,7 @@
 ) extends Http4sDsl[F] {
   private val log = LoggerFactory.getLogger(getClass)
 
-  private val loginPath  = uri"/login"
-  private val logoutPath = uri"/logout"
-  private val resetPath  = loginPath.addPath("reset")
-  private val unlockPath = loginPath.addPath("unlock")
+  private val loginPath = uri"/login"
 
   private val parseLoginForm: HttpRoutes[F] = HttpRoutes.of[F] { case request @ POST -> Root / "login" =>
     request.decodeStrict[F, UrlForm] { urlForm =>
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DarcsSshCommand.scala	2025-01-31 10:41:02.142413897 +0000
@@ -74,12 +74,30 @@
     */
   protected def commandLogic(cmd: os.proc): os.CommandResult
 
-  override def destroy(channel: ChannelSession): Unit            = ()
-  override def setErrorStream(errorStream: OutputStream): Unit   = this.stderr = errorStream
-  override def setExitCallback(callback: ExitCallback): Unit     = this.callback = callback
-  override def setInputStream(inputStream: InputStream): Unit    = this.stdin = inputStream
-  override def setOutputStream(outputStream: OutputStream): Unit = this.stdout = outputStream
-  override def setSession(session: ServerSession): Unit          = this.session = session
+  override def destroy(channel: ChannelSession): Unit = {
+    log.debug("destroy: {}", channel)
+    ()
+  }
+  override def setErrorStream(errorStream: OutputStream): Unit = {
+    log.debug("setErrorStream")
+    this.stderr = errorStream
+  }
+  override def setExitCallback(callback: ExitCallback): Unit = {
+    log.debug("setExitCallback: {}", callback)
+    this.callback = callback
+  }
+  override def setInputStream(inputStream: InputStream): Unit = {
+    log.debug("setInputStream")
+    this.stdin = inputStream
+  }
+  override def setOutputStream(outputStream: OutputStream): Unit = {
+    log.debug("setOutputStream")
+    this.stdout = outputStream
+  }
+  override def setSession(session: ServerSession): Unit = {
+    log.debug("setSession: {}", session)
+    this.session = session
+  }
 
 }
 
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DoobieSshAuthenticationRepository.scala new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DoobieSshAuthenticationRepository.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/ssh/DoobieSshAuthenticationRepository.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/ssh/DoobieSshAuthenticationRepository.scala	2025-01-31 10:41:02.142413897 +0000
@@ -25,10 +25,8 @@
 import doobie._
 import doobie.implicits._
 import doobie.postgres.implicits._
-import org.slf4j.LoggerFactory
 
 final class DoobieSshAuthenticationRepository[F[_]: Sync](tx: Transactor[F]) extends SshAuthenticationRepository[F] {
-  private final val log = LoggerFactory.getLogger(getClass)
 
   given Meta[EncodedKeyBytes]   = Meta[String].timap(EncodedKeyBytes.unsafeFrom)(_.toString)
   given Meta[KeyComment]        = Meta[String].timap(KeyComment.apply)(_.toString)
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala new-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/ssh/SshServer.scala	2025-01-31 10:41:02.142413897 +0000
@@ -18,23 +18,17 @@
 package de.smederee.ssh
 
 import java.nio.file.*
-import java.util.Collections
 
 import cats._
-import cats.data._
 import cats.effect._
-import cats.effect.std.Dispatcher
-import cats.syntax.all._
 import com.comcast.ip4s._
 import de.smederee.hub.config._
 import de.smederee.security.{ UserId, Username }
 import doobie._
 import org.apache.sshd.common.AttributeRepository.AttributeKey
 import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory
-import org.apache.sshd.scp.server.ScpCommandFactory
 import org.apache.sshd.server.SshServer
 import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
-import org.apache.sshd.sftp.server.SftpSubsystemFactory
 import pureconfig._
 
 import scala.util.matching.Regex
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/tickets/LabelRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/tickets/LabelRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/tickets/LabelRoutes.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/tickets/LabelRoutes.scala	2025-01-31 10:41:02.142413897 +0000
@@ -30,7 +30,6 @@
 import de.smederee.tickets.forms.types._
 import org.http4s._
 import org.http4s.dsl.Http4sDsl
-import org.http4s.dsl.impl._
 import org.http4s.headers.Location
 import org.http4s.twirl.TwirlInstances._
 import org.slf4j.LoggerFactory
@@ -74,6 +73,7 @@
       csrf: Option[CsrfToken]
   )(user: Option[Account])(projectOwnerName: Username)(projectName: ProjectName): F[Response[F]] =
     for {
+      _            <- Sync[F].delay(log.debug(s"doShowLabels: $csrf, $user, $projectOwnerName, $projectName"))
       projectAndId <- loadProject(user)(projectOwnerName, projectName)
       resp <- projectAndId match {
         case Some((repo, repoId)) =>
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/tickets/MilestoneRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/tickets/MilestoneRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/tickets/MilestoneRoutes.scala	2025-01-31 10:41:02.138413889 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/tickets/MilestoneRoutes.scala	2025-01-31 10:41:02.142413897 +0000
@@ -32,7 +32,6 @@
 import org.http4s.dsl.Http4sDsl
 import org.http4s.headers.Location
 import org.http4s.twirl.TwirlInstances._
-import org.slf4j.LoggerFactory
 
 /** Routes for managing milestones (basically CRUD functionality).
   *
@@ -50,7 +49,6 @@
     milestoneRepo: MilestoneRepository[F],
     projectRepo: ProjectRepository[F]
 ) extends Http4sDsl[F] {
-  private val log = LoggerFactory.getLogger(getClass)
 
   given CsrfProtectionConfiguration = configuration.csrfProtection