Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move codebase to scala 3 #1430

Merged
merged 10 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .scalafix.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
rules = [
ProcedureSyntax
OrganizeImports
]
OrganizeImports {
Expand All @@ -10,4 +9,5 @@ OrganizeImports {
groups = ["re:javax?\\.", "scala.", "re:(cats|fs2)\\.", "sharry.", "*"]
importSelectorsOrder = Ascii
removeUnused = true
targetDialect = Scala3
}
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version = "3.8.1"

preset = default
runner.dialect = scala213source3
runner.dialect = scala3
align.preset = some

maxColumn = 90
Expand Down
22 changes: 8 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ val scalafixSettings = Seq(

val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := "2.13.14",
scalaVersion := "3.4.2",
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
Expand All @@ -22,12 +22,10 @@ val sharedSettings = Seq(
"-feature",
"-Werror", // fail when there are warnings
"-unchecked",
// remove -byname-implicit, once https://github.com/scala/bug/issues/12072 is resolved
"-Xlint:-byname-implicit,_",
"-Wdead-code",
"-Wunused",
"-Wvalue-discard",
"-Wnumeric-widen"
"-Wunused:imports",
"-Wunused:locals",
"-Wunused:explicits",
"-Wvalue-discard"
),
Compile / console / scalacOptions := Seq(),
Test / console / scalacOptions := Seq()
Expand Down Expand Up @@ -124,7 +122,6 @@ val loggingApi = project
.settings(testSettingsMUnit)
.settings(
name := "sharry-logging-api",
addCompilerPlugin(Dependencies.kindProjectorPlugin),
libraryDependencies ++=
Dependencies.circeCore ++
Dependencies.fs2 ++
Expand All @@ -141,8 +138,7 @@ val common = project
libraryDependencies ++=
Dependencies.fs2 ++
Dependencies.fs2io ++
Dependencies.circe ++
Dependencies.pureconfig
Dependencies.circe
)

val loggingScribe = project
Expand All @@ -152,7 +148,6 @@ val loggingScribe = project
.settings(testSettingsMUnit)
.settings(
name := "sharry-logging-scribe",
addCompilerPlugin(Dependencies.kindProjectorPlugin),
libraryDependencies ++=
Dependencies.scribe ++
Dependencies.circeCore ++
Expand Down Expand Up @@ -284,11 +279,10 @@ val restserver = project
Dependencies.http4s ++
Dependencies.http4sclient ++
Dependencies.circe ++
Dependencies.pureconfig ++
Dependencies.typesafeConfig ++
Dependencies.ciris ++
Dependencies.yamusca ++
Dependencies.webjars,
addCompilerPlugin(Dependencies.kindProjectorPlugin),
addCompilerPlugin(Dependencies.betterMonadicFor),
buildInfoPackage := "sharry.restserver",
reStart / javaOptions ++=
Seq(
Expand Down
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
SHARRY_BACKEND_MAIL_SMTP_PORT = "25";
SHARRY_BACKEND_MAIL_SMTP_USER = "admin";
SHARRY_BACKEND_MAIL_SMTP_PASSWORD = "admin";
SHARRY_BACKEND_MAIL_SMTP_SSL__TYPE = "none";
SHARRY_BACKEND_MAIL_SMTP_SSL_TYPE = "none";
};

dev-vm = pkgs.mkShellNoCC {
Expand All @@ -91,7 +91,7 @@
SHARRY_BACKEND_MAIL_SMTP_PORT = "10025";
SHARRY_BACKEND_MAIL_SMTP_USER = "admin";
SHARRY_BACKEND_MAIL_SMTP_PASSWORD = "admin";
SHARRY_BACKEND_MAIL_SMTP_SSL__TYPE = "none";
SHARRY_BACKEND_MAIL_SMTP_SSL_TYPE = "none";
};
ci = pkgs.mkShellNoCC {
buildInputs = ciPkgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package sharry.backend

import scala.concurrent.ExecutionContext

import cats.effect._
import cats.effect.*
import fs2.io.file.Files

import sharry.backend.account._
import sharry.backend.account.*
import sharry.backend.alias.OAlias
import sharry.backend.auth.Login
import sharry.backend.config.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sharry.backend.account

import cats.effect.Sync
import cats.implicits._
import cats.implicits.*

import sharry.common._
import sharry.common.*

case class NewAccount(
id: Ident,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package sharry.backend.account

import cats.data.OptionT
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*
import fs2.Stream

import sharry.backend.PasswordCrypt
import sharry.backend.share.{Queries => ShareQueries}
import sharry.common._
import sharry.backend.share.Queries as ShareQueries
import sharry.common.*
import sharry.store.AddResult
import sharry.store.Store
import sharry.store.records._
import sharry.store.records.*

import doobie._
import doobie.*

trait OAccount[F[_]] {

Expand Down Expand Up @@ -45,7 +45,7 @@ object OAccount {

def apply[F[_]: Async](store: Store[F]): Resource[F, OAccount[F]] =
Resource.pure[F, OAccount[F]](new OAccount[F] {
private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def changePassword(id: Ident, oldPw: Password, newPw: Password): F[AddResult] = {
val update =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package sharry.backend.account

import fs2.Stream

import sharry.common._
import sharry.store.doobie.DoobieMeta._
import sharry.store.doobie._
import sharry.store.records._
import sharry.common.*
import sharry.store.doobie.*
import sharry.store.doobie.DoobieMeta.*
import sharry.store.records.*

import doobie._
import doobie.implicits._
import doobie.*
import doobie.implicits.*

object Queries {

Expand Down
10 changes: 5 additions & 5 deletions modules/backend/src/main/scala/sharry/backend/alias/OAlias.scala
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package sharry.backend.alias

import cats.data.OptionT
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*
import fs2.Stream

import sharry.backend.alias.OAlias.{AliasDetail, AliasInput}
import sharry.common._
import sharry.common.*
import sharry.store.AddResult
import sharry.store.Store
import sharry.store.records.RAlias
import sharry.store.records.RAliasMember

import doobie._
import doobie.*

trait OAlias[F[_]] {

Expand Down Expand Up @@ -40,7 +40,7 @@ object OAlias {

def apply[F[_]: Async](store: Store[F]): Resource[F, OAlias[F]] =
Resource.pure[F, OAlias[F]](new OAlias[F] {
private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def create(detail: AliasInput): F[AddResult] =
store.add(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package sharry.backend.auth

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.backend.account.{NewAccount, OAccount}
import sharry.common._
import sharry.common.*
import sharry.store.records.RAccount

object AddAccount {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package sharry.backend.auth
import sharry.common._
import sharry.common.*

import scodec.bits.ByteVector

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package sharry.backend.auth

import java.time.Instant

import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.backend.Common
import sharry.backend.auth.AuthToken._
import sharry.backend.auth.AuthToken.*
import sharry.common.util.SignUtil
import sharry.common.{AccountId, Duration}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package sharry.backend.auth

import scala.sys.process._
import scala.sys.process.*

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.common._
import sharry.common.*

import yamusca.implicits._
import yamusca.imports._
import yamusca.implicits.*
import yamusca.imports.*

final class CommandAuth[F[_]: Async](
cfg: AuthConfig,
ops: AddAccount.AccountOps[F],
runner: CommandAuth.RunCommand[F]
) {
private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def login: LoginModule[F] =
LoginModule.whenEnabled(cfg.command.enabled)(
Expand Down Expand Up @@ -69,7 +69,7 @@ object CommandAuth {

def systemProcess[F[_]: Sync]: RunCommand[F] =
new RunCommand[F] {
private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def exec(up: UserPassData, cfg: AuthConfig.Command): F[Boolean] =
Sync[F].delay {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package sharry.backend.auth

import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.backend.account._
import sharry.common._
import sharry.backend.account.*
import sharry.common.*

/** Provides authentication from the configuration.
*
Expand All @@ -17,7 +17,7 @@ import sharry.common._
*/
final class FixedAuth[F[_]: Async](cfg: AuthConfig, op: OAccount[F]) {

private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def login: LoginModule[F] =
LoginModule { up =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package sharry.backend.auth
import java.nio.charset.StandardCharsets

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.common._
import sharry.common.*

import yamusca.implicits._
import yamusca.imports._
import yamusca.implicits.*
import yamusca.imports.*

final class HttpAuth[F[_]: Async](
cfg: AuthConfig,
ops: AddAccount.AccountOps[F],
runner: HttpAuth.RunRequest[F]
) {

private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def login: LoginModule[F] =
LoginModule.whenEnabled(cfg.http.enabled)(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package sharry.backend.auth

import java.nio.charset.StandardCharsets
import java.{util => ju}
import java.util as ju

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.common._
import sharry.common.*

final class HttpBasicAuth[F[_]: Async](
cfg: AuthConfig,
ops: AddAccount.AccountOps[F],
runner: HttpBasicAuth.RunRequest[F]
) {

private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def login: LoginModule[F] =
LoginModule.whenEnabled(cfg.httpBasic.enabled)(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package sharry.backend.auth

import cats.data.Kleisli
import cats.effect._
import cats.implicits._
import cats.effect.*
import cats.implicits.*

import sharry.backend.PasswordCrypt
import sharry.backend.account.OAccount
import sharry.common._
import sharry.common.*
import sharry.store.records.RAccount

final class InternalAuth[F[_]: Async](cfg: AuthConfig, op: OAccount[F]) {

private[this] val logger = sharry.logging.getLogger[F]
private val logger = sharry.logging.getLogger[F]

def login: LoginModule[F] =
LoginModule.enabledState(cfg.internal.enabled, op, AccountSource.intern)(
Expand Down
Loading