If we apply SafeButNotConsensualMutators to our sources, all calls of this(); inside a constructor are removed.
This shouldn't be considered a safe operation, because other constructors may call the "empty" default constructor to initialise an object properly.
class Horse {
private String sound;
private String name;
Horse() {
// here it is a static assignment
// however, this might be fetched from any other class
sound = "neigh neigh";
}
Horse(String name) {
this(); // <-- this is removed if applying "SafeButNotConsensualMutators"
this.name = name;
}
Horse(String name, String sound) {
this.name = name;
this.sound = sound;
}
}
If we apply SafeButNotConsensualMutators to our sources, all calls of
this();
inside a constructor are removed. This shouldn't be considered a safe operation, because other constructors may call the "empty" default constructor to initialise an object properly.Example: Gradle Configuration
Java Source Code