Skip to content

Commit

Permalink
New warning: Unused imports should be removed
Browse files Browse the repository at this point in the history
### What's done:
* Added new warning
* Added new test
  • Loading branch information
Cheshiriks committed Jan 21, 2021
1 parent fc1637a commit 59341d8
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class FileStructureRuleTest : LintTestBase(::FileStructureRule) {
|
|class Example {
|val x: Test = null
|val x: Foo = null
|val y: Foo = null
|}
""".trimMargin(),
LintError(3, 1, ruleId, "${FILE_UNORDERED_IMPORTS.warnText()} import org.cqfn.diktat.example.Foo...", true)
LintError(3, 1, ruleId, "${FILE_UNORDERED_IMPORTS.warnText()} import org.cqfn.diktat.Foo...", true)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package org.cqfn.diktat.example

import org.cqfn.diktat.example.Foo
import org.cqfn.diktat.Foo

class Example
class Example {
val y: Foo = Foo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ import foo.Bar
/**
* KDoc
*/
class Example
class Example{
val x: Bar = Bar()
val y: Baz = Baz()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ import baz.Baz
/**
* KDoc
*/
class Example
class Example{
val x: Bar = Bar()
val y: Baz = Baz()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
*/
@file:JvmName("Foo")
package org.cqfn.diktat.example
import org.cqfn.diktat.example.Foo
class Example
import org.cqfn.diktat.Foo
class Example {
val y: Foo = Foo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
package org.cqfn.diktat.example


import org.cqfn.diktat.example.Foo
import org.cqfn.diktat.Foo







class Example
class Example {
val y: Foo = Foo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import org.cqfn.diktat.example.Bar
import org.cqfn.diktat.example.Foo
import org.junit.jupiter.api.Test

class Example
class Example {
val x: Test = Test()
val y: Foo = Foo()
val z: Bar = Bar()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,12 @@ import java.nio.charset.Charset

import kotlin.system.exitProcess

class Example
class Example {
val x = setOf<Object>(CaseFormat(), Detekt(), Assertions(), Logger(), Bean(), IOException(), URL(), Charset(), ObjectMapper())

fun Foo() {
while (true) {
exitProcess(1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@ import java.nio.charset.Charset
import io.gitlab.arturbosch.detekt.Detekt
import org.slf4j.Logger

class Example
class Example {
val x = setOf<Object>(CaseFormat(), Detekt(), Assertions(), Logger(), Bean(), IOException(), URL(), Charset(), ObjectMapper())

fun Foo() {
while (true) {
exitProcess(1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ import org.junit.jupiter.api.Test
import org.cqfn.diktat.example.Foo
// lorem ipsum
import org.cqfn.diktat.example.Bar
class Example
class Example {
val x: Test = Test()
val y: Foo = Foo()
val z: Bar = Bar()
}

0 comments on commit 59341d8

Please sign in to comment.