saveourtool/diktat

`WRONG_NEWLINES` false positives

Open

#1,495 opened on Aug 9, 2022

 (0 comments) (0 reactions) (1 assignee)Kotlin (40 forks)github user discovery
buggood first issue

Repository metrics

Stars
 (571 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Examples:

        private fun IndentedSourceCode.customConfig(): SortedMap<String, out Boolean> =
            mapOf(
                EXTENDED_INDENT_AFTER_OPERATORS to extendedIndentAfterOperators,
                EXTENDED_INDENT_BEFORE_DOT to extendedIndentBeforeDot,
                EXTENDED_INDENT_FOR_EXPRESSION_BODIES to extendedIndentForExpressionBodies,
                EXTENDED_INDENT_OF_PARAMETERS to extendedIndentOfParameters,
            ).mapValues { (_, value) ->
                value.valueOrNull
            }.filterValues { value ->
                value != null
            }.mapValues { (_, value) ->
                value!!
            }.toSortedMap()
                val columnNumbers = decimalNumber
                    .findAll(detail)
                    .map { match ->
                        match.groups[1]?.value
                    }.filterNotNull()
                    .map(String::toInt)
                    .toList()
                    .takeLast(2)
        val joinedPaths = keys
            .asSequence()
            .map { path ->
                path.tryToDeleteOnExit()
            }.map { path ->
                path.relativizeSafely()
            }.map(Any::toString)
            .joinToString()
        private val warningNames = WarningNames::class
            .declaredMemberProperties
            .asSequence()
            .map { property ->
                property.name
            }.toSet()
        val filteredCode = code
            .trimIndent()
            .lineSequence()
            .mapIndexed { index, line ->
                extractExpectedError(index, line, codeAnnotationRegex)
            }.map { (line, expectedError) ->
                if (expectedError != null) {
                    expectedErrors += expectedError
                }

                line
            }.joinToString(separator = NEWLINE.toString())
        val supportedTags = context
            .tags
            .asSequence()
            .filter { tag ->
                tag in warningNames
            }.toList()

Environment information

  • diktat version: 1.2.3

Contributor guide