Created
June 11, 2020 12:50
-
-
Save guilhermekrz/49176fa05ab1e48755e281dda63f43b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun `two calls to OkHttpClient constructor in different files`() { | |
val javaFile = java( | |
""" | |
package com.brokoli.lint; | |
import okhttp3.OkHttpClient; | |
class MyClass { | |
public void method1() { | |
new OkHttpClient(); | |
} | |
} | |
""" | |
).indented() | |
val kotlinFile = kotlin( | |
""" | |
package com.brokoli.lint | |
import okhttp3.OkHttpClient | |
class MyClass { | |
fun method1() { | |
OkHttpClient() | |
} | |
} | |
""" | |
).indented() | |
val lintResult = lint() | |
.files(okHttpClientFile, javaFile, kotlinFile) | |
.run() | |
lintResult | |
.expectWarningCount(2) | |
.expect(""" | |
src/com/brokoli/lint/MyClass.java:8: Warning: You should only create one OkHttpClient instance [MoreThanOneOkHttpClientDetector] | |
new OkHttpClient(); | |
~~~~~~~~~~~~~~~~~~ | |
src/com/brokoli/lint/MyClass.kt:8: Warning: You should only create one OkHttpClient instance [MoreThanOneOkHttpClientDetector] | |
OkHttpClient() | |
~~~~~~~~~~~~~~ | |
0 errors, 2 warnings | |
""".trimIndent()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment