Skip to content

Commit

Permalink
Enable wartremover
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Feb 3, 2024
1 parent a16ed20 commit 14a3045
Show file tree
Hide file tree
Showing 38 changed files with 84 additions and 72 deletions.
2 changes: 2 additions & 0 deletions backend/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import ProjectKeys._
import ch.epfl.scala.sbtmissinglink.MissingLinkPlugin.missinglinkConflictsTag
import sbt.Keys.concurrentRestrictions

ThisBuild / scalaVersion := "2.13.12"

ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value)

ThisBuild / concurrentRestrictions += Tags.limit(missinglinkConflictsTag, 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ru.tinkoff.tcb.bson

case class DeserializationError(message: String, cause: Throwable) extends RuntimeException(message, cause) {
final case class DeserializationError(message: String, cause: Throwable) extends RuntimeException(message, cause) {
def this(message: String) = this(message, null)
}
object DeserializationError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import scala.util.Try
import enumeratum.values.*

import ru.tinkoff.tcb.bson.*
sealed trait BsonValueEnum[ValueType, EntryType <: ValueEnumEntry[ValueType]] {

trait BsonValueEnum[ValueType, EntryType <: ValueEnumEntry[ValueType]] {
enum: ValueEnum[ValueType, EntryType] =>

implicit def bsonEncoder: BsonEncoder[EntryType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ sealed trait RegexModifier {
def value: String
}

case class CombinedRegexModifier(lhs: RegexModifier, rhs: RegexModifier) extends RegexModifier {
final case class CombinedRegexModifier(lhs: RegexModifier, rhs: RegexModifier) extends RegexModifier {
override def value: String = lhs.value + rhs.value
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ru.tinkoff.tcb.bson.derivation.bsonDecoder
import ru.tinkoff.tcb.bson.derivation.bsonEncoder

@derive(bsonEncoder, bsonDecoder)
case class TestEntity(_id: String, name: String, externalKey: Option[Int])
final case class TestEntity(_id: String, name: String, externalKey: Option[Int])

class PatchGeneratorSpec extends AnyFunSuite with Matchers {
test("Generate update with Some") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import derevo.derive
import ru.tinkoff.tcb.bson.annotation.BsonKey

@derive(bsonDecoder, bsonEncoder)
case class TestMeta(time: Instant, seq: Long, flag: Boolean)
final case class TestMeta(time: Instant, seq: Long, flag: Boolean)

@derive(bsonDecoder, bsonEncoder)
case class TestCheck(year: Year, comment: String)
final case class TestCheck(year: Year, comment: String)

@derive(bsonDecoder, bsonEncoder)
case class TestEntity(
final case class TestEntity(
@BsonKey("_id") id: Int,
name: String,
meta: TestMeta,
Expand All @@ -24,10 +24,10 @@ case class TestEntity(
)

@derive(bsonDecoder, bsonEncoder)
case class TestContainer[T](value: Option[T])
final case class TestContainer[T](value: Option[T])

@derive(bsonDecoder, bsonEncoder)
case class TestEntityWithDefaults(
final case class TestEntityWithDefaults(
@BsonKey("_id") id: Int,
name: String = "test",
meta: TestMeta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ru.tinkoff.tcb.bson.derivation
import derevo.derive

@derive(bsonDecoder, bsonEncoder)
case class XXXCaseClass(
final case class XXXCaseClass(
a: Int,
b: Int,
c: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ru.tinkoff.tcb.bson.*
import ru.tinkoff.tcb.bson.derivation.*
import ru.tinkoff.tcb.criteria.Typed.*

case class Data(intField: Int, optField: Option[Int])
final case class Data(intField: Int, optField: Option[Int])

object Data {
implicit val dataDecoder: BsonDecoder[Data] = DerivedDecoder.genBsonDecoder[Data]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ru.tinkoff.tcb.protocol.schema.*
import ru.tinkoff.tcb.utils.id.SID

@derive(decoder, encoder, schema)
case class CreateDestinationConfigurationRequest(
final case class CreateDestinationConfigurationRequest(
@description("Уникальное название конфигурации")
name: SID[DestinationConfiguration],
@description("Описание конфигурации")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import ru.tinkoff.tcb.protocol.schema.*
import ru.tinkoff.tcb.utils.circe.optics.JsonOptic

@derive(decoder, encoder, schema)
case class CreateGrpcStubRequest(
final case class CreateGrpcStubRequest(
scope: Scope,
times: Option[Int Refined NonNegative] = Some(1),
service: String Refined NonEmpty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ru.tinkoff.tcb.utils.circe.optics.JsonOptic
import ru.tinkoff.tcb.utils.id.SID

@derive(decoder, encoder, schema)
case class CreateScenarioRequest(
final case class CreateScenarioRequest(
@description("Тип конфигурации")
scope: Scope,
@description("Количество возможных срабатываний. Имеет смысл только для scope=countdown")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ru.tinkoff.tcb.generic.PropSubset
import ru.tinkoff.tcb.mockingbird.model.Service

@derive(decoder, encoder, schema)
case class CreateServiceRequest(
final case class CreateServiceRequest(
suffix: String Refined And[NonEmpty, MatchesRegex["[\\w-]+"]],
name: String Refined NonEmpty
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ru.tinkoff.tcb.protocol.schema.*
import ru.tinkoff.tcb.utils.id.SID

@derive(decoder, encoder, schema)
case class CreateSourceConfigurationRequest(
final case class CreateSourceConfigurationRequest(
@description("Уникальное название конфигурации")
name: SID[SourceConfiguration],
@description("Описание конфигурации")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ru.tinkoff.tcb.protocol.schema.*
import ru.tinkoff.tcb.utils.circe.optics.JsonOptic

@derive(encoder, decoder, schema)
case class CreateStubRequest(
final case class CreateStubRequest(
@description("Тип конфигурации")
scope: Scope,
@description("Количество возможных срабатываний. Имеет смысл только для scope=countdown")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import ru.tinkoff.tcb.mockingbird.model.ResourceRequest
import ru.tinkoff.tcb.protocol.schema.*

@derive(decoder, encoder, schema)
case class UpdateDestinationConfigurationRequest(
final case class UpdateDestinationConfigurationRequest(
@description("Описание конфигурации")
description: String,
service: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import ru.tinkoff.tcb.utils.circe.optics.JsonOptic
import ru.tinkoff.tcb.utils.id.SID

@derive(decoder, encoder, schema)
case class UpdateScenarioRequest(
final case class UpdateScenarioRequest(
@description("Тип конфигурации")
scope: Scope,
@description("Количество возможных срабатываний. Имеет смысл только для scope=countdown")
Expand Down Expand Up @@ -63,7 +63,7 @@ object UpdateScenarioRequest {
}

@derive(bsonEncoder)
case class ScenarioPatch(
final case class ScenarioPatch(
@BsonKey("_id") id: SID[Scenario],
scope: Scope,
times: Option[Int Refined NonNegative],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ru.tinkoff.tcb.mockingbird.model.SourceConfiguration
import ru.tinkoff.tcb.protocol.schema.*

@derive(decoder, encoder, schema)
case class UpdateSourceConfigurationRequest(
final case class UpdateSourceConfigurationRequest(
@description("Описание конфигурации")
description: String,
service: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import ru.tinkoff.tcb.utils.circe.optics.JsonOptic
import ru.tinkoff.tcb.utils.id.SID

@derive(decoder, encoder, schema)
case class UpdateStubRequest(
final case class UpdateStubRequest(
@description("Тип конфигурации")
scope: Scope,
@description("Количество возможных срабатываний. Имеет смысл только для scope=countdown")
Expand Down Expand Up @@ -64,7 +64,7 @@ object UpdateStubRequest {
}

@derive(bsonEncoder)
case class StubPatch(
final case class StubPatch(
@BsonKey("_id") id: SID[HttpStub],
scope: Scope,
times: Option[Int Refined NonNegative],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ import ru.tinkoff.tcb.utils.xml.XMLString
import ru.tinkoff.tcb.xpath.Xpath

@derive(decoder, encoder, schema)
case class XPathTestRequest(xml: XMLString, path: Xpath)
final case class XPathTestRequest(xml: XMLString, path: Xpath)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import ru.tinkoff.tcb.mockingbird.model.DestinationConfiguration
import ru.tinkoff.tcb.utils.id.SID

@derive(encoder, decoder, schema, bsonDecoder)
case class DestinationDTO(@BsonKey("_id") name: SID[DestinationConfiguration], description: String)
final case class DestinationDTO(@BsonKey("_id") name: SID[DestinationConfiguration], description: String)
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import ru.tinkoff.tcb.mockingbird.model.SourceConfiguration
import ru.tinkoff.tcb.utils.id.SID

@derive(encoder, decoder, schema, bsonDecoder)
case class SourceDTO(@BsonKey("_id") name: SID[SourceConfiguration], description: String)
final case class SourceDTO(@BsonKey("_id") name: SID[SourceConfiguration], description: String)
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import net.ceedubs.ficus.Ficus.*
import net.ceedubs.ficus.readers.ArbitraryTypeReader.*
import net.ceedubs.ficus.readers.EnumerationReader.*

case class ServerConfig(interface: String, port: Int, allowedOrigins: Seq[String], healthCheckRoute: Option[String])
final case class ServerConfig(interface: String, port: Int, allowedOrigins: Seq[String], healthCheckRoute: Option[String])

case class SecurityConfig(secret: String)
final case class SecurityConfig(secret: String)

case class ProxyServerAuth(user: String, password: String)
final case class ProxyServerAuth(user: String, password: String)

object ProxyServerType extends Enumeration {
val Http = Value("http")
val Socks = Value("socks")
}

case class ProxyServerConfig(
final case class ProxyServerConfig(
`type`: ProxyServerType.Value,
host: String,
port: Int,
Expand All @@ -28,19 +28,19 @@ case class ProxyServerConfig(
auth: Option[ProxyServerAuth]
)

case class ProxyConfig(
final case class ProxyConfig(
excludedRequestHeaders: Seq[String],
excludedResponseHeaders: Set[String],
proxyServer: Option[ProxyServerConfig],
insecureHosts: Seq[String],
logOutgoingRequests: Boolean
)

case class EventConfig(fetchInterval: FiniteDuration, reloadInterval: FiniteDuration)
final case class EventConfig(fetchInterval: FiniteDuration, reloadInterval: FiniteDuration)

case class MongoConfig(uri: String, collections: MongoCollections)
final case class MongoConfig(uri: String, collections: MongoCollections)

case class MongoCollections(
final case class MongoCollections(
stub: String,
state: String,
scenario: String,
Expand All @@ -51,13 +51,13 @@ case class MongoCollections(
destination: String
)

case class TracingConfig(
final case class TracingConfig(
required: List[String] = List.empty,
incomingHeaders: Map[String, String] = Map.empty,
outcomingHeaders: Map[String, String] = Map.empty,
)

case class MockingbirdConfiguration(
final case class MockingbirdConfiguration(
server: ServerConfig,
security: SecurityConfig,
mongo: MongoConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package ru.tinkoff.tcb.mockingbird.error

case class CompoundError(excs: List[Throwable]) extends Exception
final case class CompoundError(excs: List[Throwable]) extends Exception
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object Method {
/*
Универсальный маршаллер, который не меняет поток байтов
*/
case class ByteMarshaller() extends Marshaller[Array[Byte]] {
final case class ByteMarshaller() extends Marshaller[Array[Byte]] {
override def stream(value: Array[Byte]): InputStream = new ByteArrayInputStream(value)

override def parse(stream: InputStream): Array[Byte] = stream.readAllBytes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import io.grpc.HandlerRegistry
import io.grpc.ServerCallHandler
import io.grpc.ServerMethodDefinition

case class UniversalHandlerRegistry0(method: ServerMethodDefinition[?, ?]) extends HandlerRegistry {
final case class UniversalHandlerRegistry0(method: ServerMethodDefinition[?, ?]) extends HandlerRegistry {

override def lookupMethod(methodName: String, authority: String): ServerMethodDefinition[?, ?] =
method
}

case class UniversalHandlerRegistry(handler: ServerCallHandler[Array[Byte], Array[Byte]]) extends HandlerRegistry {
final case class UniversalHandlerRegistry(handler: ServerCallHandler[Array[Byte], Array[Byte]]) extends HandlerRegistry {

override def lookupMethod(methodName: String, authority: String): ServerMethodDefinition[Array[Byte], Array[Byte]] = {
val methodNameArray = methodName.split("/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ object Callback {
}

@derive(decoder, encoder)
case class MessageCallback(
final case class MessageCallback(
destination: SID[DestinationConfiguration],
output: ScenarioOutput,
callback: Option[Callback],
delay: Option[FiniteDuration] = None
) extends Callback

@derive(decoder, encoder)
case class HttpCallback(
final case class HttpCallback(
request: CallbackRequest,
responseMode: Option[CallbackResponseMode],
persist: Option[Map[JsonOptic, Json]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,30 @@ object CallbackRequest {
}

@derive(decoder, encoder)
case class CallbackRequestWithoutBody(
final case class CallbackRequestWithoutBody(
url: String Refined NonEmpty,
method: HttpMethod,
headers: Map[String, String]
) extends CallbackRequest

@derive(decoder, encoder)
case class RawCallbackRequest(
final case class RawCallbackRequest(
url: String Refined NonEmpty,
method: HttpMethod,
headers: Map[String, String],
body: String
) extends CallbackRequest

@derive(decoder, encoder)
case class JsonCallbackRequest(
final case class JsonCallbackRequest(
url: String Refined NonEmpty,
method: HttpMethod,
headers: Map[String, String],
body: Json
) extends CallbackRequest

@derive(decoder, encoder)
case class XMLCallbackRequest(
final case class XMLCallbackRequest(
url: String Refined NonEmpty,
method: HttpMethod,
headers: Map[String, String],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ru.tinkoff.tcb.utils.crypto.AES
import ru.tinkoff.tcb.utils.id.SID

@derive(encoder, decoder, schema)
case class DestinationConfiguration(
final case class DestinationConfiguration(
@BsonKey("_id") name: SID[DestinationConfiguration],
created: Instant,
description: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object XmlExtractor {
* Путь внутри CDATA
*/
@derive(decoder, encoder)
case class XMLCDataExtractor(prefix: Xpath, path: Xpath) extends XmlExtractor {
final case class XMLCDataExtractor(prefix: Xpath, path: Xpath) extends XmlExtractor {
def apply(node: Node): Either[XPathError, Json] =
node
.evalXPath[String](prefix.toXPathExpr)
Expand All @@ -64,7 +64,7 @@ case class XMLCDataExtractor(prefix: Xpath, path: Xpath) extends XmlExtractor {
* Путь внутри CDATA
*/
@derive(decoder, encoder)
case class JsonCDataExtractor(prefix: Xpath, path: JsonOptic) extends XmlExtractor {
final case class JsonCDataExtractor(prefix: Xpath, path: JsonOptic) extends XmlExtractor {
def apply(node: Node): Either[XPathError, Json] =
node.evalXPath[Json](prefix.toXPathExpr).map(path.get)
}
Loading

0 comments on commit 14a3045

Please sign in to comment.