A member of a final class or an object is protected, which acts as private there
What it finds
Only subclasses can use a protected member, and a class that is neither open, abstract nor sealed, or an object, has none. The modifier then means private and suggests an extension point that does not exist.
From the rule's source, protected_in_final.rs.
class Final { protected fun hook() {}tx0 reports: hook is protected in a type that has no subclasses protected val state = 1tx0 reports: state is protected} open class Open { protected open fun hook() {}} class Child : Open() { override fun hook() {}} object Single { protected fun hook() {}tx0 reports: hook is protected} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:protected-in-final-class" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/kotlin:protected-in-final-class] reason="..."tx0 explain tx0/kotlin:protected-in-final-class shows the same in the terminal. Found a false positive? Report it.