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

Kdoc-formatting failure #868

Closed
orchestr7 opened this issue May 8, 2021 · 2 comments · Fixed by #876
Closed

Kdoc-formatting failure #868

orchestr7 opened this issue May 8, 2021 · 2 comments · Fixed by #876
Assignees
Labels
bug Something isn't working
Milestone

Comments

@orchestr7
Copy link
Member

orchestr7 commented May 8, 2021

Diktat version: 0.5.2

[ERROR] 2021-05-08 23:21:19 Internal error has occurred in kdoc-formatting. Please make an issue on this bug at https://github.com/cqfn/diKTat/.
java.lang.NullPointerException: Cannot invoke "org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.IndentHelper.getIndent(org.jetbrains.kotlin.com.intellij.psi.PsiFile, org.jet
brains.kotlin.com.intellij.lang.ASTNode)" because the return value of "org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.IndentHelper.getInstance()" is null
        at org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.CodeEditUtil.saveWhitespacesInfo(CodeEditUtil.java:108)
        at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil.saveIndentationToCopy(ChangeUtil.java:104)
        at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.ChangeUtil.copyLeafWithText(ChangeUtil.java:80)
        at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement.replaceWithText(LeafElement.java:153)
        at org.cqfn.diktat.ruleset.utils.AstNodeUtilsKt.leaveExactlyNumNewLines(AstNodeUtils.kt:522)
        at org.cqfn.diktat.ruleset.utils.AstNodeUtilsKt.leaveOnlyOneNewLine(AstNodeUtils.kt:515)
        at org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting$checkEmptyLinesBetweenBasicTags$1$1.invoke(KdocFormatting.kt:272)
        at org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting$checkEmptyLinesBetweenBasicTags$1$1.invoke(KdocFormatting.kt:62)
        at org.cqfn.diktat.ruleset.constants.Warnings.warnAndFix(Warnings.kt:258)
        at org.cqfn.diktat.ruleset.constants.Warnings.warnAndFix$default(Warnings.kt:206)
        at org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting.checkEmptyLinesBetweenBasicTags(KdocFormatting.kt:270)
        at org.cqfn.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting.logic(KdocFormatting.kt:88)
        at org.cqfn.diktat.ruleset.rules.DiktatRule.visit(DiktatRule.kt:46)
        at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:271)
        at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:23)
        at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:212)
        at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:23)
        at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:224)
        at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
        at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
        at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
        at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:225)
        at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:211)
        at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:23)
        at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:264)
        at com.pinterest.ktlint.internal.FileUtilsKt.formatFile(FileUtils.kt:79)
        at com.pinterest.ktlint.KtlintCommandLine.process(Main.kt:331)
        at com.pinterest.ktlint.KtlintCommandLine.access$process(Main.kt:116)
        at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:257)
        at com.pinterest.ktlint.KtlintCommandLine$lintFiles$2$1.call(Main.kt:116)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
        at java.base/java.lang.Thread.run(Thread.java:832)
[ERROR] 2021-05-08 23:21:19 As a workaround you can disable these inspections in yml config: [KDOC_CONTAINS_DATE_OR_AUTHOR, KDOC_EMPTY_KDOC, KDOC_NEWLINES_BEFORE_BASIC_TAGS, KDOC_NO_DE
PRECATED_TAG, KDOC_NO_EMPTY_TAGS, KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS, KDOC_NO_NEWLINE_AFTER_SPECIAL_TAGS, KDOC_WRONG_SPACES_AFTER_TAG, KDOC_WRONG_TAGS_ORDER]

Reproducer:

package com.akuleshov7.ktoml.parsers.node

import com.akuleshov7.ktoml.error
import com.akuleshov7.ktoml.exceptions.InternalAstException
import com.akuleshov7.ktoml.exceptions.InternalParsingException
import com.akuleshov7.ktoml.exceptions.TomlParsingException
import com.akuleshov7.ktoml.parsingError



class TomlFile : TomlNode("rootNode", 0) {
    override val name = "rootNode"

    override fun getNeighbourNodes() =
        throw InternalAstException("Invalid call to getNeighbourNodes() for TomlFile node")

    /**
     * This method recursively finds child toml table with the proper name in AST.
     * Stops processing if AST is broken and it has more than one table with the searched name on the same level.
     * @param searchedTableName - the table name that is expected to be found in the list of children of this node
     * @param searchedLevel - the level of nested child node that is searched level (indexed from 1)
     *
     * For example: findTableInAstByName("a.d", 2) will find [a.d] table in the following tree:
     *     a
     *    /  \
     *   a.c a.d
     *        \
     *        a.d.e
     */
    fun findTableInAstByName(searchedTableName: String, searchedLevel: Int): TomlTable? {
    }
}
@orchestr7 orchestr7 added the bug Something isn't working label May 8, 2021
@orchestr7
Copy link
Member Author

orchestr7 commented May 8, 2021

Critical bug as happens with Fix and Check modes, please fix asap

@petertrr
Copy link
Member

petertrr commented May 9, 2021

As a WA, you can remove an empty line before 'for example', so that tag's body doesn't have empty lines.

@petertrr petertrr added this to the 0.5.3 milestone May 11, 2021
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