diff --git a/auth/.js/src/main/scala/io/udash/auth/AuthApplication.scala b/auth/.js/src/main/scala/io/udash/auth/AuthApplication.scala index 0ecb4bfa7..2e68ad25a 100644 --- a/auth/.js/src/main/scala/io/udash/auth/AuthApplication.scala +++ b/auth/.js/src/main/scala/io/udash/auth/AuthApplication.scala @@ -3,7 +3,9 @@ package io.udash.auth import io.udash._ object AuthApplication { - implicit class ApplicationAuthExt[HierarchyRoot >: Null <: GState[HierarchyRoot]](val application: Application[HierarchyRoot]) extends AnyVal { + implicit final class ApplicationAuthExt[HierarchyRoot >: Null <: GState[HierarchyRoot]]( + private val application: Application[HierarchyRoot] + ) extends AnyVal { /** * Adds the default listener of authorization failure in routing (redirects to provided state). * diff --git a/auth/src/main/scala/io/udash/auth/Permission.scala b/auth/src/main/scala/io/udash/auth/Permission.scala index ac03395da..b768b4410 100644 --- a/auth/src/main/scala/io/udash/auth/Permission.scala +++ b/auth/src/main/scala/io/udash/auth/Permission.scala @@ -20,7 +20,7 @@ trait Permission { object Permission { /** Single permission as a combinator resolved implicitly. */ - implicit class Single(private val permission: Permission) extends AnyVal with PermissionCombinator { + implicit final class Single(private val permission: Permission) extends AnyVal with PermissionCombinator { override def check(ctx: UserCtx): Boolean = ctx.has(permission) diff --git a/auth/src/main/scala/io/udash/auth/PermissionId.scala b/auth/src/main/scala/io/udash/auth/PermissionId.scala index b26fe3328..f495389a8 100644 --- a/auth/src/main/scala/io/udash/auth/PermissionId.scala +++ b/auth/src/main/scala/io/udash/auth/PermissionId.scala @@ -3,5 +3,5 @@ package io.udash.auth import com.avsystem.commons.serialization.{HasGenCodec, transparent} @transparent -case class PermissionId(value: String) extends AnyVal +final case class PermissionId(value: String) extends AnyVal object PermissionId extends HasGenCodec[PermissionId] diff --git a/auth/src/main/scala/io/udash/auth/exceptions.scala b/auth/src/main/scala/io/udash/auth/exceptions.scala index 59b2612b2..6a3554c4c 100644 --- a/auth/src/main/scala/io/udash/auth/exceptions.scala +++ b/auth/src/main/scala/io/udash/auth/exceptions.scala @@ -1,9 +1,5 @@ package io.udash.auth -import com.avsystem.commons.serialization.HasGenCodec +class UnauthenticatedException extends RuntimeException(s"User has to be authenticated to access this content.") -case class UnauthenticatedException() extends RuntimeException(s"User has to be authenticated to access this content.") -object UnauthenticatedException extends HasGenCodec[UnauthenticatedException] - -case class UnauthorizedException() extends RuntimeException(s"Provided user context does not have access to this content.") -object UnauthorizedException extends HasGenCodec[UnauthorizedException] +class UnauthorizedException extends RuntimeException(s"Provided user context does not have access to this content.") diff --git a/benchmarks/.js/src/main/scala/io/udash/benchmarks/properties/PropertyParameters.scala b/benchmarks/.js/src/main/scala/io/udash/benchmarks/properties/PropertyParameters.scala index 78645cf1b..d7b034143 100644 --- a/benchmarks/.js/src/main/scala/io/udash/benchmarks/properties/PropertyParameters.scala +++ b/benchmarks/.js/src/main/scala/io/udash/benchmarks/properties/PropertyParameters.scala @@ -6,7 +6,7 @@ import japgolly.scalajs.benchmark.gui._ import scalatags.JsDom.all._ object PropertyParameters { - case class Entity(i: Int, s: String, r: Entity) + final case class Entity(i: Int, s: String, r: Entity) object Entity extends HasModelPropertyCreator[Entity] private def listenProperty(p: ReadableProperty[String]) = { diff --git a/bootstrap4/.js/src/main/scala/io/udash/bootstrap/carousel/UdashCarousel.scala b/bootstrap4/.js/src/main/scala/io/udash/bootstrap/carousel/UdashCarousel.scala index 87fa13818..2d0e8f702 100644 --- a/bootstrap4/.js/src/main/scala/io/udash/bootstrap/carousel/UdashCarousel.scala +++ b/bootstrap4/.js/src/main/scala/io/udash/bootstrap/carousel/UdashCarousel.scala @@ -254,7 +254,7 @@ object UdashCarousel { * @param keyboard Should the carousel react to keyboard events. * @param active Should the animation be active. */ - case class AnimationOptions( + final case class AnimationOptions( interval: Duration = 5 seconds, pause: PauseOption = PauseOption.Hover, wrap: Boolean = true, keyboard: Boolean = true, active: Boolean = true ) { @@ -285,7 +285,7 @@ object UdashCarousel { * @param imgSrc Slide image source url. * @param caption Slide caption content. */ -case class UdashCarouselSlide(imgSrc: Url)(caption: Modifier*) { +final case class UdashCarouselSlide(imgSrc: Url)(caption: Modifier*) { import io.udash.css.CssView._ lazy val render: Node = { @@ -296,4 +296,4 @@ case class UdashCarouselSlide(imgSrc: Url)(caption: Modifier*) { ) ).render } -} \ No newline at end of file +} diff --git a/bootstrap4/.js/src/main/scala/io/udash/bootstrap/dropdown/UdashDropdown.scala b/bootstrap4/.js/src/main/scala/io/udash/bootstrap/dropdown/UdashDropdown.scala index f3246b3f1..cd38843b3 100644 --- a/bootstrap4/.js/src/main/scala/io/udash/bootstrap/dropdown/UdashDropdown.scala +++ b/bootstrap4/.js/src/main/scala/io/udash/bootstrap/dropdown/UdashDropdown.scala @@ -133,13 +133,13 @@ object UdashDropdown { /** Default dropdown elements. */ sealed trait DefaultDropdownItem extends AbstractCase object DefaultDropdownItem { - case class Text(text: String) extends DefaultDropdownItem - case class Link(title: String, url: Url) extends DefaultDropdownItem - case class Button(title: String, clickCallback: () => Any) extends DefaultDropdownItem - case class Header(title: String) extends DefaultDropdownItem - case class Disabled(item: DefaultDropdownItem) extends DefaultDropdownItem - case class Raw(element: Element) extends DefaultDropdownItem - case class Dynamic(factory: Binding.NestedInterceptor => Element) extends DefaultDropdownItem + final case class Text(text: String) extends DefaultDropdownItem + final case class Link(title: String, url: Url) extends DefaultDropdownItem + final case class Button(title: String, clickCallback: () => Any) extends DefaultDropdownItem + final case class Header(title: String) extends DefaultDropdownItem + final case class Disabled(item: DefaultDropdownItem) extends DefaultDropdownItem + final case class Raw(element: Element) extends DefaultDropdownItem + final case class Dynamic(factory: Binding.NestedInterceptor => Element) extends DefaultDropdownItem case object Divider extends DefaultDropdownItem } diff --git a/core/.js/src/main/scala/io/udash/bindings/Bindings.scala b/core/.js/src/main/scala/io/udash/bindings/Bindings.scala index 6516295ac..7a4ee5548 100644 --- a/core/.js/src/main/scala/io/udash/bindings/Bindings.scala +++ b/core/.js/src/main/scala/io/udash/bindings/Bindings.scala @@ -1,14 +1,15 @@ package io.udash.bindings -import com.avsystem.commons._ +import com.avsystem.commons.* import io.udash.bindings.Bindings.{AttrOps, AttrPairOps, HasCssName, PropertyOps} -import io.udash.bindings.modifiers._ +import io.udash.bindings.modifiers.* import io.udash.properties.seq.ReadableSeqProperty import io.udash.properties.single.ReadableProperty -import org.scalajs.dom._ +import org.scalajs.dom.* import scalatags.JsDom import scalatags.generic.{Attr, AttrPair, AttrValue, Modifier} +import scala.annotation.nowarn import scala.scalajs.js trait Bindings { @@ -28,6 +29,7 @@ trait Bindings { implicit def seqFromNode(el: Node): Seq[Node] = Seq(el) implicit def seqFromElement(el: Element): Seq[Element] = Seq(el) + @nowarn("msg=Implicit parameters") implicit def seqNodeFromOpt[T](el: Opt[T])(implicit ev: T => Modifier[Element]): Modifier[Element] = new JsDom.all.SeqNode(el.toSeq) diff --git a/core/.js/src/main/scala/io/udash/bindings/modifiers/package.scala b/core/.js/src/main/scala/io/udash/bindings/modifiers/package.scala index f7317399f..98f36da0b 100644 --- a/core/.js/src/main/scala/io/udash/bindings/modifiers/package.scala +++ b/core/.js/src/main/scala/io/udash/bindings/modifiers/package.scala @@ -3,7 +3,7 @@ package io.udash.bindings import org.scalajs.dom.Node package object modifiers { - implicit class ElementExts(private val el: Node) extends AnyVal { + implicit final class ElementExts(private val el: Node) extends AnyVal { def replaceChildren(oldChildren: Seq[Node], newChildren: Seq[Node]): Unit = { if (oldChildren == null || oldChildren.isEmpty) newChildren.foreach(el.appendChild) else { diff --git a/core/.js/src/main/scala/io/udash/core/Definitions.scala b/core/.js/src/main/scala/io/udash/core/Definitions.scala index 781734e76..84852577a 100644 --- a/core/.js/src/main/scala/io/udash/core/Definitions.scala +++ b/core/.js/src/main/scala/io/udash/core/Definitions.scala @@ -7,7 +7,7 @@ import scalatags.generic.Modifier /** * Url wrapper - just for avoiding strings. */ -case class Url(value: String) extends AnyVal +final case class Url(value: String) extends AnyVal object Url extends HasModelPropertyCreator[Url] /** diff --git a/core/.js/src/test/scala/io/udash/testing/TestState.scala b/core/.js/src/test/scala/io/udash/testing/TestState.scala index 72bfa3a74..2f6d4cf14 100644 --- a/core/.js/src/test/scala/io/udash/testing/TestState.scala +++ b/core/.js/src/test/scala/io/udash/testing/TestState.scala @@ -8,8 +8,8 @@ sealed abstract class TestState(val parentState: Option[ContainerTestState]) ext sealed abstract class ContainerTestState(parentState: Option[ContainerTestState]) extends TestState(parentState) sealed abstract class FinalTestState(parentState: Option[ContainerTestState]) extends TestState(parentState) -case class RootState(sth: Option[Int]) extends ContainerTestState(None) -case class ClassState(arg: String, arg2: Int) extends FinalTestState(Some(RootState(None))) +final case class RootState(sth: Option[Int]) extends ContainerTestState(None) +final case class ClassState(arg: String, arg2: Int) extends FinalTestState(Some(RootState(None))) case object ObjectState extends ContainerTestState(Some(RootState(None))) case object ThrowExceptionState extends ContainerTestState(Some(RootState(None))) case object NextObjectState extends FinalTestState(Some(ObjectState)) diff --git a/core/.js/src/test/scala/manual/PropertyErrorManualTest.scala b/core/.js/src/test/scala/manual/PropertyErrorManualTest.scala index 05155d63d..3fc7d9c4c 100644 --- a/core/.js/src/test/scala/manual/PropertyErrorManualTest.scala +++ b/core/.js/src/test/scala/manual/PropertyErrorManualTest.scala @@ -58,7 +58,7 @@ object PropertyErrorManualTest { trait B { def c: Seq[C] } - case class C(d: D) + final case class C(d: D) trait D { def errorField: ClassicClass } diff --git a/core/src/main/scala/io/udash/properties/Properties.scala b/core/src/main/scala/io/udash/properties/Properties.scala index 30ab67302..08aa43ae0 100644 --- a/core/src/main/scala/io/udash/properties/Properties.scala +++ b/core/src/main/scala/io/udash/properties/Properties.scala @@ -31,20 +31,20 @@ trait Properties { } object Properties extends Properties { - class Any2Property[A] private[properties](private val value: A) extends AnyVal { + final class Any2Property[A] private[properties](private val value: A) extends AnyVal { def toProperty[B >: A : PropertyCreator]: ReadableProperty[B] = PropertyCreator[B].newImmutableProperty(value) def toModelProperty[B >: A : ModelPropertyCreator]: ReadableModelProperty[B] = ModelPropertyCreator[B].newImmutableProperty(value) } - class Any2SeqProperty[A] private[properties](private val value: Seq[A]) extends AnyVal { + final class Any2SeqProperty[A] private[properties](private val value: Seq[A]) extends AnyVal { def toSeqProperty: ReadableSeqProperty[A] = new ImmutableSeqProperty[A, Seq](value) } - class PropertySeq2SeqProperty[A] private[properties](private val value: ISeq[ReadableProperty[A]]) extends AnyVal { + final class PropertySeq2SeqProperty[A] private[properties](private val value: ISeq[ReadableProperty[A]]) extends AnyVal { def combineToSeqProperty: ReadableSeqProperty[A] = new PropertySeqCombinedReadableSeqProperty[A](value) } - class BooleanPropertyOps private[properties](private val underlying: Property[Boolean]) extends AnyVal { + final class BooleanPropertyOps private[properties](private val underlying: Property[Boolean]) extends AnyVal { /** Toggles the value of the underlying boolean-backed property. * @param force If true, the value change listeners will be fired even if value didn't change. * */ diff --git a/core/src/test/scala/io/udash/properties/BlankTest.scala b/core/src/test/scala/io/udash/properties/BlankTest.scala index 47467aec7..26510d69f 100644 --- a/core/src/test/scala/io/udash/properties/BlankTest.scala +++ b/core/src/test/scala/io/udash/properties/BlankTest.scala @@ -33,7 +33,7 @@ class BlankTest extends UdashCoreTest { } object BlankTest { - case class Entity(i: Int, s: String) + final case class Entity(i: Int, s: String) object Entity extends HasModelPropertyCreator[Entity] { implicit val default: Blank[Entity] = Blank.Simple(Entity(5, "asd")) } diff --git a/core/src/test/scala/io/udash/properties/HasGenCodecAndModelPropertyCreatorTest.scala b/core/src/test/scala/io/udash/properties/HasGenCodecAndModelPropertyCreatorTest.scala index 7ed7dbf67..f49a011c9 100644 --- a/core/src/test/scala/io/udash/properties/HasGenCodecAndModelPropertyCreatorTest.scala +++ b/core/src/test/scala/io/udash/properties/HasGenCodecAndModelPropertyCreatorTest.scala @@ -24,6 +24,6 @@ class HasGenCodecAndModelPropertyCreatorTest extends UdashCoreTest { } object HasGenCodecAndModelPropertyCreatorTest { - case class Entity(i: Int, s: String, e: Option[Entity]) + final case class Entity(i: Int, s: String, e: Option[Entity]) object Entity extends HasGenCodecAndModelPropertyCreator[Entity] } diff --git a/core/src/test/scala/io/udash/properties/ImmutablePropertyTest.scala b/core/src/test/scala/io/udash/properties/ImmutablePropertyTest.scala index 3190867bb..5c002d9b4 100644 --- a/core/src/test/scala/io/udash/properties/ImmutablePropertyTest.scala +++ b/core/src/test/scala/io/udash/properties/ImmutablePropertyTest.scala @@ -150,9 +150,9 @@ class ImmutablePropertyTest extends UdashCoreTest { } object ImmutablePropertyTest { - case class Nested(s: Nested) + final case class Nested(s: Nested) object Nested extends HasModelPropertyCreator[Nested] - case class ModelEntity(s: String, i: Seq[Int], v: Vector[Int], m: ModelEntity) + final case class ModelEntity(s: String, i: Seq[Int], v: Vector[Int], m: ModelEntity) object ModelEntity extends HasModelPropertyCreator[ModelEntity] } \ No newline at end of file diff --git a/core/src/test/scala/io/udash/properties/PropertyTest.scala b/core/src/test/scala/io/udash/properties/PropertyTest.scala index 4287652a7..803776652 100644 --- a/core/src/test/scala/io/udash/properties/PropertyTest.scala +++ b/core/src/test/scala/io/udash/properties/PropertyTest.scala @@ -1436,7 +1436,7 @@ class PropertyTest extends UdashCoreTest { } private object ReqModels { - case class Simple(i: Int, s: Simple) + final case class Simple(i: Int, s: Simple) object Simple extends HasModelPropertyCreator[Simple] trait ReqT { @@ -1444,6 +1444,6 @@ private object ReqModels { } object ReqT extends HasModelPropertyCreator[ReqT] - case class SimpleSeq(i: Seq[SimpleSeq], s: SimpleSeq) + final case class SimpleSeq(i: Seq[SimpleSeq], s: SimpleSeq) object SimpleSeq extends HasModelPropertyCreator[SimpleSeq] } diff --git a/css/src/main/scala/io/udash/css/CssBase.scala b/css/src/main/scala/io/udash/css/CssBase.scala index 53126fc8b..a7582ff68 100644 --- a/css/src/main/scala/io/udash/css/CssBase.scala +++ b/css/src/main/scala/io/udash/css/CssBase.scala @@ -188,12 +188,12 @@ trait CssBase { } object CssBase { - class AnimationNameExt(private val n: Attrs.animationName.type) extends AnyVal { + final class AnimationNameExt(private val n: Attrs.animationName.type) extends AnyVal { def apply(s: CssStyle): AV = AV(n.attr, s.classNames.mkString(" ")) } - class FontFamilyExt(private val n: Attrs.fontFamily.type) extends AnyVal { + final class FontFamilyExt(private val n: Attrs.fontFamily.type) extends AnyVal { def apply(s: CssStyle): AV = AV(n.attr, s.classNames.mkString(" ")) } diff --git a/css/src/main/scala/io/udash/css/CssStyle.scala b/css/src/main/scala/io/udash/css/CssStyle.scala index 1d022fa85..0234b6881 100644 --- a/css/src/main/scala/io/udash/css/CssStyle.scala +++ b/css/src/main/scala/io/udash/css/CssStyle.scala @@ -9,15 +9,19 @@ sealed trait CssStyle { def commonPrefixClass: Option[String] = None def classNames: Seq[String] = commonPrefixClass.toList :+ className } -case class CssStyleName(className: String) extends CssStyle -case class CssPrefixedStyleName(prefixClass: String, actualClassSuffix: String) extends CssStyle { + +final case class CssStyleName(className: String) extends CssStyle + +final case class CssPrefixedStyleName(prefixClass: String, actualClassSuffix: String) extends CssStyle { val className = s"$prefixClass-$actualClassSuffix" override val commonPrefixClass: Option[String] = Some(prefixClass) } -case class CssStyleNameWithSharedCompanion(companionClass: String, commonPrefix: String, className: String) extends CssStyle { + +final case class CssStyleNameWithSharedCompanion(companionClass: String, commonPrefix: String, className: String) extends CssStyle { override val commonPrefixClass: Option[String] = Some(commonPrefix) override def classNames: Seq[String] = Seq(companionClass, className) } -case class CssStyleImpl(className: String, impl: StyleS) extends CssStyle -case class CssKeyframes(className: String, steps: Seq[(Double, StyleS)]) extends CssStyle -case class CssFontFace(className: String, font: FontFace[Option[String]]) extends CssStyle + +final case class CssStyleImpl(className: String, impl: StyleS) extends CssStyle +final case class CssKeyframes(className: String, steps: Seq[(Double, StyleS)]) extends CssStyle +final case class CssFontFace(className: String, font: FontFace[Option[String]]) extends CssStyle diff --git a/guide/commons/.js/src/main/scala/io/udash/web/commons/views/ImageFactory.scala b/guide/commons/.js/src/main/scala/io/udash/web/commons/views/ImageFactory.scala index adbdd3b28..180abb8f3 100644 --- a/guide/commons/.js/src/main/scala/io/udash/web/commons/views/ImageFactory.scala +++ b/guide/commons/.js/src/main/scala/io/udash/web/commons/views/ImageFactory.scala @@ -40,4 +40,4 @@ object SVG { } } -case class Size(width: Int, height: Int) \ No newline at end of file +final case class Size(width: Int, height: Int) diff --git a/guide/guide/.js/src/main/scala/io/udash/web/guide/RoutingStatesDef.scala b/guide/guide/.js/src/main/scala/io/udash/web/guide/RoutingStatesDef.scala index b7123b248..1fc76593c 100644 --- a/guide/guide/.js/src/main/scala/io/udash/web/guide/RoutingStatesDef.scala +++ b/guide/guide/.js/src/main/scala/io/udash/web/guide/RoutingStatesDef.scala @@ -49,7 +49,7 @@ case object FrontendState extends ContainerRoutingState(Some(ContentState)) case object FrontendIntroState extends RoutingState(Some(FrontendState)) -case class FrontendRoutingState(additionalArgument: Option[String]) extends RoutingState(Some(FrontendState)) +final case class FrontendRoutingState(additionalArgument: Option[String]) extends RoutingState(Some(FrontendState)) case object FrontendMVPState extends RoutingState(Some(FrontendState)) diff --git a/guide/guide/.js/src/main/scala/io/udash/web/guide/components/GuideMenu.scala b/guide/guide/.js/src/main/scala/io/udash/web/guide/components/GuideMenu.scala index f51b2ef35..3999f8f5f 100644 --- a/guide/guide/.js/src/main/scala/io/udash/web/guide/components/GuideMenu.scala +++ b/guide/guide/.js/src/main/scala/io/udash/web/guide/components/GuideMenu.scala @@ -18,8 +18,8 @@ sealed trait MenuEntry { def name: String } -case class MenuContainer(override val name: String, children: Seq[MenuLink]) extends MenuEntry -case class MenuLink(override val name: String, state: RoutingState, fragment: OptArg[String] = OptArg.Empty) extends MenuEntry +final case class MenuContainer(override val name: String, children: Seq[MenuLink]) extends MenuEntry +final case class MenuLink(override val name: String, state: RoutingState, fragment: OptArg[String] = OptArg.Empty) extends MenuEntry class GuideMenu(entries: Seq[MenuEntry], property: Property[String]) { diff --git a/guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/IntroFormDemo.scala b/guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/IntroFormDemo.scala index 5067fc6fe..7a1c14a22 100644 --- a/guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/IntroFormDemo.scala +++ b/guide/guide/.js/src/main/scala/io/udash/web/guide/views/frontend/demos/IntroFormDemo.scala @@ -7,7 +7,7 @@ import scalatags.JsDom.all._ object IntroFormDemo extends AutoDemo { - case class IntroFormDemoModel(minimum: Int, between: Int, maximum: Int) + final case class IntroFormDemoModel(minimum: Int, between: Int, maximum: Int) object IntroFormDemoModel extends HasModelPropertyCreator[IntroFormDemoModel] diff --git a/guide/guide/.js/src/main/scala/io/udash/web/guide/views/rpc/demos/ExceptionsDemoComponent.scala b/guide/guide/.js/src/main/scala/io/udash/web/guide/views/rpc/demos/ExceptionsDemoComponent.scala index 3db2ae1ae..6a91d2d71 100644 --- a/guide/guide/.js/src/main/scala/io/udash/web/guide/views/rpc/demos/ExceptionsDemoComponent.scala +++ b/guide/guide/.js/src/main/scala/io/udash/web/guide/views/rpc/demos/ExceptionsDemoComponent.scala @@ -16,10 +16,10 @@ import scala.concurrent.duration.DurationLong import scala.language.postfixOps import scala.util.{Failure, Success} -case class ExceptionsDemoModel( +final case class ExceptionsDemoModel( exception: String, translatableException: TranslationKey0, - unknownException: String + unknownException: String, ) object ExceptionsDemoModel extends HasModelPropertyCreator[ExceptionsDemoModel] diff --git a/guide/shared/src/main/scala/io/udash/web/guide/GuideExceptions.scala b/guide/shared/src/main/scala/io/udash/web/guide/GuideExceptions.scala index ab67c6990..f9442fce6 100644 --- a/guide/shared/src/main/scala/io/udash/web/guide/GuideExceptions.scala +++ b/guide/shared/src/main/scala/io/udash/web/guide/GuideExceptions.scala @@ -6,8 +6,8 @@ import io.udash.i18n.TranslationKey0 import io.udash.rpc.serialization.{DefaultExceptionCodecRegistry, ExceptionCodecRegistry} object GuideExceptions { - case class ExampleException(msg: String) extends Exception(msg) - case class TranslatableExampleException(trKey: TranslationKey0) extends Exception + final case class ExampleException(msg: String) extends Exception(msg) + final case class TranslatableExampleException(trKey: TranslationKey0) extends Exception val registry: ExceptionCodecRegistry = (new DefaultExceptionCodecRegistry).setup { registry => registry.register(GenCodec.materialize[ExampleException]) diff --git a/guide/shared/src/main/scala/io/udash/web/guide/demos/activity/Call.scala b/guide/shared/src/main/scala/io/udash/web/guide/demos/activity/Call.scala index 6ec5ed263..315b3533e 100644 --- a/guide/shared/src/main/scala/io/udash/web/guide/demos/activity/Call.scala +++ b/guide/shared/src/main/scala/io/udash/web/guide/demos/activity/Call.scala @@ -2,7 +2,7 @@ package io.udash.web.guide.demos.activity import com.avsystem.commons.serialization.HasGenCodec -case class Call(rpcName: String, method: String, args: Seq[String]) { +final case class Call(rpcName: String, method: String, args: Seq[String]) { override def toString: String = s"$rpcName.$method args: ${args.mkString("[", ", ", "]")}" } object Call extends HasGenCodec[Call] \ No newline at end of file diff --git a/guide/shared/src/main/scala/io/udash/web/guide/demos/rest/RestExampleClass.scala b/guide/shared/src/main/scala/io/udash/web/guide/demos/rest/RestExampleClass.scala index 81848c625..57b91817a 100644 --- a/guide/shared/src/main/scala/io/udash/web/guide/demos/rest/RestExampleClass.scala +++ b/guide/shared/src/main/scala/io/udash/web/guide/demos/rest/RestExampleClass.scala @@ -2,8 +2,8 @@ package io.udash.web.guide.demos.rest import io.udash.rest.RestDataCompanion -case class RestExampleClass(i: Int, s: String, inner: InnerClass) +final case class RestExampleClass(i: Int, s: String, inner: InnerClass) object RestExampleClass extends RestDataCompanion[RestExampleClass] -case class InnerClass(d: Double, s: String) +final case class InnerClass(d: Double, s: String) object InnerClass extends RestDataCompanion[InnerClass] \ No newline at end of file diff --git a/guide/shared/src/main/scala/io/udash/web/guide/demos/rpc/GenCodecServerRPC.scala b/guide/shared/src/main/scala/io/udash/web/guide/demos/rpc/GenCodecServerRPC.scala index c627d5c5c..0bd6878cf 100644 --- a/guide/shared/src/main/scala/io/udash/web/guide/demos/rpc/GenCodecServerRPC.scala +++ b/guide/shared/src/main/scala/io/udash/web/guide/demos/rpc/GenCodecServerRPC.scala @@ -6,7 +6,7 @@ import io.udash.rpc._ import scala.concurrent.Future object GenCodecServerRPC extends DefaultServerRpcCompanion[GenCodecServerRPC] { - case class DemoCaseClass(i: Int, s: String, intAsDouble: Double) + final case class DemoCaseClass(i: Int, s: String, intAsDouble: Double) object DemoCaseClass extends HasGenCodec[DemoCaseClass] sealed trait Fruit diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 253516d6f..fdc0271df 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -14,7 +14,7 @@ object Dependencies { val scalaCssVersion = "1.0.0" val servletVersion = "4.0.1" - val avsCommonsVersion = "2.22.0" + val avsCommonsVersion = "2.23.0" val atmosphereJSVersion = "3.1.3" val atmosphereVersion = "2.7.15" diff --git a/rest/.jvm/src/test/scala/io/udash/rest/examples/UserApi.scala b/rest/.jvm/src/test/scala/io/udash/rest/examples/UserApi.scala index d3c47601d..89181b980 100644 --- a/rest/.jvm/src/test/scala/io/udash/rest/examples/UserApi.scala +++ b/rest/.jvm/src/test/scala/io/udash/rest/examples/UserApi.scala @@ -12,12 +12,12 @@ trait UserApi { } object UserApi extends DefaultRestApiCompanion[UserApi] -case class UserId(id: Long) extends AnyVal +final case class UserId(id: Long) extends AnyVal object UserId extends RestDataWrapperCompanion[Long, UserId] @description("Representation of system user") @example(User(UserId(0), "Fred")) -case class User(id: UserId, @description("User name") name: String) +final case class User(id: UserId, @description("User name") name: String) object User extends RestDataCompanion[User] trait GroupApi diff --git a/rest/src/main/scala/io/udash/rest/openapi/OpenApi.scala b/rest/src/main/scala/io/udash/rest/openapi/OpenApi.scala index e839e5e42..87c054048 100644 --- a/rest/src/main/scala/io/udash/rest/openapi/OpenApi.scala +++ b/rest/src/main/scala/io/udash/rest/openapi/OpenApi.scala @@ -308,7 +308,7 @@ object Schema extends HasGenObjectCodec[Schema] { Schema(allOf = List(ref), nullable = true) } - implicit class RefOrOps(private val refOrSchema: RefOr[Schema]) extends AnyVal { + implicit final class RefOrOps(private val refOrSchema: RefOr[Schema]) extends AnyVal { /** * Transforms a potential schema reference into an actual [[Schema]] by wrapping the reference into * `allOf` property of the new schema, e.g. `{"$$ref": "#/components/schemas/Entity"}` becomes diff --git a/rest/src/main/scala/io/udash/rest/raw/RestRequest.scala b/rest/src/main/scala/io/udash/rest/raw/RestRequest.scala index eafaaf09e..e2994af40 100644 --- a/rest/src/main/scala/io/udash/rest/raw/RestRequest.scala +++ b/rest/src/main/scala/io/udash/rest/raw/RestRequest.scala @@ -23,14 +23,14 @@ final case class RestParameters( @multi @tagged[Path] path: List[PlainValue] = Nil, @multi @tagged[Header] @allowOptional headers: IMapping[PlainValue] = IMapping.empty, @multi @tagged[Query] @allowOptional query: Mapping[PlainValue] = Mapping.empty, - @multi @tagged[Cookie] @allowOptional cookies: Mapping[PlainValue] = Mapping.empty + @multi @tagged[Cookie] @allowOptional cookies: Mapping[PlainValue] = Mapping.empty, ) { def append(method: RestMethodMetadata[_], otherParameters: RestParameters): RestParameters = RestParameters( path ::: method.applyPathParams(otherParameters.path), headers ++ otherParameters.headers, query ++ otherParameters.query, - cookies ++ otherParameters.cookies + cookies ++ otherParameters.cookies, ) def path(values: String*): RestParameters = @@ -49,7 +49,7 @@ object RestParameters { final val Empty = RestParameters() } -case class HttpErrorException(code: Int, payload: HttpBody = HttpBody.Empty, cause: Throwable = null) +final case class HttpErrorException(code: Int, payload: HttpBody = HttpBody.Empty, cause: Throwable = null) extends RuntimeException(s"HTTP ERROR $code${payload.textualContentOpt.fold("")(p => s": $p")}", cause) with NoStackTrace { def toResponse: RestResponse = RestResponse(code, IMapping.empty, payload) } diff --git a/rest/src/main/scala/io/udash/rest/raw/RestResponse.scala b/rest/src/main/scala/io/udash/rest/raw/RestResponse.scala index 836d0dbbb..3d34d696f 100644 --- a/rest/src/main/scala/io/udash/rest/raw/RestResponse.scala +++ b/rest/src/main/scala/io/udash/rest/raw/RestResponse.scala @@ -40,14 +40,14 @@ object RestResponse extends RestResponseLowPrio { def plain(status: Int, message: OptArg[String] = OptArg.Empty): RestResponse = RestResponse(status, IMapping.empty, HttpBody.plain(message)) - class LazyOps(private val resp: () => RestResponse) extends AnyVal { + final class LazyOps(private val resp: () => RestResponse) extends AnyVal { def recoverHttpError: RestResponse = try resp() catch { case e: HttpErrorException => e.toResponse } } implicit def lazyOps(resp: => RestResponse): LazyOps = new LazyOps(() => resp) - implicit class TaskOps(private val asyncResp: Task[RestResponse]) extends AnyVal { + implicit final class TaskOps(private val asyncResp: Task[RestResponse]) extends AnyVal { def recoverHttpError: Task[RestResponse] = asyncResp.onErrorRecover { case e: HttpErrorException => e.toResponse @@ -171,14 +171,14 @@ object StreamedRestResponse extends StreamedRestResponseLowPrio { def fromHttpError(error: HttpErrorException): StreamedRestResponse = StreamedRestResponse(error.code, IMapping.empty, StreamedBody.fromHttpBody(error.payload)) - class LazyOps(private val resp: () => StreamedRestResponse) extends AnyVal { + final class LazyOps(private val resp: () => StreamedRestResponse) extends AnyVal { def recoverHttpError: StreamedRestResponse = try resp() catch { case e: HttpErrorException => StreamedRestResponse.fromHttpError(e) } } implicit def lazyOps(resp: => StreamedRestResponse): LazyOps = new LazyOps(() => resp) - implicit class TaskOps(private val asyncResp: Task[StreamedRestResponse]) extends AnyVal { + implicit final class TaskOps(private val asyncResp: Task[StreamedRestResponse]) extends AnyVal { def recoverHttpError: Task[StreamedRestResponse] = asyncResp.onErrorRecover { case e: HttpErrorException => StreamedRestResponse.fromHttpError(e) diff --git a/rest/src/main/scala/io/udash/rest/util/WithHeaders.scala b/rest/src/main/scala/io/udash/rest/util/WithHeaders.scala index c8d8edb82..b309c2def 100644 --- a/rest/src/main/scala/io/udash/rest/util/WithHeaders.scala +++ b/rest/src/main/scala/io/udash/rest/util/WithHeaders.scala @@ -13,7 +13,7 @@ import io.udash.rest.raw.{HttpBody, IMapping, PlainValue, RestResponse} * If you want to include this information into OpenAPI definition for method that returns `WithHeaders`, * you may use [[io.udash.rest.adjustResponse adjustResponse]] on it. */ -case class WithHeaders[+T](value: T, headers: ISeq[(String, String)]) +final case class WithHeaders[+T](value: T, headers: ISeq[(String, String)]) object WithHeaders { implicit def asResponse[T](implicit wrapped: AsRaw[HttpBody, T]): AsRaw[RestResponse, WithHeaders[T]] = { case WithHeaders(value, headers) => diff --git a/rest/src/test/scala/io/udash/rest/CirceRestApiTest.scala b/rest/src/test/scala/io/udash/rest/CirceRestApiTest.scala index 31406349c..44ef2ee30 100644 --- a/rest/src/test/scala/io/udash/rest/CirceRestApiTest.scala +++ b/rest/src/test/scala/io/udash/rest/CirceRestApiTest.scala @@ -79,10 +79,10 @@ abstract class HasCirceCustomizedCodec[T]( implicit final lazy val decoder: Decoder[T] = instances((), this).decoder(nameTransform, useDefaults, discriminator) } -case class CirceAddress(city: String, zip: String) +final case class CirceAddress(city: String, zip: String) object CirceAddress extends HasCirceCustomizedCodec[CirceAddress](_.toUpperCase) -case class CircePerson(id: Long, name: String, address: Option[CirceAddress] = None) +final case class CircePerson(id: Long, name: String, address: Option[CirceAddress] = None) object CircePerson extends HasCirceCodec[CircePerson] abstract class CirceRestApiCompanion[T]( diff --git a/rest/src/test/scala/io/udash/rest/RestTestApi.scala b/rest/src/test/scala/io/udash/rest/RestTestApi.scala index 64ad06b33..2f217fd28 100644 --- a/rest/src/test/scala/io/udash/rest/RestTestApi.scala +++ b/rest/src/test/scala/io/udash/rest/RestTestApi.scala @@ -16,7 +16,7 @@ import scala.concurrent.Future import scala.concurrent.duration.* @description("Entity identifier") -case class RestEntityId(value: String) extends AnyVal +final case class RestEntityId(value: String) extends AnyVal object RestEntityId extends RestDataWrapperCompanion[String, RestEntityId] @name("RestEntityEnumCustom") @@ -42,7 +42,7 @@ object BaseEntity extends RestDataCompanion[BaseEntity] object FlatBaseEntity extends RestDataCompanion[FlatBaseEntity] @description("REST entity") -case class RestEntity( +final case class RestEntity( @description("entity id") id: RestEntityId, @whenAbsent("anonymous") name: String = whenAbsent.value, @description("recursive optional subentity") subentity: OptArg[RestEntity] = OptArg.Empty, @@ -52,11 +52,11 @@ case class RestEntity( ) extends FlatBaseEntity object RestEntity extends RestDataCompanion[RestEntity] -case class RestOtherEntity(fuu: Boolean, kek: List[String]) extends FlatBaseEntity +final case class RestOtherEntity(fuu: Boolean, kek: List[String]) extends FlatBaseEntity case object SingletonEntity extends FlatBaseEntity -case class CustomResp(value: String) +final case class CustomResp(value: String) object CustomResp { implicit val asResponse: AsRawReal[RestResponse, CustomResp] = AsRawReal.create( cr => RestResponse(200, IMapping.create("X-Value" -> PlainValue(cr.value)), HttpBody.plain("Yes")), @@ -77,10 +77,10 @@ object CustomResp { } @description("binary bytes") -case class Bytes(bytes: Array[Byte]) extends AnyVal +final case class Bytes(bytes: Array[Byte]) extends AnyVal object Bytes extends RestDataWrapperCompanion[Array[Byte], Bytes] -case class ThirdParty(thing: Int) +final case class ThirdParty(thing: Int) object ThirdPartyImplicits { implicit val thirdPartyCodec: GenCodec[ThirdParty] = GenCodec.materialize[ThirdParty] @@ -88,10 +88,10 @@ object ThirdPartyImplicits { RestStructure.materialize[ThirdParty].standaloneSchema } -case class HasThirdParty(dur: ThirdParty) +final case class HasThirdParty(dur: ThirdParty) object HasThirdParty extends RestDataCompanionWithDeps[ThirdPartyImplicits.type, HasThirdParty] -case class ErrorWrapper[T](error: T) +final case class ErrorWrapper[T](error: T) object ErrorWrapper extends HasPolyGenCodec[ErrorWrapper] trait RestTestApi { diff --git a/rest/src/test/scala/io/udash/rest/TestRESTRecord.scala b/rest/src/test/scala/io/udash/rest/TestRESTRecord.scala index 02f0a6591..994dbc465 100644 --- a/rest/src/test/scala/io/udash/rest/TestRESTRecord.scala +++ b/rest/src/test/scala/io/udash/rest/TestRESTRecord.scala @@ -1,5 +1,5 @@ package io.udash package rest -case class TestRESTRecord(id: Option[Int], s: String) +final case class TestRESTRecord(id: Option[Int], s: String) object TestRESTRecord extends RestDataCompanion[TestRESTRecord] \ No newline at end of file diff --git a/rest/src/test/scala/io/udash/rest/openapi/RestSchemaTest.scala b/rest/src/test/scala/io/udash/rest/openapi/RestSchemaTest.scala index 18e051c05..183591cfd 100644 --- a/rest/src/test/scala/io/udash/rest/openapi/RestSchemaTest.scala +++ b/rest/src/test/scala/io/udash/rest/openapi/RestSchemaTest.scala @@ -23,7 +23,7 @@ object Dependency { } @description("kejs klass") -case class KejsKlass( +final case class KejsKlass( @name("integer") @customWa(42) int: Int, @description("serious dependency") dep: Dependency, @description("optional thing") @optionalParam opty: Opt[String] = Opt("defaultThatMustBeIgnored"), @@ -32,13 +32,13 @@ case class KejsKlass( object KejsKlass extends RestDataCompanion[KejsKlass] @description("wrapped string") -@transparent case class Wrap(str: String) +@transparent final case class Wrap(str: String) object Wrap extends RestDataCompanion[Wrap] -case class PlainGenericCC[+T](thing: T) +final case class PlainGenericCC[+T](thing: T) object PlainGenericCC extends PolyRestDataCompanion[PlainGenericCC] -case class GenCC[+T >: Null](@customWa[T](null) value: T) +final case class GenCC[+T >: Null](@customWa[T](null) value: T) object GenCC extends RestDataCompanion[GenCC[String]] final class KeyEnum(implicit enumCtx: EnumCtx) extends AbstractValueEnum @@ -48,7 +48,7 @@ object KeyEnum extends AbstractValueEnumCompanion[KeyEnum] { @flatten("tpe") sealed trait HierarchyRoot[+T] -case class HierarchyCase[+T](value: T) extends HierarchyRoot[T] +final case class HierarchyCase[+T](value: T) extends HierarchyRoot[T] object HierarchyCase { implicit val stringRestSchema: RestSchema[HierarchyCase[String]] = RestStructure.materialize[HierarchyCase[String]] match { @@ -65,8 +65,8 @@ object HierarchyRoot { @flatten("case") sealed trait FullyQualifiedHierarchy object FullyQualifiedHierarchy extends RestDataCompanionWithDeps[FullyQualifiedNames.type, FullyQualifiedHierarchy] { - case class Foo(str: String) extends FullyQualifiedHierarchy - case class Bar(int: Int) extends FullyQualifiedHierarchy + final case class Foo(str: String) extends FullyQualifiedHierarchy + final case class Bar(int: Int) extends FullyQualifiedHierarchy object Bar extends RestDataCompanionWithDeps[FullyQualifiedNames.type, Bar] case object Baz extends FullyQualifiedHierarchy } @@ -76,15 +76,15 @@ sealed trait CustomSchemaNameHierarchy object CustomSchemaNameHierarchy extends RestDataCompanion[CustomSchemaNameHierarchy] { // annotation value should be used as schema name, but NOT as type discriminator value @schemaName("CustomSchemaName123") - case class CustomSchemaName(str: String) extends CustomSchemaNameHierarchy + final case class CustomSchemaName(str: String) extends CustomSchemaNameHierarchy // annotation value should be used as both schema name and type discriminator value @name("CustomName123") - case class CustomName(str: String) extends CustomSchemaNameHierarchy + final case class CustomName(str: String) extends CustomSchemaNameHierarchy // @schemaName annotation should be used as schema name, @name annotation should be used only as type discriminator value @schemaName("CustomSchemaNameBoth") @name("CustomNameBoth123") - case class CustomNameBoth(str: String) extends CustomSchemaNameHierarchy + final case class CustomNameBoth(str: String) extends CustomSchemaNameHierarchy } class RestSchemaTest extends AnyFunSuite { diff --git a/rest/src/test/scala/io/udash/rest/openapi/openapiDependencies.scala b/rest/src/test/scala/io/udash/rest/openapi/openapiDependencies.scala index c307f261a..a815d6341 100644 --- a/rest/src/test/scala/io/udash/rest/openapi/openapiDependencies.scala +++ b/rest/src/test/scala/io/udash/rest/openapi/openapiDependencies.scala @@ -49,7 +49,7 @@ class descriptionKey(key: String, @infer i18n: I18N = infer.value) extends description(i18n.t(key)) @descriptionKey("person.desc") -case class Person( +final case class Person( @descriptionKey("name.desc") name: String ) object Person extends I18NRestDataCompanion[Person] diff --git a/rest/src/test/scala/io/udash/rest/raw/RawRestTest.scala b/rest/src/test/scala/io/udash/rest/raw/RawRestTest.scala index 16e71ee79..ec0c976f2 100644 --- a/rest/src/test/scala/io/udash/rest/raw/RawRestTest.scala +++ b/rest/src/test/scala/io/udash/rest/raw/RawRestTest.scala @@ -15,15 +15,15 @@ import org.scalatest.concurrent.ScalaFutures import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers -case class UserId(id: String) extends AnyVal { +final case class UserId(id: String) extends AnyVal { override def toString: String = id } object UserId extends RestDataWrapperCompanion[String, UserId] -case class User(id: UserId, name: String) +final case class User(id: UserId, name: String) object User extends RestDataCompanion[User] -case class NonBlankString(str: String) { +final case class NonBlankString(str: String) { if (str.isBlank) { throw HttpErrorException(400, HttpBody.plain("this stuff is blank")) } diff --git a/rpc/.js/src/main/scala/io/udash/rpc/internals/UsesServerRPC.scala b/rpc/.js/src/main/scala/io/udash/rpc/internals/UsesServerRPC.scala index 9a5c86417..0b70f99e9 100644 --- a/rpc/.js/src/main/scala/io/udash/rpc/internals/UsesServerRPC.scala +++ b/rpc/.js/src/main/scala/io/udash/rpc/internals/UsesServerRPC.scala @@ -1,7 +1,7 @@ package io.udash.rpc.internals -import com.avsystem.commons.SharedExtensions._ -import io.udash.rpc._ +import com.avsystem.commons.SharedExtensions.* +import io.udash.rpc.* import io.udash.utils.{CallbacksHandler, Registration} import org.scalajs.dom @@ -96,5 +96,5 @@ private[rpc] trait UsesServerRPC[ServerRPCType] extends UsesRemoteRPC[ServerRPCT } object UsesServerRPC { - case class CallTimeout(callTimeout: Duration) extends RuntimeException(s"Response missing after $callTimeout.") + final case class CallTimeout(callTimeout: Duration) extends RuntimeException(s"Response missing after $callTimeout.") } diff --git a/rpc/.jvm/src/main/scala/io/udash/rpc/DefaultClientRPC.scala b/rpc/.jvm/src/main/scala/io/udash/rpc/DefaultClientRPC.scala index a35141405..086bb675b 100644 --- a/rpc/.jvm/src/main/scala/io/udash/rpc/DefaultClientRPC.scala +++ b/rpc/.jvm/src/main/scala/io/udash/rpc/DefaultClientRPC.scala @@ -13,7 +13,7 @@ import scala.concurrent.ExecutionContext */ sealed trait ClientRPCTarget case object AllClients extends ClientRPCTarget -case class ClientId(id: String) extends ClientRPCTarget +final case class ClientId(id: String) extends ClientRPCTarget abstract class ClientRPC[ClientRPCType](target: ClientRPCTarget) (implicit ec: ExecutionContext) extends UsesClientRPC[ClientRPCType] { diff --git a/rpc/.jvm/src/test/scala/io/udash/rpc/DefaultExceptionCodecRegistryTest.scala b/rpc/.jvm/src/test/scala/io/udash/rpc/DefaultExceptionCodecRegistryTest.scala index f7611d372..63ef3f9fb 100644 --- a/rpc/.jvm/src/test/scala/io/udash/rpc/DefaultExceptionCodecRegistryTest.scala +++ b/rpc/.jvm/src/test/scala/io/udash/rpc/DefaultExceptionCodecRegistryTest.scala @@ -6,11 +6,11 @@ import io.udash.testing.UdashSharedTest private sealed trait RootTrait extends Throwable private sealed trait SubTrait extends RootTrait -private case class SubTraitImpl() extends SubTrait +private final case class SubTraitImpl() extends SubTrait private sealed trait SealedHierarchy extends Throwable -private case class SealedHierarchyA(a: Int) extends SealedHierarchy -private case class SealedHierarchyB(b: Double) extends SealedHierarchy +private final case class SealedHierarchyA(a: Int) extends SealedHierarchy +private final case class SealedHierarchyB(b: Double) extends SealedHierarchy class DefaultExceptionCodecRegistryTest extends UdashSharedTest with Utils { val exceptionsRegistry: ExceptionCodecRegistry = new DefaultExceptionCodecRegistry diff --git a/rpc/src/main/scala/io/udash/rpc/rawrpc.scala b/rpc/src/main/scala/io/udash/rpc/rawrpc.scala index 61c18ca52..bc8a739f2 100644 --- a/rpc/src/main/scala/io/udash/rpc/rawrpc.scala +++ b/rpc/src/main/scala/io/udash/rpc/rawrpc.scala @@ -12,11 +12,11 @@ import io.udash.rpc.utils.Logged import scala.annotation.implicitNotFound import scala.concurrent.Future -case class JsonStr(json: String) extends AnyVal +final case class JsonStr(json: String) extends AnyVal object JsonStr { implicit val codec: GenCodec[JsonStr] = GenCodec.create( i => JsonStr(i.readCustom(RawJson).getOrElse(i.readSimple().readString())), - (o, v) => if (!o.writeCustom(RawJson, v.json)) o.writeSimple().writeString(v.json) + (o, v) => if (!o.writeCustom(RawJson, v.json)) o.writeSimple().writeString(v.json), ) implicit def futureAsReal[T](implicit asReal: AsReal[JsonStr, T]): AsReal[Future[JsonStr], Future[T]] = @@ -36,10 +36,10 @@ object JsonStr { ): ImplicitNotFound[AsRaw[Future[JsonStr], Future[T]]] = ImplicitNotFound() } -case class RpcInvocation(@methodName rpcName: String, @multi args: List[JsonStr]) +final case class RpcInvocation(@methodName rpcName: String, @multi args: List[JsonStr]) object RpcInvocation extends HasGenCodec[RpcInvocation] -case class RpcFailure(remoteCause: String, remoteMessage: String) +final case class RpcFailure(remoteCause: String, remoteMessage: String) extends Exception(s"$remoteCause: $remoteMessage") object RpcFailure extends HasGenCodec[RpcFailure] @@ -56,12 +56,12 @@ sealed trait RpcRequest { object RpcRequest extends HasGenCodec[RpcRequest] /** [[RpcRequest]] which returns some value. */ -case class RpcCall(invocation: RpcInvocation, gettersChain: List[RpcInvocation], callId: String) +final case class RpcCall(invocation: RpcInvocation, gettersChain: List[RpcInvocation], callId: String) extends RpcRequest object RpcCall extends HasGenCodec[RpcCall] /** [[RpcRequest]] which returns Unit. */ -case class RpcFire(invocation: RpcInvocation, gettersChain: List[RpcInvocation]) +final case class RpcFire(invocation: RpcInvocation, gettersChain: List[RpcInvocation]) extends RpcRequest with RpcServerMessage object RpcFire extends HasGenCodec[RpcFire] @@ -74,11 +74,11 @@ object RpcResponse { } /** Message containing response for [[RpcCall]]. */ -case class RpcResponseSuccess(response: JsonStr, callId: String) extends RpcResponse +final case class RpcResponseSuccess(response: JsonStr, callId: String) extends RpcResponse /** Message reporting failure of [[RpcCall]]. */ -case class RpcResponseFailure(cause: String, errorMsg: String, callId: String) extends RpcResponse +final case class RpcResponseFailure(cause: String, errorMsg: String, callId: String) extends RpcResponse /** Message reporting exception from [[RpcCall]]. */ -case class RpcResponseException(name: String, exception: Throwable, callId: String) extends RpcResponse +final case class RpcResponseException(name: String, exception: Throwable, callId: String) extends RpcResponse object RpcResponseException { implicit def codec(implicit ecr: ExceptionCodecRegistry): GenCodec[RpcResponseException] = GenCodec.nullableObject( @@ -139,20 +139,20 @@ object ServerRawRpc extends RawRpcCompanion[ServerRawRpc] { } @allowIncomplete -case class ServerRpcMetadata[T]( +final case class ServerRpcMetadata[T]( @reifyName name: String, @multi @rpcMethodMetadata getters: Map[String, GetterMethod[_]], - @multi @rpcMethodMetadata methods: Map[String, RpcMethod[_]] + @multi @rpcMethodMetadata methods: Map[String, RpcMethod[_]], ) object ServerRpcMetadata extends RpcMetadataCompanion[ServerRpcMetadata] @allowIncomplete -case class GetterMethod[T]( +final case class GetterMethod[T]( @infer @checked resultMetadata: ServerRpcMetadata.Lazy[T] ) extends TypedMetadata[T] @allowIncomplete -case class RpcMethod[T]( +final case class RpcMethod[T]( @reifyName name: String, @isAnnotated[Logged] logged: Boolean, ) extends TypedMetadata[T] diff --git a/rpc/src/test/scala/io/udash/rpc/RpcMessagesTest.scala b/rpc/src/test/scala/io/udash/rpc/RpcMessagesTest.scala index 616c006b5..5b317c5e1 100644 --- a/rpc/src/test/scala/io/udash/rpc/RpcMessagesTest.scala +++ b/rpc/src/test/scala/io/udash/rpc/RpcMessagesTest.scala @@ -7,11 +7,11 @@ import io.udash.testing.UdashSharedTest import scala.util.Random -private case class CustomException(error: String, counter: Int) extends Throwable +private final case class CustomException(error: String, counter: Int) extends Throwable private sealed trait SealedExceptions extends Throwable -private case class SealedExceptionsA(a: Int) extends SealedExceptions -private case class SealedExceptionsB(b: Double) extends SealedExceptions +private final case class SealedExceptionsA(a: Int) extends SealedExceptions +private final case class SealedExceptionsB(b: Double) extends SealedExceptions trait RpcMessagesTestScenarios extends UdashSharedTest with Utils { val exceptionsRegistry: ExceptionCodecRegistry = new DefaultExceptionCodecRegistry diff --git a/rpc/src/test/scala/io/udash/rpc/TestRPC.scala b/rpc/src/test/scala/io/udash/rpc/TestRPC.scala index 1c0c1e0f2..485977afb 100644 --- a/rpc/src/test/scala/io/udash/rpc/TestRPC.scala +++ b/rpc/src/test/scala/io/udash/rpc/TestRPC.scala @@ -7,10 +7,10 @@ import io.udash.rpc.utils.Logged import scala.annotation.nowarn import scala.concurrent.Future -case class Record(i: Int, fuu: String) +final case class Record(i: Int, fuu: String) object Record extends HasGenCodec[Record] -case class CustomRPCException(i: Int) extends Throwable +final case class CustomRPCException(i: Int) extends Throwable object CustomRPCException extends HasGenCodec[CustomRPCException] trait RPCMethods { @@ -47,7 +47,7 @@ trait InnerClientRPC { } object InnerClientRPC extends DefaultClientRpcCompanion[InnerClientRPC] -case class External(x: Int) +final case class External(x: Int) object ExternalTypeCodec { implicit val codec: GenCodec[External] = GenCodec.transformed[External, Int](_.x, External.apply) diff --git a/rpc/src/test/scala/io/udash/rpc/types.scala b/rpc/src/test/scala/io/udash/rpc/types.scala index 7ab001970..ff74f5c64 100644 --- a/rpc/src/test/scala/io/udash/rpc/types.scala +++ b/rpc/src/test/scala/io/udash/rpc/types.scala @@ -2,16 +2,16 @@ package io.udash.rpc import com.avsystem.commons.serialization.HasGenCodec -case class TestCC(i: Int, l: Long, intAsDouble: Double, b: Boolean, s: String, list: List[Char]) +final case class TestCC(i: Int, l: Long, intAsDouble: Double, b: Boolean, s: String, list: List[Char]) object TestCC extends HasGenCodec[TestCC] -case class NestedTestCC(i: Int, t: TestCC, t2: TestCC) +final case class NestedTestCC(i: Int, t: TestCC, t2: TestCC) object NestedTestCC extends HasGenCodec[NestedTestCC] -case class DeepNestedTestCC(n: NestedTestCC, l: DeepNestedTestCC) +final case class DeepNestedTestCC(n: NestedTestCC, l: DeepNestedTestCC) object DeepNestedTestCC extends HasGenCodec[DeepNestedTestCC] -case class CompleteItem(unit: Unit, string: String, specialString: String, char: Char, boolean: Boolean, byte: Byte, short: Short, int: Int, +final case class CompleteItem(unit: Unit, string: String, specialString: String, char: Char, boolean: Boolean, byte: Byte, short: Short, int: Int, long: Long, float: Float, double: Double, binary: Array[Byte], list: List[String], set: Set[String], obj: TestCC, map: Map[String, Int]) object CompleteItem extends HasGenCodec[CompleteItem] diff --git a/utils/.js/src/test/scala/io/udash/testing/AsyncUdashSharedTest.scala b/utils/.js/src/test/scala/io/udash/testing/AsyncUdashSharedTest.scala index 334f6a796..db0014be4 100644 --- a/utils/.js/src/test/scala/io/udash/testing/AsyncUdashSharedTest.scala +++ b/utils/.js/src/test/scala/io/udash/testing/AsyncUdashSharedTest.scala @@ -7,6 +7,7 @@ import org.scalatest.{Assertion, Succeeded} import scala.concurrent.{ExecutionContext, Future, Promise} import scala.scalajs.concurrent.JSExecutionContext import scala.scalajs.js.Date +import scala.util.control.NonFatal import scala.util.{Failure, Success} trait AsyncUdashSharedTest extends AsyncUdashSharedTestBase { @@ -23,7 +24,7 @@ trait AsyncUdashSharedTest extends AsyncUdashSharedTestBase { code p.complete(Success(Succeeded)) } catch { - case ex: Throwable => + case NonFatal(ex) => lastEx = Some(ex) startTest() }