wartremover-contrib icon indicating copy to clipboard operation
wartremover-contrib copied to clipboard

How can I load contrib warts into IntelliJ IDEA?

Open umireon opened this issue 2 years ago • 6 comments

My question

I tried to use contrib warts on this repository on IntelliJ IDEA. Contrib warts were successfully loaded on SBT builds and it procuded wart violations with SBT. However, when I instructed IntelliJ IDEA to build Scala classes, the contrib warts were completely ignored by IntelliJ IDEA's compiler. Warts that are built in Wartremover core could be loaded into IntelliJ IDEA's compiler and it produced wart violation as expected. How can I load contrib warts into IntelliJ IDEA?

My code

https://github.com/umireon/umireon-wartremover-contrib-intellij-idea/tree/intellij-idea-cannot-load-wartremover-contrib-classes

We prefer the -Xfatal-warnings flag and this problem also prevents us to use many IntelliJ IDEA features.

This problem causes the following error:

IntelliJ IDEA cannot load contrib warts

scalac: load failure warts = (org.wartremover.contrib.warts.Apply,scala.ScalaReflectionException: object org.wartremover.contrib.warts.Apply not found.)

I checked the configuration of Scala compiler on Intellij IDEA and it revealed that it loaded Wartremover core but didn't load Wartremover contrib.

The Scala compile on IntelliJ IDEA only loads wartremover not wartremover-contrib

Thanks in advance.

Best,

umireon avatar Aug 31 '22 08:08 umireon

@xuwei-k do you have any idea how to get contrib warts work in IntelliJ IDEA?

tsawada avatar Oct 18 '22 07:10 tsawada

@xuwei-k having same issue with intellij idea, I think it should be addressed somehow. currently, it's not possible to use contrib wart with IntelliJ idea.

scalac: load failure warts = (org.wartremover.contrib.warts.DiscardedFuture,scala.ScalaReflectionException: object org.wartremover.contrib.warts.DiscardedFuture not found.)

hagay3 avatar Apr 13 '23 09:04 hagay3

@hagay3 I believe there's something missing in the IntelliJ Scala plugin. I filed an issue here: https://youtrack.jetbrains.com/issue/SCL-21154

tsawada avatar Apr 15 '23 07:04 tsawada

This seems to be fixed in IntelliJ IDEA latest 2023.3 EAP at least (which will be soon future 2023.3 release). I was using EAP version "Build #IU-233.9802.14, built on October 12, 2023". I got the same kind of failure with the EAP build: scalac: load failure warts = (org.wartremover.contrib.warts.DiscardedFuture,scala.ScalaReflectionException: object org.wartremover.contrib.warts.OldTime not found.) when running scala in IDEA. But updating Scala plugin to the latest one 2023.3.489 fixed the issue for me.

So basically, update to latest IDEA and update Scala plugin should make it work.

mvestola avatar Oct 22 '23 19:10 mvestola

This seems to be fixed in IntelliJ IDEA latest 2023.3 EAP at least (which will be soon future 2023.3 release). I was using EAP version "Build #IU-233.9802.14, built on October 12, 2023". I got the same kind of failure with the EAP build: scalac: load failure warts = (org.wartremover.contrib.warts.DiscardedFuture,scala.ScalaReflectionException: object org.wartremover.contrib.warts.OldTime not found.) when running scala in IDEA. But updating Scala plugin to the latest one 2023.3.489 fixed the issue for me.

So basically, update to latest IDEA and update Scala plugin should make it work.

Seems that I was partly wrong. Still getting the same issue even with the latest Intellij IDEA releases. I have following line in my build.sbt:

wartremoverErrors += ContribWart.OldTime,

If I comment that out and run sbt update on IDEA (by clicking the sbt refresh icon) and then uncomment it and run sbt update again -> I get no errors. But after any dependency is updated and sbt update happens automatically by IDEA again, it suddenly starts producing the same error again. Seems really weird but definitely there is still some issue in the IDEA or IDEA's scala plugin...

mvestola avatar Oct 23 '23 13:10 mvestola

The workaround suggested here seems to be working for me.

ncreep avatar Nov 01 '23 12:11 ncreep