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

NPE in AVOID_NULL_CHECKS #1204

Closed
Cheshiriks opened this issue Jan 31, 2022 · 6 comments
Closed

NPE in AVOID_NULL_CHECKS #1204

Cheshiriks opened this issue Jan 31, 2022 · 6 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Cheshiriks
Copy link
Member

Cheshiriks commented Jan 31, 2022

Bug in DockerService.kt in Save-cloud (Fix mode).

package org.cqfn.save.orchestrator.service

import org.cqfn.save.domain.Python
import org.cqfn.save.entities.Execution
import org.cqfn.save.entities.TestSuite
import org.cqfn.save.execution.ExecutionStatus
import org.cqfn.save.execution.ExecutionUpdateDto
import org.cqfn.save.orchestrator.config.ConfigProperties
import org.cqfn.save.orchestrator.copyRecursivelyWithAttributes
import org.cqfn.save.orchestrator.createSyntheticTomlConfig
import org.cqfn.save.orchestrator.docker.ContainerManager
import org.cqfn.save.testsuite.TestSuiteDto
import org.cqfn.save.utils.PREFIX_FOR_SUITES_LOCATION_IN_STANDARD_MODE
import org.cqfn.save.utils.STANDARD_TEST_SUITE_DIR
import org.cqfn.save.utils.moveFileWithAttributes

import com.github.dockerjava.api.exception.DockerException
import generated.SAVE_CORE_VERSION
import net.lingala.zip4j.ZipFile
import net.lingala.zip4j.exception.ZipException
import org.apache.commons.io.FileUtils
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.core.io.ClassPathResource
import org.springframework.http.MediaType
import org.springframework.stereotype.Service
import org.springframework.util.FileSystemUtils
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.bodyToMono

import java.io.File
import java.nio.file.Files
import java.nio.file.LinkOption
import java.nio.file.attribute.PosixFileAttributeView
import java.util.concurrent.atomic.AtomicBoolean

import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.createTempDirectory

/**
 * A service that uses [ContainerManager] to build and start containers for test execution.
 */
@Service
@OptIn(ExperimentalPathApi::class)
class DockerService(private val configProperties: ConfigProperties) {
    /**
     * [ContainerManager] that is used to access docker daemon API
     */
    internal val containerManager = ContainerManager(configProperties.docker)
    private val executionDir = "/run/save-execution"

    @Suppress("NonBooleanPropertyPrefixedWithIs")
    private val isAgentStoppingInProgress = AtomicBoolean(false)

    @Autowired
    @Qualifier("webClientBackend")
    private lateinit var webClientBackend: WebClient

    /**
     * Function that builds a base image with test resources and then creates containers with agents.
     *
     * @param execution [Execution] from which this workflow is started
     * @param testSuiteDtos test suites, selected by user
     * @return list of IDs of created containers
     * @throws DockerException if interaction with docker daemon is not successful
     */
    fun buildAndCreateContainers(
        execution: Execution,
        testSuiteDtos: List<TestSuiteDto>?,
    ): List<String> {
        log.info("Building base image for execution.id=${execution.id}")
        val (imageId, runCmd, saveCliExecFlags) = buildBaseImageForExecution(execution, testSuiteDtos)
        log.info("Built base image for execution.id=${execution.id}")
        return (1..configProperties.agentsCount).map { number ->
            log.info("Building container #$number for execution.id=${execution.id}")
            createContainerForExecution(execution, imageId, "${execution.id}-$number", runCmd, saveCliExecFlags).also {
                log.info("Built container id=$it for execution.id=${execution.id}")
            }
        }
    }

    /**
     * @param execution an [Execution] for which containers are being started
     * @param agentIds list of IDs of agents (==containers) for this execution
     */
    fun startContainersAndUpdateExecution(execution: Execution, agentIds: List<String>) {
        val executionId = requireNotNull(execution.id) { "For project=${execution.project} method has been called with execution with id=null" }
        log.info("Sending request to make execution.id=$executionId RUNNING")
        webClientBackend
            .post()
            .uri("/updateExecutionByDto")
            .body(BodyInserters.fromValue(ExecutionUpdateDto(executionId, ExecutionStatus.RUNNING)))
            .retrieve()
            .toBodilessEntity()
            .subscribe()
        agentIds.forEach {
            log.info("Starting container id=$it")
            containerManager.dockerClient.startContainerCmd(it).exec()
        }
        log.info("Successfully started all containers for execution.id=$executionId")
    }

    /**
     * @param agentIds list of IDs of agents to stop
     * @return true if agents have been stopped, false if another thread is already stopping them
     */
    @Suppress("TOO_MANY_LINES_IN_LAMBDA")
    fun stopAgents(agentIds: List<String>) =
            if (isAgentStoppingInProgress.compareAndSet(false, true)) {
                try {
                    val containerList = containerManager.dockerClient.listContainersCmd().withShowAll(true).exec()
                    val runningContainersIds = containerList.filter { it.state == "running" }.map { it.id }
                    agentIds.forEach { agentId ->
                        if (agentId in runningContainersIds) {
                            log.info("Stopping agent with id=$agentId")
                            containerManager.dockerClient.stopContainerCmd(agentId).exec()
                            log.info("Agent with id=$agentId has been stopped")
                        } else {
                            val state = containerList.find { it.id == agentId }?.state ?: "deleted"
                            val warnMsg = "Agent with id=$agentId was requested to be stopped, but it actual state=$state"
                            log.warn(warnMsg)
                        }
                    }
                    true
                } catch (dex: DockerException) {
                    log.error("Error while stopping agents $agentIds", dex)
                    false
                } finally {
                    isAgentStoppingInProgress.lazySet(false)
                }
            } else {
                log.info("Agents stopping is already in progress, skipping")
                false
            }

    /**
     * @param imageName name of the image to remove
     * @return an instance of docker command
     */
    fun removeImage(imageName: String) {
        log.info("Removing image $imageName")
        val existingImages = containerManager.dockerClient.listImagesCmd().exec().map {
            it.id
        }
        if (imageName in existingImages) {
            containerManager.dockerClient.removeImageCmd(imageName).exec()
        } else {
            log.info("Image $imageName is not present, so won't attempt to remove")
        }
    }

    /**
     * @param containerId id of container to remove
     * @return an instance of docker command
     */
    fun removeContainer(containerId: String) {
        log.info("Removing container $containerId")
        val existingContainerIds = containerManager.dockerClient.listContainersCmd().withShowAll(true).exec()
            .map {
                it.id
            }
        if (containerId in existingContainerIds) {
            containerManager.dockerClient.removeContainerCmd(containerId).exec()
        } else {
            log.info("Container $containerId is not present, so won't attempt to remove")
        }
    }

    @Suppress(
        "TOO_LONG_FUNCTION",
        "UnsafeCallOnNullableType",
        "LongMethod",
    )
    private fun buildBaseImageForExecution(
        execution: Execution,
        testSuiteDtos: List<TestSuiteDto>?
    ): Triple<String, String, String> {
        val resourcesPath = File(
            configProperties.testResources.basePath,
            execution.resourcesRootPath!!,
        )
        val agentRunCmd = "./$SAVE_AGENT_EXECUTABLE_NAME"

        // collect standard test suites for docker image, which were selected by user, if any
        val testSuitesForDocker = collectStandardTestSuitesForDocker(testSuiteDtos)
        val testSuitesDir = resourcesPath.resolve(STANDARD_TEST_SUITE_DIR)

        // list is not empty only in standard mode
        val isStandardMode = testSuitesForDocker.isNotEmpty()

        if (isStandardMode) {
            // copy corresponding standard test suites to resourcesRootPath dir
            copyTestSuitesToResourcesPath(testSuitesForDocker, testSuitesDir)
            // move additional files, which were downloaded into the root dit to the execution dir for standard suites
            execution.additionalFiles?.split(";")?.filter { it.isNotBlank() }?.forEach {
                val additionalFilePath = resourcesPath.resolve(File(it).name)
                log.info("Move additional file $additionalFilePath into $testSuitesDir")
                moveFileWithAttributes(additionalFilePath, testSuitesDir)
            }
        }

        // if some additional file is archive, unzip it into proper destination:
        // for standard mode into STANDARD_TEST_SUITE_DIR
        // for Git mode into testRootPath
        unzipArchivesAmongAdditionalFiles(execution, isStandardMode, testSuitesDir, resourcesPath)

        val saveCliExecFlags = if (isStandardMode) {
            // create stub toml config in aim to execute all test suites directories from `testSuitesDir`
            val configData = createSyntheticTomlConfig(execution.execCmd, execution.batchSizeForAnalyzer)

            testSuitesDir.resolve("save.toml").apply { createNewFile() }.writeText(configData)
            " $STANDARD_TEST_SUITE_DIR --include-suites \"${testSuitesForDocker.joinToString(",") { it.name }}\""
        } else {
            ""
        }

        // include save-agent into the image
        val saveAgent = File(resourcesPath, SAVE_AGENT_EXECUTABLE_NAME)
        FileUtils.copyInputStreamToFile(
            ClassPathResource(SAVE_AGENT_EXECUTABLE_NAME).inputStream,
            saveAgent
        )

        // include save-cli into the image
        val saveCli = File(resourcesPath, SAVE_CLI_EXECUTABLE_NAME)
        FileUtils.copyInputStreamToFile(
            ClassPathResource(SAVE_CLI_EXECUTABLE_NAME).inputStream,
            saveCli
        )

        if (configProperties.adjustResourceOwner) {
            changeOwnerRecursively(resourcesPath, "cnb")
        }

        val baseImage = execution.sdk
        val aptCmd = "apt-get ${configProperties.aptExtraFlags}"
        // fixme: https://github.com/analysis-dev/save-cloud/issues/352
        val additionalRunCmd = if (execution.sdk.startsWith(Python.NAME, ignoreCase = true)) {
            """|RUN env DEBIAN_FRONTEND="noninteractive" $aptCmd install zip
               |RUN curl -s "https://get.sdkman.io" | bash
               |RUN bash -c 'source "${'$'}HOME/.sdkman/bin/sdkman-init.sh" && sdk install java 8.0.302-open'
               |RUN ln -s ${'$'}(which java) /usr/bin/java
            """.trimMargin()
        } else {
            ""
        }
        val imageId = containerManager.buildImageWithResources(
            baseImage = baseImage,
            imageName = imageName(execution.id!!),
            baseDir = resourcesPath,
            resourcesPath = executionDir,
            runCmd = """RUN $aptCmd update && env DEBIAN_FRONTEND="noninteractive" $aptCmd install -y \
                    |libcurl4-openssl-dev tzdata
                    |RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime
                    |$additionalRunCmd
                    |RUN rm -rf /var/lib/apt/lists/*
                    |RUN chmod +x $executionDir/$SAVE_AGENT_EXECUTABLE_NAME
                    |RUN chmod +x $executionDir/$SAVE_CLI_EXECUTABLE_NAME
                """
        )
        saveAgent.delete()
        saveCli.delete()
        return Triple(imageId, agentRunCmd, saveCliExecFlags)
    }

    private fun changeOwnerRecursively(directory: File, user: String) {
        // orchestrator is executed as root (to access docker socket), but files are in a shared volume
        val lookupService = directory.toPath().fileSystem.userPrincipalLookupService
        directory.walk().forEach {
            Files.getFileAttributeView(it.toPath(), PosixFileAttributeView::class.java, LinkOption.NOFOLLOW_LINKS).apply {
                setGroup(lookupService.lookupPrincipalByGroupName(user))
                setOwner(lookupService.lookupPrincipalByName(user))
            }
        }
    }

    @Suppress("TOO_MANY_LINES_IN_LAMBDA")
    private fun unzipArchivesAmongAdditionalFiles(
        execution: Execution,
        isStandardMode: Boolean,
        testSuitesDir: File,
        resourcesPath: File,
    ) {
        // FixMe: for now support only .zip files
        execution.additionalFiles?.split(";")?.filter { it.endsWith(".zip") }?.forEach {
            val fileLocation = if (isStandardMode) {
                testSuitesDir
            } else {
                val testRootPath = webClientBackend.post()
                    .uri("/findTestRootPathForExecutionByTestSuites")
                    .contentType(MediaType.APPLICATION_JSON)
                    .body(BodyInserters.fromValue(execution))
                    .retrieve()
                    .bodyToMono<List<String>>()
                    .block()!!
                    .distinct()
                    .single()
                resourcesPath.resolve(testRootPath)
            }

            val file = fileLocation.resolve(File(it).name)
            val shouldBeExecutable = file.canExecute()
            log.debug("Unzip ${file.absolutePath} into ${fileLocation.absolutePath}")

            file.unzipInto(fileLocation)
            if (shouldBeExecutable) {
                log.info("Marking files in $fileLocation executable...")
                fileLocation.walkTopDown().forEach { source ->
                    if (!source.setExecutable(true)) {
                        log.warn("Failed to mark file ${source.name} as executable")
                    }
                }
            }
            file.delete()
        }
    }

    private fun File.unzipInto(destination: File) {
        try {
            val zipFile = ZipFile(this.toString())
            zipFile.extractAll(destination.toString())
        } catch (e: ZipException) {
            log.error("Error occurred during extracting of archive ${this.name}")
            e.printStackTrace()
        }
    }

    private fun collectStandardTestSuitesForDocker(testSuiteDtos: List<TestSuiteDto>?): List<TestSuiteDto> = testSuiteDtos?.flatMap {
        webClientBackend.get()
            .uri("/standardTestSuitesWithName?name=${it.name}")
            .retrieve()
            .bodyToMono<List<TestSuite>>()
            .block()!!
    }?.map { it.toDto() } ?: emptyList()

    @Suppress("UnsafeCallOnNullableType", "TOO_MANY_LINES_IN_LAMBDA")
    private fun copyTestSuitesToResourcesPath(testSuitesForDocker: List<TestSuiteDto>, destination: File) {
        FileSystemUtils.deleteRecursively(destination)
        // TODO: https://github.com/analysis-dev/save-cloud/issues/321
        log.info("Copying suites ${testSuitesForDocker.map { it.name }} into $destination")
        testSuitesForDocker.forEach {
            val standardTestSuiteAbsolutePath = File(configProperties.testResources.basePath)
                // tmp directories names for standard test suites constructs just by hashCode of listOf(repoUrl); reuse this logic
                .resolve(File("${listOf(it.testSuiteRepoUrl!!).hashCode()}")
                    .resolve(it.testRootPath)
                )
            val currentSuiteDestination = destination.resolve(getLocationInStandardDirForTestSuite(it))
            if (!currentSuiteDestination.exists()) {
                log.debug("Copying suite ${it.name} from $standardTestSuiteAbsolutePath into $currentSuiteDestination/...")
                copyRecursivelyWithAttributes(standardTestSuiteAbsolutePath, currentSuiteDestination)
            }
        }
    }

    private fun createContainerForExecution(
        execution: Execution,
        imageId: String,
        containerNumber: String,
        runCmd: String,
        saveCliExecFlags: String,
    ): String {
        val containerId = containerManager.createContainerFromImage(
            imageId,
            executionDir,
            runCmd,
            containerName(containerNumber),
        )
        val agentPropertiesFile = createTempDirectory("agent")
            .resolve("agent.properties")
            .toFile()
        FileUtils.copyInputStreamToFile(
            ClassPathResource("agent.properties").inputStream,
            agentPropertiesFile
        )
        val cliCommand = "./$SAVE_CLI_EXECUTABLE_NAME$saveCliExecFlags"
        agentPropertiesFile.writeText(
            agentPropertiesFile.readLines().joinToString(System.lineSeparator()) {
                if (it.startsWith("id=")) {
                    "id=$containerId"
                } else if (it.startsWith("cliCommand=")) {
                    "cliCommand=$cliCommand"
                } else {
                    it
                }
            }
        )
        containerManager.copyResourcesIntoContainer(
            containerId, executionDir,
            listOf(agentPropertiesFile)
        )
        return containerId
    }

    companion object {
        private val log = LoggerFactory.getLogger(DockerService::class.java)
        private const val SAVE_AGENT_EXECUTABLE_NAME = "save-agent.kexe"
        private const val SAVE_CLI_EXECUTABLE_NAME = "save-$SAVE_CORE_VERSION-linuxX64.kexe"
    }
}

/**
 * @param executionId
 */
internal fun imageName(executionId: Long) = "save-execution:$executionId"

/**
 * @param id
 */
internal fun containerName(id: String) = "save-execution-$id"

/**
 * @param testSuiteDto
 */
internal fun getLocationInStandardDirForTestSuite(testSuiteDto: TestSuiteDto) =
        "$PREFIX_FOR_SUITES_LOCATION_IN_STANDARD_MODE${testSuiteDto.testSuiteRepoUrl.hashCode()}_${testSuiteDto.testRootPath.hashCode()}"

@Cheshiriks Cheshiriks added the bug Something isn't working label Jan 31, 2022
@petertrr
Copy link
Member

petertrr commented Feb 1, 2022

We have issue template for a reason. Also: https://stackoverflow.com/help/minimal-reproducible-example. I can't reproduce NPE on https://ktlint-demo.herokuapp.com, also how can there be NPE in AVOID_NULL_CHECKS if there are literally no comparisons with null in the snippet you provided?

@Cheshiriks
Copy link
Member Author

We have issue template for a reason. Also: https://stackoverflow.com/help/minimal-reproducible-example. I can't reproduce NPE on https://ktlint-demo.herokuapp.com, also how can there be NPE in AVOID_NULL_CHECKS if there are literally no comparisons with null in the snippet you provided?

Maybe Ktlint or something else breaks the code before that. I didn't manage to reproduce it in Diktat-Demo either, but it reproduce fine in Save-cloud.

[ERROR] 2022-02-03 13:06:28 Internal error has occurred in rule [null-checks]. Please make an issue on this bug at https://github.com/cqfn/diKTat/. 
                       As a workaround you can disable these inspections in yml config: <[AVOID_NULL_CHECKS]>.
                       Root cause of the problem is in [C:\Users\vwx1020336\IdeaProjects\save-cloud\save-orchestrator\src\main\kotlin\org\cqfn\save\orchestrator\service\DockerService.kt] file.
java.lang.NullPointerException: No operation reference for binary expression: [BINARY_EXPRESSION]
	at org.jetbrains.kotlin.psi.KtBinaryExpression.getOperationReference(KtBinaryExpression.java:71) ~[kotlin-compiler-embeddable-1.6.10.jar:1.6.10-release-923(1.6.10)]
	at org.jetbrains.kotlin.psi.KtBinaryExpression.getRight(KtBinaryExpression.java:54) ~[kotlin-compiler-embeddable-1.6.10.jar:1.6.10-release-923(1.6.10)]
	at org.cqfn.diktat.ruleset.rules.chapter4.NullChecksRule.isNullCheckBinaryExpression(NullChecksRule.kt:226) ~[diktat-rules-1.0.2.jar:?]
	at org.cqfn.diktat.ruleset.rules.chapter4.NullChecksRule.nullCheckInOtherStatements(NullChecksRule.kt:176) ~[diktat-rules-1.0.2.jar:?]
	at org.cqfn.diktat.ruleset.rules.chapter4.NullChecksRule.logic(NullChecksRule.kt:52) ~[diktat-rules-1.0.2.jar:?]
	at org.cqfn.diktat.ruleset.rules.DiktatRule.visit(DiktatRule.kt:50) ~[diktat-rules-1.0.2.jar:?]
	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:389) ~[ktlint-core-0.43.2.jar:?]
Exception in thread "main" 	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:382) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:313) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.KtLint$visitor$2$2.invoke(KtLint.kt:312) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:229) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
java.util.concurrent.ExecutionException: java.lang.Error: Internal error in diktat application	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]

	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]

	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.KtlintCommandLine.parallel(Main.kt:576)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.KtlintCommandLine.parallel$default(Main.kt:548)	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]

	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.KtlintCommandLine.lintFiles(Main.kt:298)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.KtlintCommandLine.run(Main.kt:262)	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]

	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.Main.main(Main.kt:70)
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.ast.PackageKt.visit(package.kt:230) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:312) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.KtLint$visitor$2.invoke(KtLint.kt:300) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.core.KtLint.format(KtLint.kt:382) ~[ktlint-core-0.43.2.jar:?]
	at com.pinterest.ktlint.internal.FileUtilsKt.formatFile(FileUtils.kt:202) ~[ktlint-0.43.2.jar:0.43.2]
	at com.pinterest.ktlint.KtlintCommandLine.process(Main.kt:366) ~[ktlint-0.43.2.jar:0.43.2]
	at com.pinterest.ktlint.KtlintCommandLine.access$process(Main.kt:89) ~[ktlint-0.43.2.jar:0.43.2]
	at com.pinterest.ktlint.KtlintCommandLine$lintFiles$3.invoke$lambda-0(Main.kt:289) ~[ktlint-0.43.2.jar:0.43.2]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: java.lang.Error: Internal error in diktat application
	at org.cqfn.diktat.ruleset.rules.DiktatRule.visit(DiktatRule.kt:61)
	at com.pinterest.ktlint.core.KtLint$format$1.invoke(KtLint.kt:389)

@petertrr
Copy link
Member

petertrr commented Feb 3, 2022

it reproduce fine in Save-cloud.

With which config options? It's not reproducible from master: https://github.com/analysis-dev/save-cloud/runs/5049639800?check_suite_focus=true

@Cheshiriks
Copy link
Member Author

Cheshiriks commented Feb 3, 2022

it reproduce fine in Save-cloud.

With which config options? It's not reproducible from master: https://github.com/analysis-dev/save-cloud/runs/5049639800?check_suite_focus=true

Here with such diktat-analysis.

- name: DIKTAT_COMMON
  configuration:
    domainName: net.yewton
    kotlinVersion: 1.5.31
- name: MISSING_KDOC_TOP_LEVEL
  enabled: false
- name: USE_DATA_CLASS
  enabled: false
- name: MISSING_KDOC_CLASS_ELEMENTS
  enabled: false
- name: CUSTOM_GETTERS_SETTERS
  enabled: false
- name: TRAILING_COMMA
  enabled: false
- name: AVOID_NULL_CHECKS 
  enabled: true

If in config disable option AVOID_NULL_CHECKS, then the diktat will fail on SAY_NO_TO_VAR in DockerService.kt

@orchestr7 orchestr7 added this to the 1.0.4 milestone Feb 22, 2022
@orchestr7
Copy link
Member

@Arrgentum what's with this issue: please mark here new issues if you have opened new

@Arrgentum
Copy link
Member

Arrgentum commented Apr 13, 2022

Problem was found and will be fixed and investigated here:

#1244
#1243
#1242
#1241

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

No branches or pull requests

4 participants