UseSingletonRule: too restrictive in some cases
A source code analyzer
Brought to you by:
adangel,
juansotuyo
Hi,
we have a base class with 1 static helper method in.
public class BaseDao extends BaseObject {
// protected constructor to prevent other classes
// making instances of this class directly
protected BaseDao() {
super();
}
protected static String load(String file) {
... // load something from the file
}
}
Concrete implementations extends from this base class:
public class PersonDao extends BaseDao {
private static final String SQL =
load("selectperson.sql");
public PersonDao() {
super();
}
public Person findPerson(String id) {
...
}
}
The UseSingletonRule triggers on the BaseDao class, but
it shouldn't!
Perhaps the UseSingletonRule class could ignore classes
that:
- extend from another class, or
- has a protected constructor
what do you think?
regards,
Maarten