Using reflection to find and report deprecated uniques (#5276)

* Using reflection to find and report deprecated uniques

* No kotlin reflection needed thank you very much
This commit is contained in:
Yair Morgenstern 2021-09-21 20:26:05 +03:00 committed by GitHub
parent 7a59cbcbe8
commit 05394f627d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -312,11 +312,19 @@ class Ruleset {
if (unique.type == null) continue
val complianceErrors = unique.type.getComplianceErrors(unique, this)
for (complianceError in complianceErrors) {
if (complianceError.errorSeverity == severityToReport)
if (complianceError.errorSeverity == severityToReport)
lines += "$name's unique \"${unique.text}\" contains parameter ${complianceError.parameterName}," +
" which does not fit parameter type" +
" ${complianceError.acceptableParameterTypes.joinToString(" or ") { it.parameterName }} !"
}
val deprecationAnnotation = unique.type.declaringClass.getField(unique.type.name)
.getAnnotation(Deprecated::class.java)
if (deprecationAnnotation != null) {
// Not user-visible
println("$name's unique \"${unique.text}\" is deprecated ${deprecationAnnotation.message}," +
" replace with \"${deprecationAnnotation.replaceWith.expression}\"")
}
}
}