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

internal: Introduce scalafix #3328

Merged
merged 1 commit into from
Jan 9, 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
12 changes: 12 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
rules = [
# ExplicitResultTypes,
# OrganizeImports,
# RemoveUnused,
DisableSyntax,
LeakingImplicitClassVal,
NoValInForComprehension,
# ProcedureSyntax, // Scala-2 only
// Need to preserve string-interpolation prefix for `s"..."` and `f"..."` for
// preservinng the code alignment
# RedundantSyntax
]
2 changes: 1 addition & 1 deletion airframe-di/src/main/scala/wvlet/airframe/Session.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ object Session extends LogSupport {
*
* @param session
*/
implicit class SessionAccess(val session: Session) extends AnyVal {
implicit class SessionAccess(private val session: Session) extends AnyVal {
def get[A](surface: Surface)(implicit sourceCode: SourceCode): A = session.get[A](surface)(sourceCode)
def getOrElse[A](surface: Surface, obj: => A)(implicit sourceCode: SourceCode): A =
session.getOrElse[A](surface, obj)(sourceCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object HttpClientGenerator extends LogSupport {
}
}

private[client] implicit class RichSurface(val s: Surface) extends AnyVal {
private[client] implicit class RichSurface(private val s: Surface) extends AnyVal {
def fullTypeName: String = fullTypeNameOf(s)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object GrpcContext {
private[grpc] val KEY_ACCEPT = Metadata.Key.of("accept", Metadata.ASCII_STRING_MARSHALLER)
private[grpc] val KEY_CONTENT_TYPE = Metadata.Key.of("content-type", Metadata.ASCII_STRING_MARSHALLER)

private[grpc] implicit class RichMetadata(val m: Metadata) extends AnyVal {
private[grpc] implicit class RichMetadata(private val m: Metadata) extends AnyVal {
def accept: String = Option(m.get(KEY_ACCEPT)).getOrElse(RPCEncoding.ApplicationMsgPack)
def setAccept(s: String): Unit = {
m.removeAll(KEY_ACCEPT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import java.util.concurrent.ExecutorService
/**
*/
object GrpcServiceBuilder {
private implicit class RichMethod(val m: MethodSurface) extends AnyVal {
private implicit class RichMethod(private val m: MethodSurface) extends AnyVal {

private def findClientStreamingArg: Option[MethodParameter] = {
m.args.find(x => classOf[Rx[_]].isAssignableFrom(x.surface.rawType))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ package object json {
// Alias to encode msgpack into JSON strings with airframe-codec
type Json = String

implicit class RichJson(val json: Json) extends AnyVal {
implicit class RichJson(private val json: Json) extends AnyVal {
def toJSONValue: JSONValue = JSON.parseAny(json)
}

implicit class JSONValueOps(val jsonValue: JSONValue) extends AnyVal {
implicit class JSONValueOps(private val jsonValue: JSONValue) extends AnyVal {
def /(name: String): Seq[JSONValue] = {
jsonValue match {
case jsonObject: JSONObject =>
Expand Down Expand Up @@ -95,7 +95,7 @@ package object json {
}
}

implicit class JSONValueSeqOps(val jsonValues: Seq[JSONValue]) extends AnyVal {
implicit class JSONValueSeqOps(private val jsonValues: Seq[JSONValue]) extends AnyVal {
def /(name: String): Seq[JSONValue] = {
jsonValues.flatMap { jsonValue => jsonValue / name }
}
Expand Down
2 changes: 1 addition & 1 deletion airframe-rx/src/main/scala/wvlet/airframe/rx/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.concurrent.{ExecutionContext, Future}
/**
*/
package object rx {
implicit class FutureConverter[A](val f: Future[A]) extends AnyVal {
implicit class FutureConverter[A](private val f: Future[A]) extends AnyVal {
def toRx(implicit ec: ExecutionContext): RxOption[A] = Rx.fromFuture(f)(ec)
}
}
3 changes: 3 additions & 0 deletions project/plugin.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.2")

// For auto-code rewrite
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")

// For integration testing
val SBT_AIRFRAME_VERSION = sys.env.getOrElse("SBT_AIRFRAME_VERSION", "23.11.3")
addSbtPlugin("org.wvlet.airframe" % "sbt-airframe" % SBT_AIRFRAME_VERSION)
Expand Down
Loading