-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loggers sometimes shouldn't be first (#1624)
* loggers sometimes shouldn't be first ### What's done: * Added simple dependency check when looking for logger that could be first property * Added test (#1602)
- Loading branch information
1 parent
cb102a2
commit 82ee915
Showing
7 changed files
with
143 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ class Example { | |
} | ||
|
||
class UnusedNested { } | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ class Example { | |
* Dolor sit amet | ||
*/ | ||
private val BAZ = 44 | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
diktat-rules/src/test/resources/test/paragraph3/file_structure/LoggerOrderExpected.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package test.paragraph3.file_structure | ||
|
||
import org.junit.platform.commons.logging.LoggerFactory | ||
|
||
class LoggerOrderExample { | ||
private val logger = getLogger("string template") | ||
private val logger = getLogger("""string template""") | ||
private val logger = getLogger(""" | ||
string template | ||
""") | ||
private val logger = getLogger(this.javaClass) | ||
private val logger = getLogger(this.javaClass.name) | ||
private val logger = getLogger(javaClass) | ||
private val logger = getLogger(javaClass.name) | ||
private val logger = getLogger(Foo::class.java) | ||
private val logger = getLogger(Foo::class.java.name) | ||
private val logger = getLogger(Foo::class) | ||
private val logger = getLogger(Foo::class.name) | ||
private val logger = getLogger<Foo>() | ||
private val logger = getLogger({}.javaClass) | ||
private val a = "a" | ||
private val b = "b" | ||
private val c = "c" | ||
private val d = "d" | ||
private val e = "e" | ||
private val f = "f" | ||
private val g = "g" | ||
private val h = "h" | ||
private val i = "i" | ||
private val j = "j" | ||
private val k = "k" | ||
private val l = "l" | ||
private val m = "m" | ||
private val logger = LoggerFactory.getLogger(m) | ||
private val n = "n" | ||
private val logger = n.getLogger() | ||
private val o = "o" | ||
private val logger = o { get() } | ||
private val p = "p" | ||
private val logger = p::class.java.enclosingClass | ||
private val q = "q" | ||
private val logger = q::class.java | ||
private val r = "r" | ||
private val logger = r::javaClass | ||
private val s = "s" | ||
private val t = "t" | ||
private val logger = getLogger("$s$t") | ||
private val u = "u" | ||
private val v = "v" | ||
private val w = "w" | ||
private val x = "x" | ||
private val y = "y" | ||
private val z = "z" | ||
private val logger = getLogger("$s$t$u$v$w") { x + y + z } | ||
} |
55 changes: 55 additions & 0 deletions
55
diktat-rules/src/test/resources/test/paragraph3/file_structure/LoggerOrderTest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package test.paragraph3.file_structure | ||
|
||
import org.junit.platform.commons.logging.LoggerFactory | ||
|
||
class LoggerOrderExample { | ||
private val logger = getLogger("string template") | ||
private val a = "a" | ||
private val logger = getLogger("""string template""") | ||
private val b = "b" | ||
private val logger = getLogger(""" | ||
string template | ||
""") | ||
private val c = "c" | ||
private val logger = getLogger(this.javaClass) | ||
private val d = "d" | ||
private val logger = getLogger(this.javaClass.name) | ||
private val e = "e" | ||
private val logger = getLogger(javaClass) | ||
private val f = "f" | ||
private val logger = getLogger(javaClass.name) | ||
private val g = "g" | ||
private val logger = getLogger(Foo::class.java) | ||
private val h = "h" | ||
private val logger = getLogger(Foo::class.java.name) | ||
private val i = "i" | ||
private val logger = getLogger(Foo::class) | ||
private val j = "j" | ||
private val logger = getLogger(Foo::class.name) | ||
private val k = "k" | ||
private val logger = getLogger<Foo>() | ||
private val l = "l" | ||
private val logger = getLogger({}.javaClass) | ||
private val m = "m" | ||
private val logger = LoggerFactory.getLogger(m) | ||
private val n = "n" | ||
private val logger = n.getLogger() | ||
private val o = "o" | ||
private val logger = o { get() } | ||
private val p = "p" | ||
private val logger = p::class.java.enclosingClass | ||
private val q = "q" | ||
private val logger = q::class.java | ||
private val r = "r" | ||
private val logger = r::javaClass | ||
private val s = "s" | ||
private val t = "t" | ||
private val logger = getLogger("$s$t") | ||
private val u = "u" | ||
private val v = "v" | ||
private val w = "w" | ||
private val x = "x" | ||
private val y = "y" | ||
private val z = "z" | ||
private val logger = getLogger("$s$t$u$v$w") { x + y + z } | ||
} |