8000 `CouldBeSequence` is missing some functions · Issue #8190 · detekt/detekt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000
CouldBeSequence is missing some functions #8190
Open
@marschwar

Description

@marschwar

Expected Behavior

The CouldBeSequence rule should check for all standard lib collection functions that return a new collection instance.

Observed Behavior

Some functions are not accounted for even though they create a new collection and should be replaced by a sequence.

Steps to Reproduce

    @Test
    fun `all functions should be accounted for`() {
        val code = """
        val bar = listOf<String?>("bar")
            .filterIsInstance<String>()
            .filterNot { true }
            .filterNotNull()
            .take(1)
            .drop(1)
            .takeWhile { true }
            .mapNotNull { it }
        """.trimIndent()
        assertThat(subject.lintWithContext(env, code)).hasSize(1)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0