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

MissingFieldException: Field 'other_locations' when analyze with sonar-java plugin #4

Open subotaii opened 4 years ago

subotaii commented 4 years ago

Nice work with this intellij plugin nhat phan ! When a launch analyze with sonar-java plugin, i got the exception below.

kotlinx.serialization.MissingFieldException: Field 'other_locations' is required, but it was missing
    at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl.<init>(AnalyzedIssueImpl.kt)
    at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl$$serializer.deserialize(AnalyzedIssueImpl.kt)
    at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl$$serializer.deserialize(AnalyzedIssueImpl.kt:9)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:33)
    at kotlinx.serialization.json.internal.AbstractJsonTreeInput.decodeSerializableValue(TreeJsonInput.kt:43)
    at kotlinx.serialization.CoreKt.decode(Core.kt:79)
    at kotlinx.serialization.json.internal.TreeJsonInputKt.readJson(TreeJsonInput.kt:22)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:41)
    at kotlinx.serialization.json.internal.StreamingJsonInput.decodeSerializableValue(StreamingJsonInput.kt:29)
    at kotlinx.serialization.ElementValueDecoder.decodeSerializableElement(ElementWise.kt:142)
    at kotlinx.serialization.internal.ListLikeSerializer.readItem(CollectionSerializers.kt:98)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.readItem$default(CollectionSerializers.kt:70)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.patch(CollectionSerializers.kt:51)
    at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:61)
    at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:33)
    at kotlinx.serialization.json.internal.StreamingJsonInput.decodeSerializableValue(StreamingJsonInput.kt:29)
    at kotlinx.serialization.CoreKt.decode(Core.kt:79)
    at kotlinx.serialization.json.Json.parse(Json.kt:152)
    at net.ntworld.codeCleaner.Serializer.parse(Serializer.kt:30)
    at net.ntworld.codeCleaner.Serializer.parseIssues(Serializer.kt:39)
    at net.ntworld.codeCleaner.quality.CodeQualityParser.parse(CodeQualityParser.kt:19)
    at net.ntworld.codeCleaner.CodeQualityManager.create(CodeQualityManager.kt:17)
    at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.handle(CreateCodeQualityCommandHandler.kt:11)
    at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.handle(CreateCodeQualityCommandHandler.kt:9)
    at net.ntworld.foundation.cqrs.CommandHandler$DefaultImpls.execute(CommandHandler.kt:10)
    at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.execute(CreateCodeQualityCommandHandler.kt:9)
    at net.ntworld.codeCleaner.LocalCommandBus.process(LocalCommandBus.kt:34)
    at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler$handle$1.invoke(CreateAnalyzeProcessCommandHandler.kt:48)
    at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler$handle$1.invoke(CreateAnalyzeProcessCommandHandler.kt:20)
    at net.ntworld.foundation.Infrastructure$DefaultImpls.invoke(Infrastructure.kt:55)
    at net.ntworld.foundation.InfrastructureResolver.invoke(InfrastructureResolver.kt:12)
    at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.handle(CreateAnalyzeProcessCommandHandler.kt:27)
    at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.handle(CreateAnalyzeProcessCommandHandler.kt:20)
    at net.ntworld.foundation.cqrs.CommandHandler$DefaultImpls.execute(CommandHandler.kt:10)
    at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.execute(CreateAnalyzeProcessCommandHandler.kt:20)
    at net.ntworld.codeCleaner.LocalCommandBus.process(LocalCommandBus.kt:34)
    at net.ntworld.intellijCodeCleaner.task.AnalyzeTask$run$1.invoke(AnalyzeTask.kt:23)
    at net.ntworld.intellijCodeCleaner.task.AnalyzeTask$run$1.invoke(AnalyzeTask.kt:13)
    at net.ntworld.foundation.Infrastructure$DefaultImpls.invoke(Infrastructure.kt:55)
    at net.ntworld.foundation.InfrastructureWrapper.invoke(InfrastructureWrapper.kt:11)
    at net.ntworld.intellijCodeCleaner.task.AnalyzeTask.run(AnalyzeTask.kt:22)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:888)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.lambda$run$0(CoreProgressManager.java:402)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221)
    at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:402)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:238)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

Here my .codeclimate.yml file.

version: "2"
checks:
  argument-count:
    enabled: false
    config:
      threshold: 4
  complex-logic:
    enabled: false
    config:
      threshold: 4
  file-lines:
    enabled: false
    config:
      threshold: 250
  method-complexity:
    enabled: false
    config:
      threshold: 5
  method-count:
    enabled: false
    config:
      threshold: 20
  method-lines:
    enabled: false
    config:
      threshold: 25
  nested-control-flow:
    enabled: false
    config:
      threshold: 4
  return-statements:
    enabled: false
    config:
      threshold: 4
  similar-code:
    enabled: false
    config:
      threshold: #language-specific defaults. overrides affect all languages.
  identical-code:
    enabled: false
    config:
      threshold: #language-specific defaults. overrides affect all languages.
plugins:
  sonar-java:
    enabled: true
    config:
      sonar.java.source: "8"
exclude_patterns:
  - "config/"
  - "db/"
  - "dist/"
  - "features/"
  - "**/node_modules/"
  - "script/"
  - "**/spec/"
  - "**/test/"
  - "**/tests/"
  - "**/vendor/"
  - "**/*.d.ts"
  - "**/*.min.js"
  - "**/*.min.css"
  - "apache/"
  - "bdd/"
  - "mysql/"
  - "web/src/main/resources/"
  - "**/target/"
  - "!**/target/site/jacoco/jacoco.xml"
nhat-phan commented 4 years ago

@subotaii Could you please send me the sample of sonar-java plugin output. I can't change the contract if I don't know the output of that plugin.

You can run this command: codeclimate analyze -f json > result.json and find an item which don't have other_locations key

Thank you in advance!

subotaii commented 4 years ago

Hello Nhat, I don't have any problem when i execute the analysis from command line (codeclimate analyze -f json > result.json), the resulting json seems good and there is no item 'other_locations'.

Stacktrace of the execution of your plugin :

kotlinx.serialization.MissingFieldException: Field 'other_locations' is required, but it was missing at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl.(AnalyzedIssueImpl.kt) at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl$$serializer.deserialize(AnalyzedIssueImpl.kt) at net.ntworld.codeCleaner.codeClimate.internal.AnalyzedIssueImpl$$serializer.deserialize(AnalyzedIssueImpl.kt:9) at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:33) at kotlinx.serialization.json.internal.AbstractJsonTreeInput.decodeSerializableValue(TreeJsonInput.kt:43) at kotlinx.serialization.CoreKt.decode(Core.kt:79) at kotlinx.serialization.json.internal.TreeJsonInputKt.readJson(TreeJsonInput.kt:22) at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:41) at kotlinx.serialization.json.internal.StreamingJsonInput.decodeSerializableValue(StreamingJsonInput.kt:29) at kotlinx.serialization.ElementValueDecoder.decodeSerializableElement(ElementWise.kt:142) at kotlinx.serialization.internal.ListLikeSerializer.readItem(CollectionSerializers.kt:98) at kotlinx.serialization.internal.AbstractCollectionSerializer.readItem$default(CollectionSerializers.kt:70) at kotlinx.serialization.internal.AbstractCollectionSerializer.patch(CollectionSerializers.kt:51) at kotlinx.serialization.internal.AbstractCollectionSerializer.deserialize(CollectionSerializers.kt:61) at kotlinx.serialization.json.internal.PolymorphicKt.decodeSerializableValuePolymorphic(Polymorphic.kt:33) at kotlinx.serialization.json.internal.StreamingJsonInput.decodeSerializableValue(StreamingJsonInput.kt:29) at kotlinx.serialization.CoreKt.decode(Core.kt:79) at kotlinx.serialization.json.Json.parse(Json.kt:152) at net.ntworld.codeCleaner.Serializer.parse(Serializer.kt:30) at net.ntworld.codeCleaner.Serializer.parseIssues(Serializer.kt:39) at net.ntworld.codeCleaner.quality.CodeQualityParser.parse(CodeQualityParser.kt:19) at net.ntworld.codeCleaner.CodeQualityManager.create(CodeQualityManager.kt:17) at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.handle(CreateCodeQualityCommandHandler.kt:11) at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.handle(CreateCodeQualityCommandHandler.kt:9) at net.ntworld.foundation.cqrs.CommandHandler$DefaultImpls.execute(CommandHandler.kt:10) at net.ntworld.codeCleaner.commandHandler.CreateCodeQualityCommandHandler.execute(CreateCodeQualityCommandHandler.kt:9) at net.ntworld.codeCleaner.LocalCommandBus.process(LocalCommandBus.kt:34) at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler$handle$1.invoke(CreateAnalyzeProcessCommandHandler.kt:48) at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler$handle$1.invoke(CreateAnalyzeProcessCommandHandler.kt:20) at net.ntworld.foundation.Infrastructure$DefaultImpls.invoke(Infrastructure.kt:55) at net.ntworld.foundation.InfrastructureResolver.invoke(InfrastructureResolver.kt:12) at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.handle(CreateAnalyzeProcessCommandHandler.kt:27) at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.handle(CreateAnalyzeProcessCommandHandler.kt:20) at net.ntworld.foundation.cqrs.CommandHandler$DefaultImpls.execute(CommandHandler.kt:10) at net.ntworld.codeCleaner.commandHandler.CreateAnalyzeProcessCommandHandler.execute(CreateAnalyzeProcessCommandHandler.kt:20) at net.ntworld.codeCleaner.LocalCommandBus.process(LocalCommandBus.kt:34) at net.ntworld.intellijCodeCleaner.task.AnalyzeTask$run$1.invoke(AnalyzeTask.kt:23) at net.ntworld.intellijCodeCleaner.task.AnalyzeTask$run$1.invoke(AnalyzeTask.kt:13) at net.ntworld.foundation.Infrastructure$DefaultImpls.invoke(Infrastructure.kt:55) at net.ntworld.foundation.InfrastructureWrapper.invoke(InfrastructureWrapper.kt:11) at net.ntworld.intellijCodeCleaner.task.AnalyzeTask.run(AnalyzeTask.kt:22) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:888) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150) at com.intellij.openapi.progress.impl.CoreProgressManager$4.lambda$run$0(CoreProgressManager.java:402) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221) at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:402) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:238) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

Le dim. 5 janv. 2020 à 21:18, Nhat Phan notifications@github.com a écrit :

@subotaii https://github.com/subotaii Could you please send me the sample of sonar-java plugin output. I can't change the contract if I don't know the output of that plugin.

You can run this command: codeclimate analyze -f json > result.json and find an item which don't have other_locations key

Thank you in advance!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nhat-phan/shit-cleaner/issues/4?email_source=notifications&email_token=ANCYYQVVOTJWEU47RQ5AFWLQ4I6ARA5CNFSM4KAZHDF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEID6S2I#issuecomment-570943849, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCYYQQBN5FITB5X52WDIYLQ4I6ARANCNFSM4KAZHDFQ .

nhat-phan commented 4 years ago

Hi @subotaii could you please send me 1 item which doesn't have other_locations. I meant I want to know structure of the item then I can write a correct JSON parser.

sema4-vadymnovakovskyi commented 3 years ago

Hey! Is there any updates? I have the same problem

sema4-vadymnovakovskyi commented 3 years ago

@nhat-phan I see that in result.json file only "engine_name":"checkstyle" have no key other_locations. May be it will helps you

sema4-vadymnovakovskyi commented 3 years ago

@nhat-phan Hey! Is there any updates?