Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running "ArrayPrimitive" rule on "Array<*>" causes detekt to throw exception #2176

Closed
dimsuz opened this issue Dec 12, 2019 · 1 comment · Fixed by #2181
Closed

Running "ArrayPrimitive" rule on "Array<*>" causes detekt to throw exception #2176

dimsuz opened this issue Dec 12, 2019 · 1 comment · Fixed by #2181
Milestone

Comments

@dimsuz
Copy link
Contributor

dimsuz commented Dec 12, 2019

Observed Behavior

While analyzing file with the following code:

internal class MergeLceStateTest {
  @DataProvider(name = "lce_merge_data")
  private fun createStateMergeTestData(): Array<*> {
    return arrayOf(
      arrayOf(
        // first
        LceState.Loading,
        // second
        LceState.Loading,
        // expected
        LceStateLoading
      )
    )
  }
}

Detekt 1.2.2 throws the following exception

Analyzing '/path/to/Test.kt' led to an exception.
The original exception message was: genericTypeArguments[0] must not be null
Running detekt '1.2.2' on Java '1.8.0_202-release-1483-b49-5587405' on OS 'Linux'.
If the exception message does not help, please feel free to create an issue on our GitHub page.
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive.isArrayPrimitive(ArrayPrimitive.kt:81)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive.access$isArrayPrimitive(ArrayPrimitive.kt:37)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive$reportArrayPrimitives$1.invoke(ArrayPrimitive.kt:74)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive$reportArrayPrimitives$1.invoke(ArrayPrimitive.kt:37)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive$reportArrayPrimitives$$inlined$collectDescendantsOfType$1.invoke(psiUtils.kt:287)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive$reportArrayPrimitives$$inlined$collectDescendantsOfType$1.invoke(psiUtils.kt)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive$reportArrayPrimitives$$inlined$collectDescendantsOfType$2.visitElement(psiUtils.kt:235)
org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:62)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive.reportArrayPrimitives(ArrayPrimitive.kt:96)
io.gitlab.arturbosch.detekt.rules.performance.ArrayPrimitive.visitNamedFunction(ArrayPrimitive.kt:66)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitNamedFunction(KtVisitorVoid.java:483)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitNamedFunction(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtNamedFunction.accept(KtNamedFunction.java:50)
org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:59)
org.jetbrains.kotlin.com.intellij.psi.impl.PsiElementBase.acceptChildren(PsiElementBase.java:69)
org.jetbrains.kotlin.psi.KtTreeVisitorVoid.visitElement(KtTreeVisitorVoid.java:25)
org.jetbrains.kotlin.psi.KtVisitor.visitKtElement(KtVisitor.java:24)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:25)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:447)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitClassBody(KtVisitor.java:98)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassBody(KtVisitorVoid.java:89)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassBody(KtVisitorVoid.java:537)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassBody(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtClassBody.accept(KtClassBody.kt:38)
org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:59)
org.jetbrains.kotlin.com.intellij.psi.impl.PsiElementBase.acceptChildren(PsiElementBase.java:69)
org.jetbrains.kotlin.psi.KtTreeVisitorVoid.visitElement(KtTreeVisitorVoid.java:25)
org.jetbrains.kotlin.psi.KtVisitor.visitKtElement(KtVisitor.java:24)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:25)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:447)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtElement(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitExpression(KtVisitor.java:182)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitExpression(KtVisitorVoid.java:169)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitExpression(KtVisitorVoid.java:659)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitExpression(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitDeclaration(KtVisitor.java:29)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:29)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:453)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitDeclaration(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitNamedDeclaration(KtVisitor.java:398)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitNamedDeclaration(KtVisitorVoid.java:381)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitNamedDeclaration(KtVisitorVoid.java:959)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitNamedDeclaration(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitClassOrObject(KtVisitor.java:41)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassOrObject(KtVisitorVoid.java:37)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassOrObject(KtVisitorVoid.java:465)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClassOrObject(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtVisitor.visitClass(KtVisitor.java:33)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:33)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:459)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitClass(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtClass.accept(KtClass.kt:20)
org.jetbrains.kotlin.psi.KtElementImplStub.accept(KtElementImplStub.java:59)
org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.SharedImplUtil.acceptChildren(SharedImplUtil.java:200)
org.jetbrains.kotlin.com.intellij.psi.impl.source.PsiFileImpl.acceptChildren(PsiFileImpl.java:733)
org.jetbrains.kotlin.psi.KtTreeVisitorVoid.visitElement(KtTreeVisitorVoid.java:25)
org.jetbrains.kotlin.com.intellij.psi.PsiElementVisitor.visitFile(PsiElementVisitor.java:34)
org.jetbrains.kotlin.psi.KtVisitor.visitKtFile(KtVisitor.java:73)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:69)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:513)
org.jetbrains.kotlin.psi.KtVisitorVoid.visitKtFile(KtVisitorVoid.java:21)
org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:242)
org.jetbrains.kotlin.psi.KtFile.accept(KtFile.kt:229)
io.gitlab.arturbosch.detekt.api.BaseRule.visit(BaseRule.kt:53)
io.gitlab.arturbosch.detekt.api.BaseRule.visitFile(BaseRule.kt:43)
io.gitlab.arturbosch.detekt.api.RuleSet.accept(RuleSet.kt:35)
io.gitlab.arturbosch.detekt.core.Detektor.analyze(Detektor.kt:76)
io.gitlab.arturbosch.detekt.core.Detektor.runSync(Detektor.kt:44)
io.gitlab.arturbosch.detekt.core.Detektor.run(Detektor.kt:28)
io.gitlab.arturbosch.detekt.core.DetektFacade.run(DetektFacade.kt:41)
io.gitlab.arturbosch.detekt.cli.runners.Runner.execute(Runner.kt:29)
io.gitlab.arturbosch.detekt.cli.Main.main(Main.kt:16)

Your Environment

  • Version of detekt used: 1.2.2

I plan to submit a PR with the fix soonish.

@schalkms
Copy link
Member

I plan to submit a PR with the fix soonish.

Thanks for that! 👍

dimsuz pushed a commit to dimsuz/detekt that referenced this issue Dec 16, 2019
dimsuz pushed a commit to dimsuz/detekt that referenced this issue Dec 16, 2019
@arturbosch arturbosch added this to the 1.3.0 milestone Dec 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants