Introduce "Logger initialized with foreign class" inspection
^KT-38982 Fixed
This commit is contained in:
committed by
Nikita Bobko
parent
c6e23ffa3b
commit
23c4eac45b
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?) {}
|
||||
}
|
||||
Reference in New Issue
Block a user