Questions tagged [scalafix]

ScalaFix is a refactoring and linting tool for Scala

is a refactoring and linting tool for Scala

  • Refactoring: Automate day-to-day code health tasks or write one-time migrations scripts.
  • Linting: Report error messages for code patterns that cause bugs in production or violate your coding style.
  • Enforce in CI: Automatically enforce refactoring and linting rules on every code review.

Useful Links:

13 questions
8
votes
2 answers

Exclude a specific implicit from a Scala project

How can I prevent the usage of a specific implicit in my scala code? For example, I was recently bit by the default Codec provided by https://github.com/scala/scala/blob/68bad81726d15d03a843dc476d52cbbaf52fb168/src/library/scala/io/Codec.scala#L76.…
Klugscheißer
  • 1,575
  • 1
  • 11
  • 24
3
votes
2 answers

Autofix directory structure based on package in scala

I have a file src/main/scala/foo.scala which needs to be inside package bar. Ideally the file should be inside src/main/scala/bar/foo.scala. // src/main/scala/foo.scala package bar // ... How can I auto-fix this issue throughout my project such…
tusharmath
  • 10,622
  • 12
  • 56
  • 83
3
votes
0 answers

Relationship between ScalaMeta, ScalaFix, and SemanticDB

I have the following information: Scalameta: has the ability to produce ASTs from a source file SemanticDB: Contains information about symbols from a parsed source file ScalaFix: is based on ScalaMeta and SemanticDB so it has the ability to access…
Gakuo
  • 845
  • 6
  • 26
2
votes
0 answers

scalafix.sbt.ScalafixFailed: TestError

I have a unit test written using scalatest and running fine locally. But on jenkins it fails with no specific error, just this: [error] (scalafixAll) scalafix.sbt.ScalafixFailed: TestError No test method is mentioned in traces, hence no hint about…
Mandroid
  • 6,200
  • 12
  • 64
  • 134
2
votes
1 answer

Scalafix: resolving object apply method

I have an object with some apply method defined and then use it object Ob { def apply(i: Int) = () def apply(s: String) = () } object Use { def someMethod(i: Int) = () Ob(1) someMethod(1) } When using scalafix/scalameta, I'm unable to…
Jacob Wang
  • 4,411
  • 5
  • 29
  • 43
1
vote
3 answers

Quasiquotes in Scalafix

Here is Spark 2.4 code using unionAll import org.apache.spark.sql.{DataFrame, Dataset} object UnionRewrite { def inSource( df1: DataFrame, df2: DataFrame, df3: DataFrame, ds1: Dataset[String], ds2: Dataset[String] ): Unit =…
mvasyliv
  • 1,214
  • 6
  • 10
1
vote
1 answer

Scala SymbolMatcher failing to match import prefix

I'm using the scalafix library to try to convert a project from scalaz to cats, but one particular attempt at removing imports (the first case in the following code) is failing. The relevant bits of code are: scalafix code: package fix import…
Charles_F
  • 186
  • 2
1
vote
1 answer

Why is scala.meta.Term.Param#toString dropping modifiers?

I'm trying to rename the parameter of an anonymous function using a semantic scalafix plugin. The relevant code looks like this: case Term.Apply(func, args) => args.collect { case Term.Block(List(Term.Function(List(arg), _))) => …
Corey Woodfield
  • 350
  • 2
  • 10
1
vote
0 answers

scalafix autofix plugin error "error: repeated argument not allowed here" when varargs are present in the codebase

I'm using varargs like below in my code base. def acceptVarargs[S](s: S*): Unit = {} def toVarArgs[T](s: Seq[T]) = acceptVarargs(s: _*) I'm using autofix plugin in my sbt project. I'm following the steps here to run the scalafix command. When I…
user51
  • 8,843
  • 21
  • 79
  • 158
1
vote
2 answers

Is there a way to prevent usage of a specific function provided by a dependency?

My application has a compile dependency to a library A. There is a specific function in this library which I know that causes performance problems. But it is not deprecated and if you don't have this prior information you would think that it is safe…
fcs
  • 926
  • 1
  • 8
  • 14
1
vote
1 answer

Scalameta's Semantic API

In Scalameta's tutorial, it notes that the Semantic API can be used for name resolution (println => _root_.scala.Predef.println). The FAQ "How do I use the Semantic API?" links to scalafix, but I was unable to find a tutorial or concrete examples. …
Sledge
  • 178
  • 13
0
votes
1 answer

How to use one or multiple SemanticRules with scalafix similar to scalameta's Transformer?

In the tutorial https://scalacenter.github.io/scalafix/docs/developers/tutorial.html I see how a SemanticRule is implemented for scalafix. I would like to call it directly in the source code on a Scala file which I have read from the disk and…
Baradé
  • 1,290
  • 1
  • 15
  • 35
0
votes
1 answer

Obtaining a SemanticDocument from a Scala source file using ScalaFix

What are the steps of parsing a Scala source file into a SemanticDocument using ScalaFix?
Gakuo
  • 845
  • 6
  • 26