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

NullPointerException on KDOC inspection #1331

Closed
orchestr7 opened this issue May 30, 2022 · 2 comments · Fixed by #1334
Closed

NullPointerException on KDOC inspection #1331

orchestr7 opened this issue May 30, 2022 · 2 comments · Fixed by #1334
Assignees
Labels
bug Something isn't working

Comments

@orchestr7
Copy link
Member

package test.paragraph3.trailing_comma

class Customer(
    val name: String,
    lastName: String,
)

fun shift(x: Int,
          y: Int,
) {
    shift(
        25,
        20,
    )

    val colors = listOf(
        "red",
        "green",
        "blue",
    )
}

fun getZValue(mySurface: Surface,
              xValue: Int,
              yValue: Int,
) =
    mySurface[
            xValue,
            yValue
    ]

fun isReferenceApplicable(myReference: KClass<*>,
) = when (myReference) {
    Comparable::class,
    Iterable::class,
    String::class,
    -> true
    else -> false
}

fun isReferenceApplicable(myReference: KClass<*> ,// comment
) = when (myReference) {
    Comparable::class,
    Iterable::class,
    String::class,
    -> true
    else -> false
}

@ApplicableFor([
    "serializer",
    "balancer",
    "database",
    "inMemoryCache",
],
)
fun foo() {}

fun <T1,
        T21,
        > foo() {}

fun mains() {
    foo<
            Comparable<Number,
                    >,
            Iterable<Number,
                    >,
            >()
}

fun printMeanValue() {
    var meanValue: Int = 0
    for ((
        _,
        _,
        year,
    ) in cars) {
        meanValue += year
    }
    println(meanValue/cars.size)
}

enum class SomeEnum(
    val a: Int, val b: Int  ,// comment
)

enum class SomeEnum(
    val a: Int, val b: Int,// comment
)

enum class SomeEnum(
    val a: Int, val b: Int  ,/* comment */
)

enum class SomeEnum(
    val a: Int, val b: Int,  /**
    some comment */
)

fun foo() {
    val sum: (Int, Int, Int,) -> Int = fun(
        x,
        y,
        z ,// trailing comma
    ): Int {
        return x + y + x
    }
    println(sum(8, 8, 8))
}

fun shift(x: Int, y: Int) {
    shift(
        25,
        20, // trailing comma
    )

    val colors = listOf(
        "red",
        "green",
        "blue", // trailing comma
    )
}

image

Diktat incorrectly treats KDOC and causes hard failure

@orchestr7 orchestr7 added the bug Something isn't working label May 30, 2022
@Cheshiriks
Copy link
Member

Cheshiriks commented May 30, 2022

Error in this example:

fun foo() {
    val sum: (Int, Int, Int,) -> Int = fun(
        x,
        y,
        z,
    ): Int {
        return x + y + x
    }
}

Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
@Cheshiriks
Copy link
Member

The problem occurs in many rules due to anonymous functions

Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue May 31, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue Jun 1, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue Jun 1, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue Jun 2, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue Jun 2, 2022
### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Cheshiriks added a commit that referenced this issue Jun 2, 2022
* NullPointerException on KDOC inspection

### What's done:
* fixed NullPointerException on KDOC inspection
Closes #1331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants