Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 19 15:01
    benwaffle commented #982
  • Sep 19 08:19
    UkonnRa commented #982
  • Sep 13 08:45
    aeons commented #978
  • Sep 12 21:18
    olafurpg commented #978
  • Sep 12 18:05
    aeons commented #978
  • Sep 12 13:49
    ingarabr commented #981
  • Sep 12 12:19
    olafurpg commented #981
  • Sep 12 12:18
    olafurpg commented #978
  • Sep 12 12:03

    olafurpg on gh-pages

    Deploy website Deploy website … (compare)

  • Sep 12 11:15

    olafurpg on gh-pages

    Deploy website Deploy website … (compare)

  • Sep 12 11:07

    olafurpg on v0.9.7

    (compare)

  • Sep 12 11:06

    olafurpg on master

    Cross-build against 2.13. Remove Scala 2.13 from build fo… Fix failing CI tests. 2.12.8 w… and 3 more (compare)

  • Sep 12 11:06
    olafurpg closed #980
  • Sep 12 11:06
    olafurpg closed #978
  • Sep 12 10:56
    olafurpg synchronize #980
  • Sep 12 10:21
    olafurpg synchronize #980
  • Sep 12 10:07
    olafurpg synchronize #980
  • Sep 12 09:56

    olafurpg on gh-pages

    Deploy website Deploy website … (compare)

  • Sep 12 09:51
    olafurpg edited #980
  • Sep 12 09:50
    olafurpg commented #982
Win Wang
@wiwa
how would i pass multiple arguments to a scalafix cli parameter? something like
--scalac-options [A, B]? somehow doesn't seem to work
Win Wang
@wiwa
the answer is
--scalac-options A --scalac-options B
Ólafur Páll Geirsson
@olafurpg
@wiwa if you are programmatically invoking scalafix then I would look at the build tools api in scalafix-interfaces. It has a java library api with extensive javadocs
That api is used by the sbt plugin and maven plugin.
TATSUNO Yasuhiro
@exoego

Hello, I would like to perform scalatest's scalafix rule from GitHub.
I know it is possible to add a dependency to scalafixDependencies described in https://github.com/scalatest/autofix/blob/master/3.0.x/README.md,
but I need running it from GitHub since it is a easy way to integrate scalafix rule into Scala Steward (A bot for updating Scala dependencies).

I tried the below sbt command for scio

scalafix github:spotify/scio/AddMissingImports

will dowloads https://raw.githubusercontent.com/spotify/scio/master/scalafix/rules/src/main/scala/fix/AddMissingImports.scala from GitHub, and works fine.

However, the below does not works.

test:scalafix github:scalatest/autofix/RenameDeprecatedPackage

Sicne salafix try to download
https://raw.githubusercontent.com/scalatest/autofix/master/scalafix/rules/src/main/scala/fix/RenameDeprecatedPackage.scala
but actual path is
https://raw.githubusercontent.com/scalatest/autofix/master/3.0.x/rules/src/main/scala/org/scalatest/autofix/v3_0_x/RenameDeprecatedPackage.scala

I could not find a document for scalafix's github: schema handling.
Is it possible to specify scalafix rule in arbitrary project strcture, like in scalatest/autofix repo ?
Or scalafix rule authors should follow some convetion regarding project structure?

TATSUNO Yasuhiro
@exoego
Ah, sorry, I found a document regarding schema on https://scalacenter.github.io/scalafix/docs/developers/tutorial.html#run-the-rule-from-source-code
I understand that scalafix command accept https://... schema too.
It is in "Developer Guide" section, not "User guide" section... ;-)
Vladyslav Pekker
@agilesteel
Scala 2.13.0 doesn't like the -Ywarn-adapted-args argument anymore and therefore the NoAutoTuplingrule doesn't work for me even with -Xlint:adapted-args. I assume this is a known issue. Is there a workaround for this?
Mustafa Kuscu
@mcku
hi, i have a working scalafix + sbt setup but @SuppressWarnings(Array("all")) annotation apparently has no effect.
Ingar Abrahamsen
@ingarabr
I'm trying to extract the implicit parameter from a function that does not have any parameter(other than the implicit ones). Something like this def a[A](implicit s: MyImplicit[A]): A = ???. I'm able to get it to work when I add call parentheses using term.synthetic. The difference in the ADT from semanticdb is that the one with call parentheses is wrapped in a Term.Apply. Should samanticdb had wrapped the Term in an apply or is there any other way I can get hold of the implicit parameter? Here is a complete example including the AST https://gist.github.com/ingarabr/c8c81fb2f2e0ad05bbeb882d39de04c1
Holden Karau
@holdenk
What's the best way to handle types which have been renamed on import when you want to rewrite those types?
Holden Karau
@holdenk
Also is there a way to order patches?
Holden Karau
@holdenk
nvm I think I can just re-order how i'm doing the traversal and that will make my life much happier
Marcelo Cenerino
@marcelocenerine
@mcku could you post an example of @SuppressWarnings not working?
Mustafa Kuscu
@mcku

@marcelocenerine

 @SuppressWarnings(Array("all"))
 def dummyFunc() = { 
      "a";  // expect a warning here 
      "b"
  }

emits this warning: a pure expression does nothing in statement position; multiline expressions might require enclosing parentheses

and is not suppressed
Ólafur Páll Geirsson
@olafurpg

What's the best way to handle types which have been renamed on import when you want to rewrite those types?

@holdenk it's usually best to work at the level of symbols instead of trees using SymbolMatcher https://scalacenter.github.io/scalafix/docs/developers/symbol-matcher.html

SymbolMatcher helps you avoid matching against hardcoded identifier names

nvm I think I can just re-order how i'm doing the traversal and that will make my life much happier

That's the recommended way to order patches : )

Holden Karau
@holdenk
awesome, going to try and rewrite my first attempt at this using those 2 today :)
Holden Karau
@holdenk
If I want to replace a tree with a symbol is there a "right" way to do that?
Alternatively replacesymbol on a subtree?
Holden Karau
@holdenk
e.g. Patch.replaceTree(h, "org.apache.spark.sql.SQLContext") but instead provide a symbol so it isn't always the long name?
Holden Karau
@holdenk
Also what's the right way to write a symbol of a templated type (e.g. RDD[String])?
Ólafur Páll Geirsson
@olafurpg
There isn't any "right" way to accomplish that. The Scalafix patch api is mostly token/string based which gives you a lot of flexibility in terms on how to transform source code but it makes it easy to produce invalid code
to write a type such as RDD[String] I would maybe use something likePatch.replaceTree(Tree, "RDD[String]") + Patch.addGlobalImport(Symbol("spark/RDD#")).
I can't remember the details of how addGlobalImport de-duplicates in the case the symbol is already imported in scope. Scalafix unfortunately doesn't have an API to lookup a name in the scope
Julien Tournay
@jto

Hi there!

Is there way to define and use scalafix as a project submodule ? I’d like to create rules that are (mostly) linters and are to be applied only on some submodules of the same project (they are not public). I could use the file:… syntax but it’s a bit limited.

put simply, I'd like my project directory to look smth like:

├── project
├── commons
├── submoduleA
├── submoduleB
└── scalafix

and I want to rules defined in scalafix to be applied on submoduleA and submoduleB

It seems that class:fix.MyFix should do the trick but looking at set-scalafix, it seems to restrict what the ClassLoader can access, effectively hidding my classes
Holden Karau
@holdenk
@olafurpg is there a good way to match against RDD[String]?
I know in the 0.9.5 addGlobal import isn't de-duplicating right now
Ólafur Páll Geirsson
@olafurpg
@jto one way to accomplish that today would be to run scalafix/publishLocal first, but that's not a great solution
file:... is probably the best workaround
a better solution would be to extend sbt-scalafix to allow loading custom rules from the classpath of a project in the build. It's not implemented at the moment but all the ingredients are there

@holdenk you can try to write two symbol matchers, one for RDD and one for String and then

case Type.Apply(rddMatcher(_), List(stringMatcher(_))) =>

I haven't tried running that but that what I would first try if matching RDD[String]

that will btw only match type tree nodes, not term exressions that have the type RDD[String]
there's no API to get the type of a term at the moment so it's not possible to for example know if an expression such as foo.column("bar") has type RDD[String]
Holden Karau
@holdenk
@olafurpg So looking at the symbol info I see Some(local1 => val local r2: RDD[String]) but when I try and match against it I'm not having a happy time
Is this just not enough type information present or am I building my matcher wrong?
Ólafur Páll Geirsson
@olafurpg
that local1 symbol has type RDD[String]. You can look at the signature of a symbol with .info.signature which will have a shape that looks something like this
ValueSignature(TypeRef(NoType, Symbol("spark...RDD#"), List(TypeRef(NoType, Symbol("java/lang/String#"), Nil))
note that the signature of a symbol column may show a generic type like RDD[T] even if the expression foo.column("bar") has the type RDD[String]. It's a bit tricky to explain but in the general case, Scalafix is not able to tell you the type of an expression. Scalafix only knows the generic signature of symbols.
in the case of local variables, the signature of the symbol will be identical to the type of the variable
Holden Karau
@holdenk
Cool, I think I can get away with doing migrations based on the outer type mostly, although I'll have to drop a few of them
Thanks!
Marcelo Cenerino
@marcelocenerine
@mcku I suppose the warning you are getting is not being emitted by a Scalafix rule but by the Scala compiler: https://github.com/scala/scala/blob/1e6315438a1492a6c2b75a6d4cb985e6a35b5ed7/src/compiler/scala/tools/nsc/typechecker/Typers.scala#L2552-L2553
@SuppressWarnings in the context of Scalafix can be used to suppress rewrites/warnings emitted by rules: https://scalacenter.github.io/scalafix/docs/users/suppression.html
Mustafa Kuscu
@mcku
@marcelocenerine thank you
Ferdinand Svehla
@fsvehla
This rule produces a very strange result
    Patch.replaceSymbols(
      "monix.eval.Task.raiseError" -> "zio.Task.fail",
      "monix.eval.Task"            -> "zio.Task"
    )
It results in TaskTask.fail, instead of Task.fail