nhat-phan / shit-cleaner

An Intellij IDE plugin which uses Code Climate CLI to analyze your source code on local machine and display code smells/duplications right in your IDE
GNU Affero General Public License v3.0
27 stars 7 forks source link

KotlinNullPointerException on DefaultAnnotationManager.attachProvidersToEditor() #1

Closed azdanov closed 4 years ago

azdanov commented 4 years ago

Happened when I've tried to run the scan. And then I couldn't stop it. Had to restart IntelliJ. Also, the docker started to hang and take 100% of the CPU. Had to restart docker too.

Using the latest IDEA and Docker as of today's date.

kotlin.KotlinNullPointerException
    at net.ntworld.intellijCodeCleaner.component.annotation.DefaultAnnotationManager.attachProvidersToEditor(DefaultAnnotationManager.kt:69)
    at net.ntworld.intellijCodeCleaner.component.annotation.DefaultAnnotationManager.attach(DefaultAnnotationManager.kt:35)
    at net.ntworld.intellijCodeCleaner.component.annotation.EditorListener.selectionChanged(EditorListener.kt:22)
    at jdk.internal.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at com.intellij.util.messages.impl.MessageBusConnectionImpl.deliverMessage(MessageBusConnectionImpl.java:102)
    at com.intellij.util.messages.impl.MessageBusImpl.doPumpMessages(MessageBusImpl.java:446)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpWaitingBuses(MessageBusImpl.java:406)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:395)
    at com.intellij.util.messages.impl.MessageBusImpl.pumpMessages(MessageBusImpl.java:379)
    at com.intellij.util.messages.impl.MessageBusImpl.sendMessage(MessageBusImpl.java:372)
    at com.intellij.util.messages.impl.MessageBusImpl.lambda$createTopicHandler$1(MessageBusImpl.java:242)
    at com.sun.proxy.$Proxy107.selectionChanged(Unknown Source)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl.lambda$fireSelectionChanged$20(FileEditorManagerImpl.java:1602)
    at com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl$5$1.run(FileEditorManagerImpl.java:1051)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$3(FocusManagerImpl.java:170)
    at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:2464)
    at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:222)
    at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:174)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:161)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:167)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$null$2(FocusManagerImpl.java:175)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:312)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:433)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:416)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
    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:878)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:827)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:466)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:704)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:465)
    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)
azdanov commented 4 years ago

After the restart, I couldn't reproduce the exception, but the scan seemed to take forever. But the stop button didn't work. I had to do a manual restart of both IDEA and Docker.

Here's the project I was trying to analyze: https://github.com/karpunets/wallet

nhat-phan commented 4 years ago

@azdanov The plugin adds an action "Analyze Code Smells and Duplications" into "Analyze" menu therefore if you are using PHPStorm you will see the null pointer exception and the action will be added to "Other" menu, could you please confirm that? Btw, I'm going to remove it soon.

For the scan take forever problem, may be you have a lot of library's files such as vendor folder (if you are using Laravel framework). Please follow this document to add some ignore path patterns to your code climate engine. In my machine - MacBook 15inch 2018 - it takes ~3 seconds per 1000 line of code.

Sample .codeclimate.yml in my machine (kotlin project):

version: '2'
engines:
  duplication:
    enabled: true
    config:
      languages:
        - kotlin
checks:
  argument-count:
    enabled: true
    config:
      threshold: 8
  complex-logic:
    enabled: true
    config:
      threshold: 4
  file-lines:
    enabled: true
    config:
      threshold: 300
  method-complexity:
    enabled: true
    config:
      threshold: 12
  method-count:
    enabled: true
    config:
      threshold: 30
  method-lines:
    enabled: true
    config:
      threshold: 30
  nested-control-flow:
    enabled: true
    config:
      threshold: 4
  return-statements:
    enabled: true
    config:
      threshold: 5
  similar-code:
    enabled: true
    config:
      threshold: 100
  identical-code:
    enabled: true
    config:
      threshold: 100
exclude_patterns:
  - '**/build/'
  - '**/src/test'
  - '**/src/commonTest'
  - 'foundation/src/commonMain/kotlin/net/ntworld/foundation/FakedData.kt'
  - 'foundation/src/jvmMain/kotlin/net/ntworld/foundation/util/JavaFakerWrapper.kt'
nhat-phan commented 4 years ago

After the restart, I couldn't reproduce the exception, but the scan seemed to take forever. But the stop button didn't work. I had to do a manual restart of both IDEA and Docker.

Here's the project I was trying to analyze: https://github.com/karpunets/wallet

Sorry, I miss this comment. I tried your repo and this is the result on my computer:

Screen Shot 2019-11-16 at 19 48 57

Could you please try command codeclimate analyze on your machine and check how long it take?

azdanov commented 4 years ago

Thanks for the codeclimate analyze tip. On my machine it took 5m26s.