Report jre deprecated warning when version is set implicitly (KT-26933)
#KT-26933 Fixed
This commit is contained in:
+6
-1
@@ -37,7 +37,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlo
|
|||||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall
|
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall
|
||||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression
|
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression
|
||||||
|
|
||||||
private val LibInfo.gradleMarker get() = "$groupId:$name:"
|
private val LibInfo.gradleMarker get() = "$groupId:$name"
|
||||||
|
|
||||||
class DeprecatedGradleDependencyInspection : GradleBaseInspection() {
|
class DeprecatedGradleDependencyInspection : GradleBaseInspection() {
|
||||||
override fun buildVisitor(): BaseInspectionVisitor = DependencyFinder()
|
override fun buildVisitor(): BaseInspectionVisitor = DependencyFinder()
|
||||||
@@ -62,6 +62,11 @@ class DeprecatedGradleDependencyInspection : GradleBaseInspection() {
|
|||||||
val libMarker = outdatedInfo.old.gradleMarker
|
val libMarker = outdatedInfo.old.gradleMarker
|
||||||
|
|
||||||
if (dependencyText.contains(libMarker)) {
|
if (dependencyText.contains(libMarker)) {
|
||||||
|
val afterMarkerChar = dependencyText.substringAfter(libMarker).getOrNull(0)
|
||||||
|
if (!(afterMarkerChar == '\'' || afterMarkerChar == '"' || afterMarkerChar == ':')) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
val libVersion =
|
val libVersion =
|
||||||
DifferentStdlibGradleVersionInspection.getResolvedLibVersion(
|
DifferentStdlibGradleVersionInspection.getResolvedLibVersion(
|
||||||
dependencyStatement.containingFile, outdatedInfo.old.groupId, listOf(outdatedInfo.old.name)
|
dependencyStatement.containingFile, outdatedInfo.old.groupId, listOf(outdatedInfo.old.name)
|
||||||
|
|||||||
+39
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.inspections.gradle.DifferentKotlinGradleVersion
|
|||||||
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentStdlibGradleVersionInspection
|
import org.jetbrains.kotlin.idea.inspections.gradle.DifferentStdlibGradleVersionInspection
|
||||||
import org.jetbrains.kotlin.idea.inspections.gradle.GradleKotlinxCoroutinesDeprecationInspection
|
import org.jetbrains.kotlin.idea.inspections.gradle.GradleKotlinxCoroutinesDeprecationInspection
|
||||||
import org.jetbrains.kotlin.idea.inspections.runInspection
|
import org.jetbrains.kotlin.idea.inspections.runInspection
|
||||||
|
import org.jetbrains.plugins.gradle.tooling.annotation.TargetVersions
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -344,6 +345,44 @@ class GradleInspectionTest : GradleImportingTestCase() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetVersions("4.9+")
|
||||||
|
@Test
|
||||||
|
fun testJreIsDeprecatedWithoutImplicitVersion() {
|
||||||
|
val localFile = createProjectSubFile(
|
||||||
|
"build.gradle", """
|
||||||
|
group 'Again'
|
||||||
|
version '1.0-SNAPSHOT'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
val tool = DeprecatedGradleDependencyInspection()
|
||||||
|
val problems = getInspectionResult(tool, localFile)
|
||||||
|
|
||||||
|
Assert.assertTrue(problems.size == 1)
|
||||||
|
Assert.assertEquals(
|
||||||
|
"kotlin-stdlib-jre8 is deprecated since 1.2.0 and should be replaced with kotlin-stdlib-jdk8",
|
||||||
|
problems.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testObsoleteCoroutinesUsage() {
|
fun testObsoleteCoroutinesUsage() {
|
||||||
val localFile = createProjectSubFile(
|
val localFile = createProjectSubFile(
|
||||||
|
|||||||
Reference in New Issue
Block a user