Skip to content

Commit

Permalink
fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
phearnot committed Jan 27, 2025
1 parent ff9442b commit be9d6b0
Show file tree
Hide file tree
Showing 44 changed files with 93 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.wavesplatform.state

import com.typesafe.config.Config
import pureconfig.*
import pureconfig.generic.derivation.default.*

case class Settings(
networkConfigFile: String,
Expand Down
15 changes: 7 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,18 @@ inScope(Global)(
publish / skip := true,
scalacOptions ++= Seq(
"-feature",
"-explain",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-Ykind-projector",
"-Ywarn-unused:-implicits",
"-Xlint",
"-nowarn", // TODO: [scala3] remove
"-Wconf:cat=deprecation&site=com.wavesplatform.api.grpc.*:s", // Ignore gRPC warnings
"-Wconf:cat=deprecation&site=com.wavesplatform.protobuf.transaction.InvokeScriptResult.*:s", // Ignore deprecated argsBytes
"-Wconf:cat=deprecation&site=com.wavesplatform.state.InvokeScriptResult.*:s",
"-Wconf:cat=deprecation&site=com\\.wavesplatform\\.(lang\\..*|JsApiUtils)&origin=com\\.wavesplatform\\.lang\\.v1\\.compiler\\.Terms\\.LET_BLOCK:s"
"-Xkind-projector",
"-Wconf:cat=deprecation&origin=com.wavesplatform.api.grpc.*:s", // Ignore gRPC warnings
"-Wconf:cat=deprecation&origin=com.wavesplatform.protobuf.transaction.InvokeScriptResult.*:s", // Ignore deprecated argsBytes
"-Wconf:cat=deprecation&origin=com.wavesplatform.state.InvokeScriptResult.*:s",
"-Wconf:cat=deprecation&origin=com\\.wavesplatform\\.(lang\\..*|JsApiUtils)&origin=com\\.wavesplatform\\.lang\\.v1\\.compiler\\.Terms\\.LET_BLOCK:s",
"-Wconf:src=src_managed/.*:s"
),
crossPaths := false,
cancelable := true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ package object grpc {
}

protected lazy val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
Logger(LoggerFactory.getLogger(this.getClass.getName))

implicit class StreamObserverMonixOps[T](val streamObserver: StreamObserver[T]) extends AnyVal {
def id: String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.wavesplatform.events.settings

import scala.concurrent.duration.FiniteDuration
import pureconfig.*
import pureconfig.generic.derivation.default.*

case class BlockchainUpdatesSettings(
grpcPort: Int,
Expand Down
1 change: 0 additions & 1 deletion lang/js/src/main/scala/com/wavesplatform/JsApiUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ object JsApiUtils {
"argList" -> args.toJSArray.map(arg => serFuncArg(arg._1, arg._2)),
"expr" -> serExpr(expr)
)
case t => jObj("[not_supported]stringRepr" -> t.toString)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,6 @@ trait BaseGlobal {
} else {
division
}) * sign)
case _ =>
Left(s"unsupported rounding $rounding")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ object CompilationError {
s"${ce.message} in ${ce.start}-${ce.end}"
}

final case object TooManyExpressions extends CompilationError {
case object TooManyExpressions extends CompilationError {

override def start: Int = 0

override def end: Int = 0

val message = "Too many expressions"
}
final case object NoExpressions extends CompilationError {
case object NoExpressions extends CompilationError {
override def start: Int = 0

override def end: Int = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class ContractCompiler(version: StdLibVersion) extends ExpressionCompiler(versio
} yield result
}

private def handleValid[T](part: PART[T]): CompileM[PART.VALID[T]] = part match {
private def handleValid[T](part: PART[T]): CompileM[PART.VALID[T]] = (part: @unchecked) match {
case x: PART.VALID[T] => x.pure[CompileM]
case PART.INVALID(p, message) => raiseError(Generic(p.start, p.end, message))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ class Parser(stdLibVersion: StdLibVersion)(implicit offset: LibrariesOffset) {
.map { case (parsed, errorIndexes) => (parsed, baseErrorIndexes ++ errorIndexes) }
else
Right((defaultResult, baseErrorIndexes))
case _ =>
Left(("Unknown parsing error.", 0, 0))
}

@tailrec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Contains extends JsTestBase {
for (
(data, list, function) <- Seq(
(randomStringArrayElement, randomStringArrayElement, contains),
(randomStringArrayElement, randomStringArrayElement, containsArgBeforeFunc),
(randomStringArrayElement, randomStringArrayElement, containsArgBeforeFunc)
)
) {
val script = precondition.simpleRideCode(data, list, function)
Expand All @@ -38,7 +38,7 @@ object Contains extends JsTestBase {
(randomInt.toString, randomAliasDataArrayElement, containsArgBeforeFunc, nonMatchingTypes("String")),
(randomInt.toString, randomIssuesArrayElement, containsArgBeforeFunc, nonMatchingTypes("String")),
(randomStringArrayElement, randomStringArrayElement, invalidContains, invalidErrorContains),
(randomStringArrayElement, randomStringArrayElement, invalidContainsArgBeforeFunc, invalidErrorContains),
(randomStringArrayElement, randomStringArrayElement, invalidContainsArgBeforeFunc, invalidErrorContains)
)
) {
val script = precondition.simpleRideCode(data, list, function)
Expand All @@ -49,8 +49,8 @@ object Contains extends JsTestBase {
}

test("RIDE-210. Can't find a function contains for RIDE V3") {
val precondition = new GeneratorContractsForBuiltInFunctions("String", V3)
val script = precondition.simpleRideCode(randomStringArrayElement, randomStringArrayElement, contains)
val precondition = new GeneratorContractsForBuiltInFunctions("String", V3)
val script = precondition.simpleRideCode(randomStringArrayElement, randomStringArrayElement, contains)
assertCompileErrorDApp(script, V3, testData.CANT_FIND_FUNCTION)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import com.wavesplatform.transaction.{GenesisTransaction, TxNonNegativeAmount}
import com.wavesplatform.utils.*
import com.wavesplatform.wallet.Wallet
import pureconfig.*
import pureconfig.generic.derivation.default.*

import java.io.{File, FileNotFoundException}
import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ package object http {
def extractScheduler: Directive1[Scheduler] = extractExecutionContext.map(ec => Scheduler(ec))

private lazy val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
Logger(LoggerFactory.getLogger(this.getClass.getName))

val uncaughtExceptionHandler: ExceptionHandler = ExceptionHandler {
case ApiException(error) => complete(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.wavesplatform.transaction.{Asset, TransactionType}
import monix.eval.Coeval
import play.api.libs.json.JsObject

sealed trait Evaluation extends Product with Serializable {
sealed trait Evaluation {
def blockchain: Blockchain
def txLike: InvokeScriptTransactionLike
def dAppToExpr(dApp: DApp): Either[ValidationError, EXPR]
Expand Down Expand Up @@ -61,6 +61,8 @@ object Evaluation {
override def chainId: Byte = AddressScheme.current.chainId
override def id: Coeval[ByteStr] = Coeval.evalOnce(ByteStr.empty)
override val tpe: TransactionType = TransactionType.InvokeScript

override def checkedAssets: Seq[Asset.IssuedAsset] = Seq.empty
}

private def toInvokeScriptLike(invocation: Invocation, dAppAddress: Address) =
Expand All @@ -78,6 +80,8 @@ object Evaluation {
invocation.payments.payments.map { case (amount, assetId) =>
Payment(amount, Asset.fromCompatId(assetId))
}

override def checkedAssets: Seq[Asset.IssuedAsset] = invocation.payments.payments.collect { case (_, Some(id)) => Asset.IssuedAsset(id) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import monix.execution.schedulers.SchedulerService
import org.influxdb.{InfluxDB, InfluxDBFactory}
import org.influxdb.dto.Point
import pureconfig.*
import pureconfig.generic.derivation.default.*

object Metrics extends ScorexLogging {
case class InfluxDbSettings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.wavesplatform.utils.ScorexLogging
import io.netty.channel.ChannelHandler.Sharable
import io.netty.channel.{ChannelDuplexHandler, ChannelHandlerContext, ChannelPromise}
import pureconfig.*
import pureconfig.generic.derivation.default.*

abstract class TrafficLogger(settings: TrafficLogger.Settings) extends ChannelDuplexHandler with ScorexLogging {
protected def codeOf(msg: AnyRef): Option[Byte]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import scala.concurrent.duration.*
package object network {
private val broadcastTimeStats = Kamon.timer("network-broadcast-time")
private lazy val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
Logger(LoggerFactory.getLogger(this.getClass.getName))

implicit class EventExecutorGroupExt(val e: EventExecutorGroup) extends AnyVal {
def scheduleWithFixedDelay(initialDelay: FiniteDuration, delay: FiniteDuration)(f: => Unit): ScheduledFuture[?] =
Expand Down
2 changes: 1 addition & 1 deletion node/src/main/scala/com/wavesplatform/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory

package object wavesplatform {
private lazy val logger: Logger =
Logger(LoggerFactory.getLogger(getClass.getName))
Logger(LoggerFactory.getLogger(this.getClass.getName))
private def checkOrAppend(block: Block, blockchainUpdater: Blockchain & BlockchainUpdater, miner: Miner): Either[ValidationError, Unit] =
if (blockchainUpdater.isEmpty) {
blockchainUpdater.processBlock(block, block.header.generationSignature, None).map { _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,6 @@ object PBTransactions {
.left
.map(e => GenericError(s"Invalid InvokeScript function call: $e"))

_ <- fcOpt match {
case None | Some(Terms.FUNCTION_CALL(_, _)) => Right(())
case Some(expr) => Left(GenericError(s"Not a function call: $expr"))
}

tx <- vt.smart.InvokeScriptTransaction.create(
version.toByte,
sender,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.typesafe.config.Config
import com.wavesplatform.account.Address
import com.wavesplatform.common.state.ByteStr
import pureconfig.*
import pureconfig.generic.derivation.default.*

import scala.concurrent.duration.*

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class DBSettings(
directory: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class FeaturesSettings(autoShutdownOnUnsupportedFeature: Boolean, supported: List[Short] = defaultSupported)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

final case class GRPCSettings(
host: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.wavesplatform.settings
import com.wavesplatform.account.PrivateKey
import com.wavesplatform.mining.Miner
import pureconfig.*
import pureconfig.generic.derivation.default.*

import scala.concurrent.duration.FiniteDuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import java.net.{InetSocketAddress, URI}
import scala.concurrent.duration.FiniteDuration
import scala.util.Random
import pureconfig.*
import pureconfig.generic.derivation.default.*

case class UPnPSettings(enable: Boolean, gatewayTimeout: FiniteDuration, discoverTimeout: FiniteDuration) derives ConfigReader

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class RestAPISettings(
enable: Boolean,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class RewardsVotingSettings(desired: Option[Long]) derives ConfigReader
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class RocksDBSettings(
mainCacheSize: SizeInBytes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.wavesplatform.settings

import com.wavesplatform.network.InvalidBlockStorageImpl.InvalidBlockStorageSettings
import pureconfig.*
import pureconfig.generic.derivation.default.*

import scala.concurrent.duration.FiniteDuration

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*

case class UtxSettings(
maxSize: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wavesplatform.settings

import pureconfig.*
import pureconfig.generic.derivation.default.*
import java.io.File

import com.wavesplatform.common.state.ByteStr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ object InvokeScriptResult {
implicit val recipientWrites: Writes[AddressOrAlias] = Writes[AddressOrAlias] {
case address: Address => implicitly[Writes[Address]].writes(address)
case alias: Alias => JsString(alias.toString)
case _ => JsNull
}
implicit val jsonWrites: OWrites[Lease] = Json.writes[Lease]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ trait InvokeScriptLike {
def funcCall: FUNCTION_CALL
def payments: Seq[Payment]
def root: InvokeScriptTransactionLike
def checkedAssets: Seq[IssuedAsset] = payments collect { case Payment(_, assetId: IssuedAsset) => assetId }
def sender: PublicKey
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ case class InvokeExpressionTransaction(
override def root: InvokeExpressionTransaction = this
override val funcCall: Terms.FUNCTION_CALL = InvokeTransaction.DefaultCall
override def payments: Seq[InvokeScriptTransaction.Payment] = Nil
override val checkedAssets: Seq[Asset.IssuedAsset] = Nil

override val bodyBytes: Coeval[Array[Byte]] = Coeval.evalOnce(PBTransactionSerializer.bodyBytes(this))
override val bytes: Coeval[Array[Byte]] = Coeval.evalOnce(PBTransactionSerializer.bytes(this))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import com.wavesplatform.lang.v1.evaluator.ContractEvaluator
import com.wavesplatform.state.diffs.invoke.InvokeScriptTransactionLike
import com.wavesplatform.transaction.{Asset, FastHashId, ProvenTransaction, Transaction, TxWithFee}

trait InvokeTransaction extends Transaction with InvokeScriptTransactionLike with ProvenTransaction with TxWithFee.InCustomAsset with FastHashId {
override val checkedAssets: Seq[Asset.IssuedAsset] = super[InvokeScriptTransactionLike].checkedAssets
}
trait InvokeTransaction extends Transaction with InvokeScriptTransactionLike with ProvenTransaction with TxWithFee.InCustomAsset with FastHashId

object InvokeTransaction {
val DefaultCall: FUNCTION_CALL = FUNCTION_CALL(User(ContractEvaluator.DEFAULT_FUNC_NAME), Nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,8 @@ object Verifier extends ScorexLogging {
.foldLeft(builder) {
case (sb, (k, Right(v))) =>
sb.append(s"\nEvaluated `$k` to ")
v match {
case obj: EVALUATED => TermPrinter().print(str => sb.append(str), obj); sb
case a => sb.append(a.toString)
}
TermPrinter().print(str => sb.append(str), v)
sb
case (sb, (k, Left(err))) => sb.append(s"\nFailed to evaluate `$k`: $err")
}
.toString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ class LeasingExpirySpec extends FreeSpec with WithDomain {
d.blockchainUpdater.processBlock(b) should beRight
val leasesToBeCancelled = b.transactionData.collect { case lt: LeaseTransaction => lt }
leasesToBeCancelled.foreach {
case lt: LeaseTransaction => d.blockchainUpdater.leaseDetails(lt.id()).map(_.isActive) shouldBe Some(true)
case _ =>
lt => d.blockchainUpdater.leaseDetails(lt.id()).map(_.isActive) shouldBe Some(true)
}
emptyBlocks.take(2).foreach(b => d.blockchainUpdater.processBlock(b) should beRight)
// activation height: leases should still be active
Expand All @@ -124,8 +123,7 @@ class LeasingExpirySpec extends FreeSpec with WithDomain {
// once new block is appended, leases become cancelled
d.blockchainUpdater.processBlock(emptyBlocks.last)
leasesToBeCancelled.foreach {
case lt: LeaseTransaction => d.blockchainUpdater.leaseDetails(lt.id()).map(_.isActive) shouldBe Some(false)
case _ =>
lt => d.blockchainUpdater.leaseDetails(lt.id()).map(_.isActive) shouldBe Some(false)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ package object util {
a match {
case address: Address => Recipient.Address(ByteStr(address.bytes))
case alias: Alias => Recipient.Alias(alias.name)
case _ => ???
}
}
}
Loading

0 comments on commit be9d6b0

Please sign in to comment.