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

ArgumentListWrapping reports false positive since 0.41.0 #1159

Closed
WonderCsabo opened this issue May 28, 2021 · 7 comments
Closed

ArgumentListWrapping reports false positive since 0.41.0 #1159

WonderCsabo opened this issue May 28, 2021 · 7 comments

Comments

@WonderCsabo
Copy link

WonderCsabo commented May 28, 2021

I have the following code snippet:

class MyClass {

    private fun initCoilOkHttp() {
        Coil.setImageLoader(
            ImageLoader.Builder(this)
                .crossfade(true)
                .okHttpClient(
                    okHttpClient.newBuilder()
                        .cache(CoilUtils.createDefaultCache(this))
                        .build()
                )
                .build()
        )
    }
}

Expected Behavior

Ktlint should not report any issues

Observed Behavior

Since Ktlint 0.41.0, the ArgumentListWrappingRule reports the following:

Unexpected indentation (expected 16, actual 20)
Unexpected indentation (expected 12, actual 16)

It means it tells this would be correct:

class MyClass {

    private fun initCoilOkHttp() {
        Coil.setImageLoader(
            ImageLoader.Builder(this)
                .crossfade(true)
                .okHttpClient(
                okHttpClient.newBuilder()
                    .cache(CoilUtils.createDefaultCache(this))
                    .build()
            )
                .build()
        )
    }
}

Steps to Reproduce

Run ktlint codesnippet.kt --android --experimental

Your Environment

  • Version of ktlint used: 0.41.0
  • Name and version (or code for custom task) of integration used (Gradle plugin, Maven plugin, command line, custom Gradle task): command line
  • Operating System and version: macOS 11.2.3
@paul-dingemans
Copy link
Collaborator

I have solved issue's like this in PR #1052 which is still waiting to be merged.

@WonderCsabo
Copy link
Author

Thanks! However i've just built your branch and my case above still produced the false positives.

@paul-dingemans
Copy link
Collaborator

Sorry for miscommunication. The PR mentioned above is the first PR of a range of 5 PR's. Originally I submitted one big PR resolving many identation issues. On request of maintainers I have split it into multiple smaller PR's. The other PR's can only be submitted once the first is merged.

@shashachu
Copy link
Contributor

Looks like it was introduced in this commit: 3591e61

shashachu added a commit to shashachu/ktlint that referenced this issue Aug 5, 2021
shashachu added a commit to shashachu/ktlint that referenced this issue Aug 5, 2021
romtsn pushed a commit to paul-dingemans/ktlint that referenced this issue Aug 8, 2021
* Revert "Fix false positive when argument list is after multiline dot-qualified expression (pinterest#1025)"

This reverts commit 3591e61.

* Fix regression with argument-list-wrapping after dot qualified expression without assignment

Fixes pinterest#1159
@osipxd
Copy link

osipxd commented Sep 1, 2021

Messed with this issue again on 0.42.1

fun onSendMessageClicked() {
    flow { chat.sendMessage(state.messageInput) }
        .onEach { state ->
            updateState(
                messageIsSending = state.isLoading, // <-- ArgumentListWrapping
                messageInput = "", // <-- ArgumentListWrapping
            ) // <-- ArgumentListWrapping
        }
        .launchIn(coroutineScope)
}

@paul-dingemans
Copy link
Collaborator

@osipxd You commented a closed issue. Also it is not clear what the problem or your expectation is. Maybe it is better to open a new issue?

@osipxd
Copy link

osipxd commented Sep 1, 2021

Sorry, it was due to old ktlint version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants