CloneMethodMustImplementCloneable ignore inheritence
A source code analyzer
Brought to you by:
adangel,
juansotuyo
CloneMethodMustImplementCloneable trigger an error when extending a class which implements Clonable.
example:
public class MyAbstractClass implements Cloneable{
}
public class MyClonableClass extends MyAbstractClass{
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
Logged In: YES
user_id=1127445
Originator: NO
This can be addressed with the type resolution framework.
Logged In: YES
user_id=1879633
Originator: NO
Looks like this is still a issue. This rule reporting vioations incorrectly. I have latest stable version 4.0
Logged In: YES
user_id=1679130
Originator: NO
Yes it still an issue, i believe Allan Caplan whish to fix it with the new type resolution framework, but he probably not have the time yet... We'll try to close this issue next release.
Thanks for the report.
Logged In: YES
user_id=1127445
Originator: NO
In 4.0 release you can use the typeresolution ruleset - it has a CloneMethodMustImplementCloneable rule which will do what you want.
I'll be merging it and removing the type resolution ruleset shortly
Logged In: YES
user_id=1879633
Originator: NO
I am sorry i did'nt realise this bug is for XPath rule 'CloneMethodMustImplementCloneable' i thought this is for type resolution and java rule 'CloneMethodMustImplementCloneable'. Any way type resolution rule 'CloneMethodMustImplementCloneable' is also incorrectly reporting violation even though super class is implementing Cloneable interface. I have configured typeResolution attribute to true in rule config file. I am not sure if this is the correct platform to report but any way i am doing it sorry for that.
As stated, this one is fixed with the typeresolution-CloneMethodMustImplementCloneable rule.