Skip to content

Commit

Permalink
Regard SuppressWarnings also
Browse files Browse the repository at this point in the history
Add more test for different annotations use sites.
  • Loading branch information
AleksandrSl committed Jul 30, 2018
1 parent 45d9993 commit 611efb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ object KtLint {
psi.annotationEntries
.filter {
it.calleeExpression?.constructorReferenceExpression
?.getReferencedName() == "Suppress"
?.getReferencedName() in suppressAnnotations
}.flatMap(KtAnnotationEntry::getValueArguments)
.mapNotNull { it.getArgumentExpression()?.text?.removeSurrounding("\"") }
.mapNotNull(suppressAnnotationRuleMap::get)
Expand Down Expand Up @@ -480,6 +480,8 @@ object KtLint {
private val suppressAnnotationRuleMap = mapOf(
"RemoveCurlyBracesFromTemplate" to "string-template"
)

private val suppressAnnotations = setOf("Suppress", "SuppressWarnings")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,33 @@ fun main() {

class B(val k: String) {
override fun toString(): String = "${super.toString()}, ${super.hashCode().toString()}, k=$k"

@Suppress("RemoveCurlyBracesFromTemplate", "Shit")
val a
get() = "${s0}"
}

@Suppress("RemoveCurlyBracesFromTemplate")
class C {
override fun toString(): String = "${s0}"
}

class D {
@Suppress("RemoveCurlyBracesFromTemplate")
override fun toString(): String = "${s0}"

fun test() = "${s0}"
}

@SuppressWarnings("RemoveCurlyBracesFromTemplate")
class E {
override fun toString(): String = "${s0}"
}

// expect
// 2:29:Redundant "toString()" call in string template
// 3:28:Redundant "toString()" call in string template
// 6:15:Redundant curly braces
// 7:15:Redundant curly braces
// 28:79:Redundant "toString()" call in string template
// 44:20:Redundant curly braces

0 comments on commit 611efb7

Please sign in to comment.