Error in SonarLint for IntelliJ, it seems to not like generated IntelliJ iml files with "SonarLintModuleSettings " before sonar cube project fetchs

Environment:

  • Java: JetBrains s.r.o. 11.0.12
  • OS: Windows 10 amd64
  • IDE: IntelliJ IDEA 2021.3 EAP
  • SonarLint: 6.1.0.38326

Hi,
i wrote a tool that did a lot of manual work automated (checkout of code, installing IJ and some plugins, creation of IJ modules and project)
When i opened my generated IJ project i had this crash.
I guess that the sonar plugin does not like to have a SonarLintModuleSettings already defined on a module iml file before having sonar cube server configured (unfortunately this I can’t automate without bothering other departments)

From my point of view having this information in the iml should not generate a crash, but it could be used to prevent manual settings from developpers.

java.lang.RuntimeException: java.lang.NullPointerException
	at com.intellij.openapi.application.impl.LaterInvocator.invokeAndWait(LaterInvocator.java:157)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:450)
	at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:455)
	at com.intellij.openapi.project.impl.ProjectManagerExImplKt.openProject(ProjectManagerExImpl.kt:388)
	at com.intellij.openapi.project.impl.ProjectManagerExImplKt.access$openProject(ProjectManagerExImpl.kt:1)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync$1.invoke(ProjectManagerExImpl.kt:134)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl$doOpenAsync$1.invoke(ProjectManagerExImpl.kt:59)
	at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner$1.apply(ProjectFrameAllocator.kt:94)
	at com.intellij.openapi.project.impl.ProjectUiFrameAllocator$run$progressRunner$1.apply(ProjectFrameAllocator.kt:71)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:244)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
	at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:624)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:698)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:646)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:623)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:244)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1692)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:221)
	at org.sonarlint.intellij.core.ModuleBindingManager.getEngineIfStarted(ModuleBindingManager.java:145)
	at org.sonarlint.intellij.module.ModuleChangeListenerKt.getEngineIfStarted(ModuleChangeListener.kt:35)
	at org.sonarlint.intellij.module.ModuleChangeListenerKt.access$getEngineIfStarted(ModuleChangeListener.kt:1)
	at org.sonarlint.intellij.module.ModuleChangeListener.moduleAdded(ModuleChangeListener.kt:39)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
	at com.intellij.util.messages.impl.MessageBusImpl.deliverMessage(MessageBusImpl.java:417)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:390)
	at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:372)
	at com.intellij.util.messages.impl.MessageBusImpl.access$200(MessageBusImpl.java:33)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:179)
	at com.sun.proxy.$Proxy95.moduleAdded(Unknown Source)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.fireModuleAdded(ModuleManagerComponentBridge.kt:293)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.access$fireModuleAdded(ModuleManagerComponentBridge.kt:45)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge$fireModuleAddedInWriteAction$1.run(ModuleManagerComponentBridge.kt:287)
	at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:947)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.fireModuleAddedInWriteAction(ModuleManagerComponentBridge.kt:284)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.fireModulesAdded(ModuleManagerComponentBridge.kt:279)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge.access$fireModulesAdded(ModuleManagerComponentBridge.kt:45)
	at com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleManagerComponentBridge$1.projectOpened(ModuleManagerComponentBridge.kt:56)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
	at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
	at com.intellij.util.messages.impl.MessageBusImpl.access$300(MessageBusImpl.java:33)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.executeOrAddToQueue(MessageBusImpl.java:208)
	at com.intellij.util.messages.impl.CompositeMessageBus$ToDirectChildrenMessagePublisher.publish(CompositeMessageBus.java:125)
	at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:166)
	at com.sun.proxy.$Proxy93.projectOpened(Unknown Source)
	at com.intellij.openapi.project.impl.ProjectManagerExImplKt$openProject$1.run(ProjectManagerExImpl.kt:400)
	at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
	at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450)
	at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:951)
	at com.intellij.openapi.progress.util.ProgressWindow.lambda$startBlocking$6(ProgressWindow.java:221)
	at com.intellij.openapi.application.impl.ApplicationImpl.runUnlockingIntendedWrite(ApplicationImpl.java:831)
	at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:217)
	at com.intellij.openapi.progress.impl.ProgressRunner.lambda$execFromEDT$6(ProgressRunner.java:321)
	at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:753)
	at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
	at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2108)
	at com.intellij.openapi.progress.impl.ProgressRunner.execFromEDT(ProgressRunner.java:318)
	at com.intellij.openapi.progress.impl.ProgressRunner.submit(ProgressRunner.java:259)
	at com.intellij.openapi.progress.impl.ProgressRunner.submitAndGet(ProgressRunner.java:185)
	at com.intellij.openapi.project.impl.ProjectUiFrameAllocator.run(ProjectFrameAllocator.kt:116)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl.doOpenAsync(ProjectManagerExImpl.kt:117)
	at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProjectAsync(ProjectManagerExImpl.kt:108)
	at com.intellij.ide.impl.ProjectUtil.openOrImportAsync(ProjectUtil.java:226)
	at com.intellij.ide.actions.OpenFileAction.openExistingDir(OpenFileAction.java:167)
	at com.intellij.ide.actions.OpenFileAction.doOpenFile(OpenFileAction.java:116)
	at com.intellij.ide.actions.OpenFileAction.lambda$actionPerformed$0(OpenFileAction.java:76)
	at com.intellij.openapi.fileChooser.ex.FileChooserDialogImpl.choose(FileChooserDialogImpl.java:146)
	at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:102)
	at com.intellij.openapi.fileChooser.FileChooser.chooseFiles(FileChooser.java:80)
	at com.intellij.ide.actions.OpenFileAction.actionPerformed(OpenFileAction.java:67)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:244)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:265)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:244)
	at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil.performAnActionForComponent(WelcomeScreenActionsUtil.java:96)
	at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreenActionsUtil$ToolbarTextButtonWrapper$1.actionPerformed(WelcomeScreenActionsUtil.java:56)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:270)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
	at java.desktop/java.awt.Component.processEvent(Component.java:6419)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2790)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:820)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:757)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Hello Alain,

Today SonarLint expects settings to be consistent. If you define a projectKey value in the module settings, you also need to define which connection you use at project-level (using bindingEnabled and providing the serverId value), and then you also need to configure the SonarQube connection at global settings level. If something is missing, it means that settings are not correct, so that’s why we throw this error (which is not explicit at all by the way).

If I understand what you are trying to achieve: you want to generate module settings to “pre-bind” modules to the right SonarQube project ? And then developers would have to create the connection and finish the binding process on their own ?

yes thats is
i created an install tool to install IntelliJ, do the project checkout, generate IJ project files and automatically configure some IntelliJ settings : keymap, preinstall some plugins (including sonarlint)

and to make my colleagues work easier I try to automate as much as possible ;p

So when I saw that you added the rule per module I looked where this was saved on my IJ and tried to replicate this on my generate files.

the idea was that the modules already know to which sonarqube rule they need to match, but as the sonar qube connection require a token, that is uniq for each developer, i can’t use mine and give it to the entire company ^^

I hope this clarifies a bit my feature request :wink:

is there also possible to add a module in an ignore binding ?
Or to not bind the entire project but just some specific modules ?

No, and no. Out of curiosity why you would need that: some of your modules are analyzed on SonarQube and some aren’t ? Why is it so ?

I understand what you are trying to achieve with your tool. After thinking more about it, we can’t be sure that settings will always be consistent between module, project and global level (some settings files could have been deleted on disk for any reason), and we should be more resilient to those kind of discrepancies anyway. I created a ticket to fix the issue.

Otherwise you’re right developers need to input the token. You could ask them to provide it when launching your tool (be it in command-line or graphical), and then automate the full creation of SonarLint settings. Please note that the token is encoded, and we might change some day the way we store tokens. Feel free to have a look in the code

Thanks again for reporting

thanks for the ticket.
In fact the company project is based out of multiple modules in Intellij (multiple projects in eclipse)
some have special rules and one project (a test project) has no rule at all on the sonarcube server

on eclipse you can have a project not linked to sonarcube
whereas on IntelliJ once the project is linked, with the new version of sonar lint you can override the setting for specific modules but you can’t say : this module has no need to check on the sonarcube server.

This is not critical for me as it is not an issue to have more warnings :stuck_out_tongue:
But I was simply asking to make sure that I did not missed something :slight_smile:)

yes I’ll try to add a dialog to ask for the token in order to fully configure sonar :slight_smile:

Wish you a nice day

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.