in src/main/kotlin/com/dd/detektcustomrules/rules/ExposingMutableObservableTypeProps.kt [19:31]
override fun visitProperty(property: KtProperty) {
super.visitProperty(property)
// check if property is accessible from outside of its class
if (property.isMember && (property.isPublic || property.isProtected())) {
val dataType = property.typeReference?.text // with declared type
?: (property.initializer?.firstChild?.text ?: "") // with inferred type
if (mutableObservableDataTypes.contains(dataType)) {
report(CodeSmell(issue = issue, entity = Entity.from(property), message = "${property.name} is accessible from outside of its class and is prone to unpredictable data updates. To restrict write access, ${dataType.replace("Mutable", "")} should be used together with a private $dataType field."))
}
}
}