This room is no longer active, please join the rest of the scalameta community on https://discord.gg/8AHaqGx3Qj
mlachkar on gh-pages
Deploy website Deploy website … (compare)
bjaglin on main
bump coursier Merge pull request #1732 from b… (compare)
mlachkar on gh-pages
Deploy website Deploy website … (compare)
bjaglin on scalameta-4.7.3
Update scalameta, semanticdb-sc… fix ambiguous overload added in… scalameta 4.7.0 deprecated unap… (compare)
bjaglin on main
docs: add note about final 2.11… fix dead link Merge pull request #1730 from b… (compare)
scala-center-steward[bot] on mdoc-2.3.7
Update mdoc, sbt-mdoc to 2.3.7 (compare)
scalafix
is evaluated by compile
when 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.
@/all Thanks to all our contributors, Scalafix 0.10.0-RC1 is out with the following highlights:
scalafixEnable
no longer overrides projects' scalaVersion unless really necessaryMore 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.
--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.
scalafix & sbt-scalafix 0.10.0 are out with the following highlights:
RedundantSyntax
built-in ruleExplicitResultTypes
& RemoveUnused
sbt scalafixEnable
no longer overrides projects' scalaVersion unless really necessaryMore details on the full release notes:
Thanks to the 6 contributors!
"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
"ch.epfl.scala" % "scalafix-cli_2.13.8" % "0.10.0-RC1"
"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.
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?
with*
methods from the Java API instead of passing untyped arguments I guess.
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'.
scala-rewrites
jar contains META-INF/services/scalafix.v1.Rule
with several rules listed, including fix.scala213.ScalaSeq
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()
@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 .
.withToolClasspath(urlClassLoaderWithExternalRule)
if you are using external rules.
@mlachkar I do have a follow-up question though, I'm on scala 2.13.8, I'm unable add scala-collection-migrations
as my external rule due to issues with scala version (artifact available in the central repo is <dependency org="org.scala-lang.modules" name="scala-collection-migrations_2.12" rev="2.7.0"/>
I'm passing withToolClasspath
with the following (I'm using coursier to pull them, and is calling the interface api to run the scalafix)
.addDependencies(
dep"org.scala-lang.modules:scala-collection-compat_2.13:2.7.0",
dep"org.scala-lang:scala-rewrites_2.13:0.1.3",
dep"com.github.liancheng:organize-imports_2.13:0.6.0",
dep"ch.epfl.scala:scalafix-rules_2.13:0.10.0",
dep"com.github.vovapolu:scaluzzi_2.13:0.1.21",
dep"io.github.ghostbuster91.scalafix-unified:unified_2.13:0.0.8")
)
.run()
.map(_.toPath)
Is there any workaround for this? I saw scala-collection-compat do support 2.13.8
ExplicitResultTypes
.I'm using coursier to pull them
Do you mean you are using coursier yourself? https://www.javadoc.io/static/ch.epfl.scala/scalafix-interfaces/0.10.0/scalafix/interfaces/ScalafixArguments.html#withToolClasspath-java.util.List-java.util.List-java.util.List- does it for you. I don't think the maven plugin uses that, that's why I recommended looking at the sbt or mill plugin.
➜ cat .scalafix.conf
fix.scala213{}
scala-collection-migrations
repo. meanwhile, I was looking at the local rules (https://github.com/scalacenter/scalafix/blob/main/docs/developers/local-rules.md#as-a-separate-sub-project), is it something i can leverage with scalafix-interface?
@ttj4
unfortunately I wasn't sure where to look for scala-collection-migrations repo
https://github.com/scala/scala-collection-compat/tree/main/scalafix
I was looking at the local rules
Local rules is a feature of sbt-scalafix, so it's built on top of scalafix-interface. Maybe we can zoom out a bit - can you tell us what you are trying to achieve?
Unknown rule 'Collection213Upgrade'
(for all rules in here) as per the repo readme I need to add scala-collection-migrations
as dep which is not available for 2.13ThisBuild / scalafixDependencies += ...
I had to include the same line into the libraryDependencies
otherwise it wasn't pull and the Scalafix rule cannot be applied. Do I miss something here ? Maybe it's normal to do so ?
Hello all, I'm a GSoC contributor for scalafix this summer ( https://summerofcode.withgoogle.com/programs/2022/projects/gQ08FcXb )
I'm running scalafix and would like to use the --setting arg to provide a different config for ExplicitResultTypes.memberKind
, but whatever value I provide is interpreted as string instead of list, eg
sbt "scalafix --no-cache --settings.ExplicitResultTypes.memberKind=List(MemberKind.Var)"
(also tried [Var]
or List(Var)
would you know if this should work and how to provide a list or valid string?
dependsOn(
my-scalafix-rules% ScalaConfig
) and i try and run the rule I get Unknown rule 'X'
(where X is a rule defined in my-scalafix-rules/src/main/scalafix/resources/META-INF/scalafix.v1.Rule
, what am I doin' wrong here?
Hi!
Is there a way to run scala-fix programatically (some kind of SDK API) instead of adding sbt plugin?
Here is my use-case:
I have scala app which prepares zipped sbt projects. During generation the temporary folder for template project I want to run scala-fix which will allow me to change the syntax from scala 2 into scala 3.
Using sbt as separate proccess is not considered as it locks repository. And I want to generate templates in parallel.
Hi, everyone! Is there a way to apply Scalafix (via commands scalafixAll --check
and scalafixAll
) to IntegrationTest
sbt configuration? I've followed the workaround from #331 like this:
ThisBuild / IntegrationTest / scalafix := ScalafixPlugin.scalafixTaskImpl(IntegrationTest).evaluated
However, scalafixTaskImpl
is not reachable. By default, scalafixAll
ignores sources in /it/
.