Skip to content

Why are the code is warning that “Function has redundant suspend modifier.” in detekt ? #5231

Answered by schalkms
tmdgusya asked this question in Q&A
Discussion options

You must be logged in to vote

The posted code doesn't trigger the RedundantSuspendModifier rule during my test with the following test code snippet.
I think type resolution isn't correctly configured in your project.

@Test
fun `discussion #5231`() {
    val code = """
        import kotlinx.coroutines.Dispatchers
        import kotlinx.coroutines.delay
        import kotlinx.coroutines.launch
        import kotlinx.coroutines.runBlocking

        class Test {

            fun networkRequestTest() {
                runBlocking(Dispatchers.IO) {
                    doNetworkRequest("test1")
                    doNetworkRequest("test2")
                }
            }

            private suspend fun doNetworkRequest(nam…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by schalkms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants