Introduce "Logger initialized with foreign class" inspection
^KT-38982 Fixed
This commit is contained in:
committed by
Nikita Bobko
parent
c6e23ffa3b
commit
23c4eac45b
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.logging.KotlinLoggerInitializedWithForeignClassInspection
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.canonicalName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.canonicalName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
idea/testData/inspectionsLocal/logging/loggerInitializedWithForeignClass/commons/getCanonicalName.kt
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.getCanonicalName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.getCanonicalName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.getName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.getName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.getSimpleName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.getSimpleName())
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
idea/testData/inspectionsLocal/logging/loggerInitializedWithForeignClass/commons/kclassSimpleName.kt
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.simpleName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.simpleName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.name)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.name)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// PROBLEM: none
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Foo::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// PROBLEM: Logger initialized with foreign class 'Bar::class'
|
||||
// FIX: Replace with 'Foo::class'
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// PROBLEM: Logger initialized with foreign class 'Bar::class'
|
||||
// FIX: Replace with 'Foo::class'
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(<caret>Bar::class.java.simpleName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
idea/testData/inspectionsLocal/logging/loggerInitializedWithForeignClass/commons/simpleName.kt.after
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.commons.logging
|
||||
|
||||
class Foo {
|
||||
private val logger = LogFactory.getLog(Foo::class.java.simpleName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogFactory {
|
||||
fun getLog(clazz: Class<*>) {}
|
||||
fun getLog(name: String?) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.log4j
|
||||
|
||||
class Foo {
|
||||
private val logger = Logger.getLogger(<caret>Bar::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object Logger {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.log4j
|
||||
|
||||
class Foo {
|
||||
private val logger = Logger.getLogger(Foo::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object Logger {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.logging.log4j
|
||||
|
||||
class Foo {
|
||||
private val logger = LogManager.getLogger(<caret>Bar::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogManager {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.apache.logging.log4j
|
||||
|
||||
class Foo {
|
||||
private val logger = LogManager.getLogger(Foo::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LogManager {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.slf4j
|
||||
|
||||
class Foo {
|
||||
private val logger = LoggerFactory.getLogger(<caret>Bar::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LoggerFactory {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
package org.slf4j
|
||||
|
||||
class Foo {
|
||||
private val logger = LoggerFactory.getLogger(Foo::class.java)
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
||||
object LoggerFactory {
|
||||
fun getLogger(clazz: Class<*>) {}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
package util
|
||||
|
||||
import java.util.logging.Logger
|
||||
|
||||
class Foo {
|
||||
private val logger = Logger.getLogger(<caret>Bar::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
package util
|
||||
|
||||
import java.util.logging.Logger
|
||||
|
||||
class Foo {
|
||||
private val logger = Logger.getLogger(Foo::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
package util
|
||||
|
||||
import java.util.logging.Logger.getLogger
|
||||
|
||||
class Foo {
|
||||
private val logger = getLogger(<caret>Bar::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
package util
|
||||
|
||||
import java.util.logging.Logger.getLogger
|
||||
|
||||
class Foo {
|
||||
private val logger = getLogger(Foo::class.qualifiedName)
|
||||
}
|
||||
|
||||
class Bar
|
||||
Reference in New Issue
Block a user