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

Update sbt-scalafix, scalafix-core to 0.12.0 #581

Merged
merged 6 commits into from
Mar 18, 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
1 change: 1 addition & 0 deletions .scalafix-common.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
rules = [
OrganizeImports
]
OrganizeImports.targetDialect = Auto
2 changes: 1 addition & 1 deletion .scalafmt-common.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# this file by hand! Instead, if you wish to make changes, you should
# make a PR to sbt-lucuma.

version = "3.7.17"
version = "3.8.0"
style = default

runner.dialect = scala3
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ lazy val sbtPlugin = project
moduleName := "sbt-clue",
crossScalaVersions := List("2.12.19"),
scalacOptions := Nil,
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1"),
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0"),
addSbtPlugin("org.portable-scala" % "sbt-platform-deps" % "1.0.2"),
addSbtPlugin("org.portable-scala" % "sbt-crossproject" % "1.3.2"),
buildInfoPackage := "clue.sbt",
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/ErrorPolicy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package clue
import cats.Applicative
import cats.ApplicativeThrow
import cats.data.Ior
import cats.syntax.all._
import cats.syntax.all.*
import clue.model.GraphQLDataResponse
import clue.model.GraphQLErrors
import clue.model.GraphQLResponse
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/clue/FetchClientImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
package clue

import cats.MonadThrow
import cats.syntax.all._
import cats.syntax.all.*
import clue.model.GraphQLRequest
import clue.model.GraphQLResponse
import clue.model.json._
import io.circe._
import io.circe.parser._
import clue.model.json.*
import io.circe.*
import io.circe.parser.*
import org.typelevel.log4cats.Logger

// Response format from Spec: https://github.com/APIs-guru/graphql-over-http
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/backends.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package clue

import cats.syntax.all._
import cats.syntax.all.*
import clue.model.GraphQLRequest
import clue.model.StreamingMessage
import io.circe.Encoder
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/clue/clients.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package clue

import cats.effect.Resource
import cats.syntax.all._
import io.circe._
import io.circe.syntax._
import cats.syntax.all.*
import io.circe.*
import io.circe.syntax.*

/**
* A client that allows one-shot queries and mutations.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cats.Eq
import cats.MonadError
import cats.effect.Concurrent
import cats.effect.Deferred
import cats.syntax.all._
import cats.syntax.all.*
import org.typelevel.log4cats.Logger

package object clue {
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/clue/websocket/ApolloClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@

package clue.websocket

import cats.effect.*
import cats.effect.Ref
import cats.effect.Temporal
import cats.effect._
import cats.effect.implicits._
import cats.effect.implicits.*
import cats.effect.std.Queue
import cats.effect.std.UUIDGen
import cats.syntax.all._
import clue._
import cats.syntax.all.*
import clue.*
import clue.model.GraphQLErrors
import clue.model.GraphQLRequest
import clue.model.GraphQLResponse
import clue.model.StreamingMessage
import clue.model.json._
import clue.model.json.*
import fs2.Stream
import fs2.concurrent.SignallingRef
import io.circe._
import io.circe.parser._
import io.circe.*
import io.circe.parser.*
import org.typelevel.log4cats.Logger

import java.util.UUID
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/websocket/CloseParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package clue.websocket

import cats.syntax.all._
import cats.syntax.all.*

case class CloseParams(code: Option[Int] = none, reason: Option[String] = none)
object CloseParams {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/clue/websocket/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package clue

import cats.syntax.all._
import cats.syntax.all.*

import scala.concurrent.duration.FiniteDuration

Expand Down
168 changes: 84 additions & 84 deletions gen/output/src/main/scala/test/LucumaODBSchema.scala

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions gen/output/src/main/scala/test/StarWarsSchema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ object StarWars {
case object Jedi extends Episode()
implicit val eqEpisode: cats.Eq[Episode] = cats.Eq.fromUniversalEquals
implicit val showEpisode: cats.Show[Episode] = cats.Show.fromToString
implicit val jsonEncoderEpisode: io.circe.Encoder[Episode] = io.circe.Encoder.encodeString.contramap[Episode]({
implicit val jsonEncoderEpisode: io.circe.Encoder[Episode] = io.circe.Encoder.encodeString.contramap[Episode] {
case Newhope => "NEWHOPE"
case Empire => "EMPIRE"
case Jedi => "JEDI"
})
}
implicit val jsonDecoderEpisode: io.circe.Decoder[Episode] = io.circe.Decoder.decodeString.emap(_ match {
case "NEWHOPE" =>
Right(Newhope)
Expand Down
2 changes: 1 addition & 1 deletion gen/rules/src/main/scala/clue/gen/Accumulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package clue.gen

import cats._
import cats.*

/**
* Holds the aggregated `CaseClass`es, their `ClassParam`s and possible `Sum` info as we recurse the
Expand Down
8 changes: 5 additions & 3 deletions gen/rules/src/main/scala/clue/gen/Generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
package clue.gen

// import scalafix.v1._
import cats.syntax.all._
import cats.syntax.all.*
import edu.gemini.grackle
import edu.gemini.grackle.ScalarType
import edu.gemini.grackle.{Type => GType}
import edu.gemini.grackle.Type as GType

import java.util.regex.Pattern
import scala.meta._
import scala.meta.*

trait Generator {
protected val TypeSelect = "__typename"
Expand Down Expand Up @@ -183,6 +183,7 @@ trait Generator {
(parentBody, false)
case Define(newParentBody, early, inits) =>
val allInits = inits ++ extending.map(t => init"${Type.Name(t)}()")

(newParentBody :+
// q"case class ${Type.Name(name)}(..$pars) extends ..$earlyDefs with ..$allParents",
q"case class ${Type.Name(name)}(..$pars) extends {..$early} with ..$allInits",
Expand Down Expand Up @@ -282,6 +283,7 @@ trait Generator {
(parentBody, false)
case Define(newParentBody, early, inits) =>
val allInits = inits ++ extending.map(t => init"${Type.Name(t)}()")

(newParentBody :+
q"sealed trait ${Type.Name(name)} extends { ..$early } with ..$allInits { ..${pars.map(paramToVal)} }",
true
Expand Down
6 changes: 3 additions & 3 deletions gen/rules/src/main/scala/clue/gen/GraphQLGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ package clue.gen

import cats.effect.IO
import cats.effect.unsafe.implicits.global
import cats.syntax.all._
import cats.syntax.all.*
import edu.gemini.grackle.QueryParser
import metaconfig.Configured
import scalafix.v1._
import scalafix.v1.*

import scala.meta._
import scala.meta.*

class GraphQLGen(config: GraphQLGenConfig)
extends SemanticRule("GraphQLGen")
Expand Down
2 changes: 1 addition & 1 deletion gen/rules/src/main/scala/clue/gen/GraphQLGenConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cats.effect.Deferred
import cats.effect.IO
import cats.effect.Ref
import cats.effect.kernel.Resource
import cats.syntax.all._
import cats.syntax.all.*
import edu.gemini.grackle.Schema
import metaconfig.ConfDecoder
import metaconfig.generic.Surface
Expand Down
22 changes: 12 additions & 10 deletions gen/rules/src/main/scala/clue/gen/QueryGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ package clue.gen

import cats.data.State
import cats.effect.unsafe.implicits.global
import cats.syntax.all._
import edu.gemini.grackle.UntypedOperation._
import edu.gemini.grackle.{Term => _, Type => GType, _}
import cats.syntax.all.*
import edu.gemini.grackle.UntypedOperation.*
import edu.gemini.grackle.{Term as _, Type as GType, *}

import scala.meta._
import scala.meta.*

trait QueryGen extends Generator {

Expand Down Expand Up @@ -121,18 +121,20 @@ trait QueryGen extends Generator {

protected[this] def compileType(schema: Schema, tpe: Ast.Type): Result[GType] = {
def loop(tpe: Ast.Type, nonNull: Boolean): Result[GType] = tpe match {
case Ast.Type.NonNull(Left(named)) => loop(named, true)
case Ast.Type.NonNull(Right(list)) => loop(list, true)
case Ast.Type.NonNull(Left(named)) => loop(named, nonNull = true)
case Ast.Type.NonNull(Right(list)) => loop(list, nonNull = true)
case Ast.Type.List(elem) =>
loop(elem, false).map(e => if (nonNull) ListType(e) else NullableType(ListType(e)))
loop(elem, nonNull = false).map(e =>
if (nonNull) ListType(e) else NullableType(ListType(e))
)
case Ast.Type.Named(name) =>
schema.definition(name.value) match {
case None => Result.internalError(s"Undefine typed '${name.value}'")
case Some(tpe) => Result.success(if (nonNull) tpe else NullableType(tpe))
case None => Result.internalError(s"Undefine typed '${name.value}'")
case Some(tp) => Result.success(if (nonNull) tp else NullableType(tp))
}
}

loop(tpe, false)
loop(tpe, nonNull = false)
}
//
// END COPIED FROM GRACKLE.
Expand Down
2 changes: 1 addition & 1 deletion gen/rules/src/main/scala/clue/gen/SchemaGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import edu.gemini.grackle.EnumType
import edu.gemini.grackle.InputObjectType
import edu.gemini.grackle.Schema

import scala.meta._
import scala.meta.*

trait SchemaGen extends Generator {
// Just make sure "object Scalars" exists.
Expand Down
4 changes: 2 additions & 2 deletions gen/rules/src/main/scala/clue/gen/annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

package clue.gen

import scalafix.v1._
import scalafix.v1.*

import scala.meta._
import scala.meta.*

// Adapted from simulacrum-scalafix
class AnnotationPattern(fqcn: String) {
Expand Down
6 changes: 3 additions & 3 deletions gen/rules/src/test/scala/clue/gen/AccumulatorSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

package clue.gen

import cats._
import cats.*
import cats.kernel.laws.discipline.MonoidTests
import munit._
import munit.*
import org.scalacheck.Arbitrary
import org.scalacheck.Arbitrary._
import org.scalacheck.Arbitrary.*
import org.scalacheck.Gen

class AccumulatorSuite extends DisciplineSuite {
Expand Down
8 changes: 4 additions & 4 deletions http4s-jdk-demo/src/main/scala/clue/http4sjdkDemo/Demo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cats.effect.IO
import cats.effect.IOApp
import cats.effect.Resource
import cats.effect.Sync
import cats.syntax.all._
import cats.syntax.all.*
import clue.ErrorPolicy
import clue.FetchClient
import clue.GraphQLOperation
Expand All @@ -19,13 +19,13 @@ import clue.websocket.WebSocketClient
import io.circe.Decoder
import io.circe.Encoder
import io.circe.Json
import io.circe.generic.semiauto._
import org.http4s.implicits._
import io.circe.generic.semiauto.*
import org.http4s.implicits.*
import org.http4s.jdkhttpclient.JdkWSClient
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger

import scala.concurrent.duration._
import scala.concurrent.duration.*
import scala.util.Random

object Demo extends IOApp.Simple {
Expand Down
10 changes: 5 additions & 5 deletions http4s/src/main/scala/clue/http4s/Http4sHttpBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

package clue.http4s

import cats.effect._
import clue._
import cats.effect.*
import clue.*
import clue.model.GraphQLRequest
import clue.model.json._
import clue.model.json.*
import io.circe.Encoder
import io.circe.syntax._
import io.circe.syntax.*
import org.http4s.Request
import org.http4s.circe._
import org.http4s.circe.*
import org.http4s.client.Client
import org.http4s.client.dsl.Http4sClientDsl

Expand Down
2 changes: 1 addition & 1 deletion http4s/src/main/scala/clue/http4s/Http4sHttpClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cats.Applicative
import cats.MonadThrow
import clue.FetchClientImpl
import org.http4s.Headers
import org.http4s.Method._
import org.http4s.Method.*
import org.http4s.Request
import org.http4s.Uri
import org.typelevel.log4cats.Logger
Expand Down
16 changes: 8 additions & 8 deletions http4s/src/main/scala/clue/http4s/Http4sWebSocketBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@

package clue.http4s

import cats.effect.*
import cats.effect.Resource.ExitCase
import cats.effect._
import cats.effect.implicits._
import cats.syntax.all._
import clue._
import cats.effect.implicits.*
import cats.syntax.all.*
import clue.*
import clue.model.StreamingMessage
import clue.model.json._
import clue.websocket._
import io.circe.syntax._
import clue.model.json.*
import clue.websocket.*
import io.circe.syntax.*
import org.http4s.Headers
import org.http4s.Uri
import org.http4s.client.websocket._
import org.http4s.client.websocket.*

/**
* Streaming backend for http4s WebSocket client.
Expand Down
8 changes: 4 additions & 4 deletions model/src/main/scala/clue/data/Input.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import cats.Monad
import cats.Show
import cats.Traverse
import cats.data.Ior
import cats.syntax.all._
import clue.data.syntax._
import io.circe._
import io.circe.syntax._
import cats.syntax.all.*
import clue.data.syntax.*
import io.circe.*
import io.circe.syntax.*

import scala.annotation.tailrec

Expand Down
2 changes: 1 addition & 1 deletion model/src/main/scala/clue/model/GraphQLDataResponse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package clue.model

import cats.Eq
import cats.syntax.option._
import cats.syntax.option.*

/**
* A GraphQL response with data.
Expand Down
Loading
Loading