Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 07 18:18
    mackenziestarr opened #1712
  • Dec 01 00:32
    scala-center-steward[bot] opened #1711
  • Dec 01 00:32

    scala-center-steward[bot] on sbt-scoverage-2.0.6

    Update sbt-scoverage to 2.0.6 (compare)

  • Dec 01 00:32
    scala-center-steward[bot] opened #1710
  • Dec 01 00:32

    scala-center-steward[bot] on sbt-1.7.3

    Update sbt to 1.7.3 (compare)

  • Dec 01 00:32
    scala-center-steward[bot] opened #1709
  • Dec 01 00:32

    scala-center-steward[bot] on scala-java8-compat-0.9.1

    Update scala-java8-compat to 0.… (compare)

  • Dec 01 00:32
    scala-center-steward[bot] opened #1708
  • Dec 01 00:32

    scala-center-steward[bot] on scala-collection-compat-2.9.0

    Update scala-collection-compat … (compare)

  • Dec 01 00:31
    scala-center-steward[bot] opened #1707
  • Dec 01 00:31

    scala-center-steward[bot] on scala3-compiler-3.2.1

    Update scala3-compiler, scala3-… (compare)

  • Dec 01 00:31
    scala-center-steward[bot] opened #1706
  • Dec 01 00:31

    scala-center-steward[bot] on interface-1.0.11

    Update interface to 1.0.11 (compare)

  • Dec 01 00:31
    scala-center-steward[bot] opened #1705
  • Dec 01 00:31

    scala-center-steward[bot] on sbt-ci-release-1.5.11

    Update sbt-ci-release to 1.5.11 (compare)

  • Dec 01 00:31
    scala-center-steward[bot] opened #1704
  • Dec 01 00:31

    scala-center-steward[bot] on sbt-version-policy-2.1.0

    Update sbt-version-policy to 2.… (compare)

  • Nov 30 18:16
    SethTisue edited #1699
  • Nov 30 18:15
    SethTisue commented #1699
  • Nov 30 15:39
    mvasyliv commented #1653
Jason Pickens
@steinybot
I’ve been thinking about a tool that would help minimise code to create minimal reproductions for bug reports. I’m wondering if I could do it with scalafix or if I should use scalameta directly.
AFAIK scalafix rules only operate on a single document but I would probably need information for the entire project
I was hoping I could use Patch but the implementations are all internal and there isn’t much that can be done with Patch directly.
Brice Jaglin
@bjaglin
@steinybot I think scalafix will get in the way more than helping you if your goal is to cut off/bisect syntax trees - I would POC something against scalameta indeed
(that sounds like an amazing tool!)
Jason Pickens
@steinybot
I suspected that would probably be the case. I haven’t figured out exactly how it should work yet.
Ólafur Páll Geirsson
@olafurpg
@steinybot there’s maybe some prior art here https://stryker-mutator.io/docs/stryker4s/getting-started/
Natan Silnitsky
@natansil

Hi,
Kinda late to the 2.13 party
I'm getting the following error when running scalafix dependency:RoughlyMapValues@org.scala-lang.modules:scala-collection-compat:2.6.0 in order to fix the mapValues MapView errors:
[error] (Compile / scalafix) scalafix.sbt.InvalidArgument: Unknown rule 'RoughlyMapValues'

I've added ThisBuild / scalafixDependencies += "org.scala-lang.modules" %% "scala-collection-migrations" % "2.6.0" to build.sbt
I've also added addCompilerPlugin(scalafixSemanticdb), scalacOptions ++= List("-Yrangepos", "-P:semanticdb:synthetics:on"),

Is this error expected? what am I missing?

Ólafur Páll Geirsson
@olafurpg
@natansil what happens if you run “scalafix RoughlyMapValues”?
the “dependency:” syntax is only needed if you dont configure scalafixDependencies
Should it be “scala-collection-migrations” instead of “-compat”?
Natan Silnitsky
@natansil
@olafurpg both of your suggestions fail (while Collection213Upgrade doesn't fail)
scalafix dependency:RoughlyMapValues@org.scala-lang.modules:scala-collection-migrations:2.6.0
[error] (Compile / scalafix) scalafix.sbt.InvalidArgument: Unknown rule 'RoughlyMapValues'
scalafix RoughlyMapValues
[error] (Compile / scalafix) scalafix.sbt.InvalidArgument: Unknown rule 'RoughlyMapValues'
scalafix Collection213Upgrade
[info] compiling 69 Scala sources...
Ólafur Páll Geirsson
@olafurpg
Im not familiar with the RoughlyMapValues rule, have you reported an issue to that repo?
If Collection213Upgrade ia working successfully then it sounds like everything is OK on your side
Natan Silnitsky
@natansil
Cool. Thanks! I will report the issue then...
Brice Jaglin
@bjaglin
Oliver Schrenk
@oschrenk
I have a project still running sbt 1.4.9. Is there a scalafix rule to (help me) migrate to sbt 1.5.7?
Oliver Schrenk
@oschrenk

At https://eed3si9n.com/sbt-1.5.0 I found

scalafix --rules=https://gist.githubusercontent.com/eed3si9n/57e83f5330592d968ce49f0d5030d4d5/raw/7f576f16a90e432baa49911c9a66204c354947bb/Sbt0_13BuildSyntax.scala *.sbt project/*.scala

But it fails with

 scalafix.sbt.InvalidArgument: 2 errors
Oliver Schrenk
@oschrenk

Oh. That page doesn't mention to install scalfix via coursier. It's only mentioned at syntactic Scalafix rule for unified slash syntax

Curious why the same command works then but not from within sbt.

Ólafur Páll Geirsson
@olafurpg
@oschrenk the sbt plugin has its own cli parser to integrate natively with sbt (for example, allow tab completions). The sbt plugin also has a different execution model, an unscoped “scalafix” command in the sbt shell runs scalatix independently for every project in the build (with the liat of sources and classpath configured per project/config pair) while the cli runs once against the recursive list of scala files
Also, the sbt shell doesn’t do glob expansion
earldouglas
@earldouglas:matrix.org
[m]
Is there a way to set the Scalafix configuration directly via an sbt setting, rather than through an external .scalafix.conf file?
I'm writing an sbt plugin that uses a Scalafix rule, and I don't want users to need to add a .scalafix.conf file.
Ólafur Páll Geirsson
@olafurpg
@earldouglas:matrix.org one workaround is to generate a .scalafix.conf file from the sbt plugin
You can configure sbt-scalafix to read the config from a custom file, which can live under target/ so that users don't see it
Brice Jaglin
@bjaglin

@earldouglas:matrix.org another possibility is to inject CLI args programmatically

Either by redefining scalafix/scalafixAll

Compile / scalafix := (Compile /scalafix).partialInput(" --settings.DisableSyntax.noSemicolons DisableSyntax").evaluated // also needed for Test
scalafixAll := scalafixAll.partialInput(" --settings.DisableSyntax.noSemicolons DisableSyntax").evaluated

or by declaring a new task using the built-in input keys (safer and less confusing for the end-user....)

lazy val lint = taskKey[Unit]("")
lint := scalafixAll.toTask(" --settings.DisableSyntax.noSemicolons DisableSyntax").value
earldouglas
@earldouglas:matrix.org
[m]
@olafurpg: Thanks, that's what I'm currently doing. It works, but it feels like there could be a better way.
@bjaglin: Ah ha, that looks like what I need. Thanks!
earldouglas
@earldouglas:matrix.org
[m]
:point_up: Edit: @bjaglin: Thanks, that looks like what I need. Is there a way to have the redefined compile use this, since I'm using scalafixOnCompile? Or could I re-redefine compile to do so?
Brice Jaglin
@bjaglin
@earldouglas:matrix.org scalafix is evaluated by compilewhen scalafixOnCompile is set (https://github.com/scalacenter/sbt-scalafix/blob/0a4dfc6a32d67b701235876fe5658f04c9c9687a/src/main/scala/scalafix/sbt/ScalafixPlugin.scala#L108-L116), so redefining scalafix like suggested in the first option should do the trick.
earldouglas
@earldouglas:matrix.org
[m]
That worked; thanks!
Brice Jaglin
@bjaglin

@/all Thanks to all our contributors, Scalafix 0.10.0-RC1 is out with the following highlights:

  • Breaking changes for rule authors (see release notes)
  • Compatibility checks when loading external rules
  • Deprecated keys & dependency to coursier-small removed from ScalafixPlugin
  • sbt-scalafix now only supports sbt 1.3+
  • scalafixEnable no longer overrides projects' scalaVersion unless really necessary
  • A new logo, visible in the docs -> https://scalacenter.github.io/scalafix/

More details on the full release notes:

Your user/rule author feedback is welcome on this release candidate.
If no major issue or obstacle is found in RC1, a final release will be cut on April 7th.

Jack Koenig
@jackkoenig
How should one include custom rules in ScalaFix without them being published? I've used --rules file:<path> in the past, but it seems to complain about missing SemanticDB for a SemanticRule, which is a little odd because ScalaFix needs to compile the rule anyway
Brice Jaglin
@bjaglin
@jackkoenig non-published rules can indeed be compiled on the fly via the --rules file:<path> syntax (https://scalacenter.github.io/scalafix/docs/developers/tutorial.html#using-file). Missing SemanticDB does not seem related to that feature but to the scalafix invocation itself. Do semantic built-in rules like RemoveUnused work? If you are using sbt, https://scalacenter.github.io/scalafix/docs/developers/local-rules.html could be an option for running project-specific rules.
Brice Jaglin
@bjaglin

scalafix & sbt-scalafix 0.10.0 are out with the following highlights:

  • New RedundantSyntax built-in rule
  • Bug fixes in ExplicitResultTypes & RemoveUnused
  • Breaking changes for rule authors (see release notes)
  • Compatibility checks when loading external rules
  • Deprecated keys & dependency to coursier-small removed from ScalafixPlugin
  • sbt-scalafix now only supports sbt 1.3+
  • sbt scalafixEnable no longer overrides projects' scalaVersion unless really necessary
  • A new logo, visible in the docs -> https://scalacenter.github.io/scalafix/

More details on the full release notes:

Thanks to the 6 contributors!

Jinto Thomas
@ttj4
hello everyone, I'm very new to scalafix, I'm testing out the scalafix cli, I have added the dependency as "ch.epfl.scala" %% "scalafix-cli" % "0.10.0-RC1" (i'm on scala 2.13.8) and getting this error not found: https://repo1.maven.org/maven2/ch/epfl/scala/scalafix-cli_2.13/0.10.0-RC1/scalafix-cli_2.13-0.10.0-RC1.pom
https://repo1.maven.org/maven2/ch/epfl/scala/scalafix-cli_2.13.8/0.10.0-RC1/scalafix-cli_2.13.8-0.10.0-RC1.pom this is the link I see in maven central, scalafix-cli_2.13 vs scalafix-cli_2.13.8
should I use it like "ch.epfl.scala" % "scalafix-cli_2.13.8" % "0.10.0-RC1"
Brice Jaglin
@bjaglin
Hi @ttj4 , I am assuming you use sbt? If so you should use "ch.epfl.scala" % "scalafix-cli" % "0.10.0" cross CrossVersion.full if you want to get the artifact safely. But if you want to run scalafix rules from your application, I recommend you use the Java API in scalafix-interfaces to avoid challenges with scala versions - scalafix-cli is really meant to be used as a CLI application, not directly (even though it contains the implementation of ScalafixArguments). scalafix-interfaces is what the most common scalafix clients (sbt, mill, maven, metals) use.
Jinto Thomas
@ttj4
ah I see, let me look into scalafix-interfaces then
Jinto Thomas
@ttj4

I think it might take sometime for me to change to the code with scalafix-interfaces. Now I;m actually stuck with this error, it doesn't recognise anything from scalafix.conf

SCALAFIX ARGS : List(--scalac-options, -Wunused, --scala-version, 2.13.8, --files, /Users/user/workspace/org/common/common, --config, scalafix.conf, --classpath, /Users/user/workspace/org/common/common-library/target/classes:/Users/user/workspace/org/common/library/target/test-classes:/Users/user/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.8/scala-library-2.13.8.jar, --syntactic)
error: 26 errors
[E0] Unknown rule 'DurationIsFinite'
[E1] Unknown rule 'FixCollectionConverters'
[E2] Unknown rule 'FixFutureConverters'
[E3] Unknown rule 'FixUnit'
[E4] Unknown rule 'FixArrayDeep'
[E5] Unknown rule 'FixPostfixSyntax'
[E6] Unknown rule 'FixExecutionContextGlobal'
[E7] Unknown rule 'FixExplicitRight'
[E8] Unknown rule 'FixSymbolLiterals'
........

is it something you have seen before?

Brice Jaglin
@bjaglin

it doesn't recognise anything from scalafix.conf

Well, it looks like it does since it's trying to run the default rules declared there, right? I see these are not built-in rules though, where are these defined? Aren't you missing --tool-classpath?

Also, you would probably benefit from using the with* methods from the Java API instead of passing untyped arguments I guess.
Jack Koenig
@jackkoenig
How can I invoke community rules running ScalaFix CLI? I have the dependency on my classpath (eg. org.scala-lang::scala-rewrites:0.1.3 trying to run rule fix.scala213.ScalaSeq). I have fix.scala213.ScalaSeq listed in rules inside of my .scalafix.conf but get the error error: {"rules": ["fix.scala213.ScalaSeq"]} has no field 'fix'.
I have tried all kind of spellings of the rule, and I can confirm the scala-rewrites jar contains META-INF/services/scalafix.v1.Rule with several rules listed, including fix.scala213.ScalaSeq
Brice Jaglin
@bjaglin
@jackkoenig did you try to run the rule explicitly as a CLI arg instead of in the config file to see if that was working?
Jinto Thomas
@ttj4
@bjaglin I thought toolClass path will be picked from the default value, I cannot actually see any samples where --tools-classpath is passed. meanwhile I looked at the maven plugin, and came up with a simple test to test the interfaces api
    val pluginClassLoaderWithScalafix = getClass.getClassLoader
    val scalafix = Scalafix.classloadInstance(pluginClassLoaderWithScalafix)
val config = ConfigFactory.parseResources("scalafix.conf")
    val rules = config.getStringList("rules")
    scalafix
      .newArguments()
          .withRules(rules)
      .run()
but this also produces the same result - unknown rule.
Brice Jaglin
@bjaglin

@ttj4

I thought toolClass path will be picked from the default value

what do you mean by default value? scalafix needs to know whereFixUnit is defined, it cannot tell where to load external rules from. I assume FixUnit is a rule you wrote, but I can't tell if there are part of your project (https://scalacenter.github.io/scalafix/docs/developers/local-rules.html) or available in published as artifacts (https://scalacenter.github.io/scalafix/docs/developers/tutorial.html#publish-the-rule-to-maven-central) ? Both sbt-scalafix and mill-scalafix allow loading external rules, check their usage of withToolclasspath .