Skip to content

Update scalafix to 0.11.0 #187

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

Merged
merged 2 commits into from
Aug 18, 2023
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
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
4 changes: 2 additions & 2 deletions rewrites/src/main/scala/fix/scala213/Any2StringAdd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final class Any2StringAdd extends SemanticRule("fix.scala213.Any2StringAdd") {

override def fix(implicit doc: SemanticDocument): Patch = {
doc.tree.collect {
case any2stringaddPlusString(Term.ApplyInfix(lhs, _, _, _)) => wrapStringValueOf(lhs)
case primitivePlusString(Term.ApplyInfix(lhs, _, _, _)) => blankStringPlus(lhs)
case any2stringaddPlusString(Term.ApplyInfix.Initial(lhs, _, _, _)) => wrapStringValueOf(lhs)
case primitivePlusString(Term.ApplyInfix.Initial(lhs, _, _, _)) => blankStringPlus(lhs)
}.asPatch
}

Expand Down
30 changes: 15 additions & 15 deletions rewrites/src/main/scala/fix/scala213/Core.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ final class Core extends SemanticRule("fix.scala213.Core") {

val platformArraycopy: Replacer = {
case arraycopy(i: Importee) => Patch.removeImportee(i)
case arraycopy(Term.Apply(t, _)) => replaceTree(t, "System.arraycopy")
case arraycopy(Term.Apply.Initial(t, _)) => replaceTree(t, "System.arraycopy")
}

val consoleRead: Replacer = {
case deprecatedConsoleReadBoolean(Term.Apply(t, _)) => stdInReplace(t, "readBoolean")
case deprecatedConsoleReadByte( Term.Apply(t, _)) => stdInReplace(t, "readByte")
case deprecatedConsoleReadChar( Term.Apply(t, _)) => stdInReplace(t, "readChar")
case deprecatedConsoleReadDouble( Term.Apply(t, _)) => stdInReplace(t, "readDouble")
case deprecatedConsoleReadFloat( Term.Apply(t, _)) => stdInReplace(t, "readFloat")
case deprecatedConsoleReadInt( Term.Apply(t, _)) => stdInReplace(t, "readInt")
case deprecatedConsoleReadLine( Term.Apply(t, _)) => stdInReplace(t, "readLine")
case deprecatedConsoleReadLine1( Term.Apply(t, _)) => stdInReplace(t, "readLine")
case deprecatedConsoleReadLong( Term.Apply(t, _)) => stdInReplace(t, "readLong")
case deprecatedConsoleReadShort( Term.Apply(t, _)) => stdInReplace(t, "readShort")
case deprecatedConsoleReadf( Term.Apply(t, _)) => stdInReplace(t, "readf")
case deprecatedConsoleReadf1( Term.Apply(t, _)) => stdInReplace(t, "readf1")
case deprecatedConsoleReadf2( Term.Apply(t, _)) => stdInReplace(t, "readf2")
case deprecatedConsoleReadf3( Term.Apply(t, _)) => stdInReplace(t, "readf3")
case deprecatedConsoleReadBoolean(Term.Apply.Initial(t, _)) => stdInReplace(t, "readBoolean")
case deprecatedConsoleReadByte( Term.Apply.Initial(t, _)) => stdInReplace(t, "readByte")
case deprecatedConsoleReadChar( Term.Apply.Initial(t, _)) => stdInReplace(t, "readChar")
case deprecatedConsoleReadDouble( Term.Apply.Initial(t, _)) => stdInReplace(t, "readDouble")
case deprecatedConsoleReadFloat( Term.Apply.Initial(t, _)) => stdInReplace(t, "readFloat")
case deprecatedConsoleReadInt( Term.Apply.Initial(t, _)) => stdInReplace(t, "readInt")
case deprecatedConsoleReadLine( Term.Apply.Initial(t, _)) => stdInReplace(t, "readLine")
case deprecatedConsoleReadLine1( Term.Apply.Initial(t, _)) => stdInReplace(t, "readLine")
case deprecatedConsoleReadLong( Term.Apply.Initial(t, _)) => stdInReplace(t, "readLong")
case deprecatedConsoleReadShort( Term.Apply.Initial(t, _)) => stdInReplace(t, "readShort")
case deprecatedConsoleReadf( Term.Apply.Initial(t, _)) => stdInReplace(t, "readf")
case deprecatedConsoleReadf1( Term.Apply.Initial(t, _)) => stdInReplace(t, "readf1")
case deprecatedConsoleReadf2( Term.Apply.Initial(t, _)) => stdInReplace(t, "readf2")
case deprecatedConsoleReadf3( Term.Apply.Initial(t, _)) => stdInReplace(t, "readf3")
}

private def stdInReplace(tree: Tree, name: String): Patch =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class ExplicitNonNullaryApply(global: LazyValue[ScalafixGlobal])
if handled.add(name)
if noArgs
if name.isReference
if !cond(name.parent) { case Some(Term.ApplyInfix(_, `name`, _, _)) => true }
if !cond(name.parent) { case Some(Term.ApplyInfix.Initial(_, `name`, _, _)) => true }
if !tree.parent.exists(_.is[Term.Eta]) // else rewrites `meth _` to `meth() _`, or requires running ExplicitNullaryEtaExpansion first
// HACK: In certain cases, `Symbol.info` may throw `MissingSymbolException` due to some unknown reason
// If it happens, here we assume that this symbol has no info
Expand Down
2 changes: 1 addition & 1 deletion rewrites/src/main/scala/fix/scala213/NullaryHashHash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class NullaryHashHash extends SemanticRule("fix.scala213.NullaryHashHash")

override def fix(implicit doc: SemanticDocument) = {
doc.tree.collect {
case expr @ Term.Apply(HashHash(fun), Nil) =>
case expr @ Term.Apply.Initial(HashHash(fun), Nil) =>
Patch.removeTokens(expr.tokens.takeRight(expr.pos.end - fun.pos.end))
}.asPatch
}
Expand Down
2 changes: 1 addition & 1 deletion rewrites/src/main/scala/fix/scala213/ScalaSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class ScalaSeq(val config: ScalaSeq.Config) extends SemanticRule("fix.scal
inParam = false
apply(p.default)

case scalaSeq(Type.Apply(t, _)) =>
case scalaSeq(Type.Apply.Initial(t, _)) =>
val sub = if (inParam) {
paramImport.foreach(i => patch += globalImports.add(i))
config.paramType
Expand Down
5 changes: 3 additions & 2 deletions tests/src/test/scala/fix/RuleSuite.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package fix

import scala.reflect.ensureAccessible
import org.scalatest.{ ConfigMap, FunSpecLike }
import org.scalatest.ConfigMap
import org.scalatest.funspec.AnyFunSpecLike
import scalafix.testkit.AbstractSemanticRuleSuite

class RuleSuite extends AbstractSemanticRuleSuite with FunSpecLike with BeforeAndAfterAllConfigMapAlt {
class RuleSuite extends AbstractSemanticRuleSuite with AnyFunSpecLike with BeforeAndAfterAllConfigMapAlt {
val isSaveExpectField = ensureAccessible(classOf[AbstractSemanticRuleSuite].getDeclaredField("isSaveExpect"))

// If you invoke the test as "tests/testOnly -- -Doverwrite=true" it will save the expected
Expand Down