silencer icon indicating copy to clipboard operation
silencer copied to clipboard

Silencer plugin suppresses compilation errors when scalafix semantic db is enabled

Open steinybot opened this issue 5 years ago • 8 comments

I had recently enabled the silencer sbt plugin and then started noticing really strange behaviour where I knew I had compilation errors but the sbt compile task would succeed. sbt test would also succeed but not actually run any tests.

It turns out that there is some sort of incompatibility between Silencer, Scalafix SemanticDB and Scala 2.13.1.

build.sbt:

scalaVersion := "2.13.1"
addCompilerPlugin(("com.github.ghik" % "silencer-plugin" % "1.4.4").cross(CrossVersion.full))
addCompilerPlugin(scalafixSemanticdb)

src/main/scala/Main.scala:

object Main extends App {
  asldfkhaklsdgjkldfjv
}

project/build.properties:

sbt.version=1.3.7

project/plugins.sbt:

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.11")

steinybot avatar Jan 28 '20 11:01 steinybot

Here is a repo that reproduces the problem https://github.com/steinybot/bug-reports/tree/silencer/scalafix-incompatible

steinybot avatar Jan 28 '20 11:01 steinybot

Thanks for the report and reproduction. Without looking into details right now, this may be caused by the same problem as https://github.com/ghik/silencer/issues/7 which is ultimately a problem in the semanticdb compiler plugin: https://github.com/scalameta/scalameta/issues/1505

Please try this workaround: https://github.com/ghik/silencer/issues/7#issuecomment-383284150

ghik avatar Jan 28 '20 12:01 ghik

@ghik that does not fix the bug for me

benwaffle avatar Feb 03 '20 23:02 benwaffle

We were having this problem over here, I didn't spot this open issue until just now: https://github.com/scalameta/metals/issues/1409

davesmith00000 avatar Feb 15 '20 20:02 davesmith00000

This is most likely still the fault of scalameta plugin. The workraround probably does not work for Scala 2.13.1 because reporters have been refactored in scalac by @lrytz (https://github.com/scala/scala/pull/8338). semanticdb plugin needs to be updated to this new implementation.

Here's the 2.13.1+ version of silencer's SuppressingReporter: https://github.com/ghik/silencer/blob/master/silencer-plugin/src/main/scala-2.13%2B/com/github/ghik/silencer/SuppressingReporter.scala

The semanticdb plugin needs to do something similar with its SemanticdbReporter: https://github.com/scalameta/scalameta/blob/master/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/SemanticdbReporter.scala

ghik avatar Feb 17 '20 09:02 ghik

This is most likely going to be fixed by https://github.com/scalameta/scalameta/pull/1992

ghik avatar Feb 18 '20 12:02 ghik

I have this issue when using scala 2.13.1, scalafix 0.9.11 and silencer 1.6.0.

Updating to scalafix 0.9.12 fixes the problem for me.

timcharper avatar Mar 26 '20 01:03 timcharper

I seem to be having this issue with Scala 2.12.17. Since the fix in https://github.com/scalameta/scalameta/pull/1992 is for Scala 2.13.1+, I wonder if I maybe need an older version that does not have this issue.

I have silencer 1.7.12. I've tried both WartRemover 2.4.21 and 3.0.11. Even without Scalafix, just setting semanticdbEnabled causes problems. But normally I'm using Scalafix 0.10.4.

Update: It looks like there is a different reporter implementation for Scala 2.12.10 vs. 2.12.13 so maybe they did fix it and I just don't have a new enough version of SemanticDB.

bmarker avatar Mar 15 '23 07:03 bmarker