detekt / detekt-intellij-plugin

detekt plugin for IntelliJ
https://plugins.jetbrains.com/plugin/10761-detekt
Apache License 2.0
297 stars 39 forks source link

plugin crashes with WindowsPath error #494

Open mutschml opened 11 months ago

mutschml commented 11 months ago

I am not sure if this is a Problem of detekt itself or the plugin. But detekt-plugin in intellij always crashes when I open my project.

I use detekt plugin Version 2.1.0, on Windows 11. The project uses kotlin 1.7.10 and java 11

One thing that could be related to the bug might be that I changed the target-directory of my maven project to a different Filesystem; in this case to a ram-disk. so some generated files an the class-files are there.

Here is the stacktrace:

Unexpected error while running detekt analysis

java.lang.IllegalArgumentException: 'other' has different root at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:404) at java.base/sun.nio.fs.WindowsPath.relativize(WindowsPath.java:42) at io.github.detekt.parser.KtCompiler.createKtFile(KtCompiler.kt:41) at io.gitlab.arturbosch.detekt.core.tooling.ParsingStrategyKt$contentToKtFile$1.invoke(ParsingStrategy.kt:13) at io.gitlab.arturbosch.detekt.core.tooling.ParsingStrategyKt$contentToKtFile$1.invoke(ParsingStrategy.kt:11) at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$filesToAnalyze$1.invoke(Lifecycle.kt:38) at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$filesToAnalyze$1.invoke(Lifecycle.kt:38) at io.gitlab.arturbosch.detekt.core.util.PerformanceMonitor.measure(PerformanceMonitor.kt:43) at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.measure(Lifecycle.kt:34) at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.analyze(Lifecycle.kt:38) at io.gitlab.arturbosch.detekt.core.tooling.DefaultLifecycle.analyze(Lifecycle.kt:61) at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:48) at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:47) at io.gitlab.arturbosch.detekt.core.tooling.ProcessingSpecSettingsBridgeKt.withSettings(ProcessingSpecSettingsBridge.kt:26) at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.runAnalysis$detekt_core(AnalysisFacade.kt:47) at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.run(AnalysisFacade.kt:33) at io.gitlab.arturbosch.detekt.idea.ConfiguredService.execute(ConfiguredService.kt:148) at io.gitlab.arturbosch.detekt.idea.ConfiguredService.execute(ConfiguredService.kt:125) at io.gitlab.arturbosch.detekt.idea.DetektAnnotator.doAnnotate(DetektAnnotator.kt:38) at io.gitlab.arturbosch.detekt.idea.DetektAnnotator.doAnnotate(DetektAnnotator.kt:19) at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:207) at com.intellij.codeInsight.daemon.impl.ExternalToolPass.doAnnotate(ExternalToolPass.java:201) at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$0(ExternalToolPass.java:164) at com.intellij.codeInsight.daemon.impl.ExternalToolPass.runChangeAware(ExternalToolPass.java:266) at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.lambda$run$2(ExternalToolPass.java:164) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679) at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173) at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:360) at com.intellij.codeInsight.daemon.impl.ExternalToolPass$1.run(ExternalToolPass.java:162) at com.intellij.util.ui.update.Update.runUpdate(Update.java:114) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:348) at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:338) at com.intellij.util.ui.update.MergingUpdateQueue.doFlush(MergingUpdateQueue.java:295) at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:277) at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:246) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:254) at com.intellij.util.Alarm$Request.runSafely(Alarm.java:373) at com.intellij.util.Alarm$Request.run(Alarm.java:360) at com.intellij.util.concurrency.Propagation.contextAwareCallable$lambda$2(propagation.kt:328) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:272) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249) at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:31) at com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:215) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699) at java.base/java.security.AccessController.doPrivileged(AccessController.java:399) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699) at java.base/java.lang.Thread.run(Thread.java:833)

arturbosch commented 11 months ago

Hm, do you have some special project setup or something? Because Intellij returns different file paths which differ from the project base path:

https://github.com/detekt/detekt-intellij-plugin/blob/6b29224721ba4e61211896ec663ab46896a2e00a/src/main/kotlin/io/gitlab/arturbosch/detekt/idea/ConfiguredService.kt#L57

mutschml commented 11 months ago

As I mentioned before, I use a different filesystem for maven output (enabled with this profile):

<profile>
  <id>mm</id>
  <build>
    <directory>Z:/MPA/${project.artifactId}</directory>
  </build>
</profile>

The ramdisk (mounted on Z:) is created with ImDisk: https://sourceforge.net/projects/imdisk-toolkit/ There are some generated sources from xml-schemas and wsdls as well, but they are only java.

I assume the same error will happen when using another partition on another drive as well. I doubt it is related to ImDisk.