new Check: EmptyPublicCtorInFinalClassCheck #186

Closed
romani opened this Issue May 10, 2014 · 1 comment

Projects

None yet

5 participants

@romani
Member
romani commented May 10, 2014

following code is happen :

class MyClass {
 MyClass() {
   super();
 }
}

nobody extend this class, this class does not extend anything - its c-tor is completely useless, especially "super()";

Checkstyle idea - EmptyPublicCtorInFinalClass,

base on investigation why empty ctor could be necessary - http://stackoverflow.com/questions/3507281/java-inheritance-problem-have-to-create-empty-constructor-in-father-class,

we can not completely cover code case that described above, as Checkstyle does not have information about other classes (nobody can predict who can extend from MyClass).

What we can be sure is final class can not be extended - so we could catch that cases.
Nuances:

  • we can check class only if it final and do not "extend" anything.
  • private c-tor is OK in utility classes.
  • ignoreSuperCtorCall - Additionally check for "super();" in class's non default c-tor and this class does not extend anything.
  • even class is not final, but do not extend anything , call of "super();" is useless and should be caught by this Check.
@jmcoelho7 jmcoelho7 was assigned by romani May 11, 2014
@daniilyar daniilyar added moderate and removed enhancement labels Aug 15, 2014
@jmcoelho7 jmcoelho7 was unassigned by romani Sep 26, 2014
@daniilyar daniilyar assigned Alexey2701 and alex-zuy and unassigned Alexey2701 Oct 14, 2014
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy New Check UselessSuperCtorCallCheck implemented. Fixes issue #186 c6c0db8
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemented. Fixes #186 3ef8705
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemented. Fixes #186 3426325
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemented. Fixes #186 e74e851
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 8b587d2
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Oct 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 d0e4252
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Nov 11, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 a5d94c4
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Nov 18, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 abe0047
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Nov 18, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 77110be
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Nov 28, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 12732f7
@romani
Member
romani commented Nov 29, 2014

just for future reference: http://stackoverflow.com/a/6318640

@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Nov 29, 2014
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 20e5bd3
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Dec 24, 2014
@alex-zuy alex-zuy New Check EmptyPublicCtorInClassCheck implemented. fixes #186 3ead707
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Dec 28, 2014
@alex-zuy alex-zuy New Check EmptyPublicCtorInClassCheck implemented. fixes #186 0a71cfe
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Dec 28, 2014
@alex-zuy alex-zuy new Check EmptyPublicCtorInClassCheck implemented. fixes #186 a25d102
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Jan 2, 2015
@alex-zuy alex-zuy New Check EmptyPublicCtorInClassCheck implemented. fixes #186 582dc3c
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Jan 2, 2015
@alex-zuy alex-zuy new Check EmptyPublicCtorInClassCheck implemented. fixes #186 beee996
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Jan 2, 2015
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 a58590f
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Jan 29, 2015
@alex-zuy alex-zuy New Check EmptyPublicCtorInClassCheck implemented. fixes #186 00d1cf4
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Jan 29, 2015
@alex-zuy alex-zuy new Check EmptyPublicCtorInClassCheck implemented. fixes #186 8a1c8c3
@alex-zuy alex-zuy added a commit to alex-zuy/sevntu.checkstyle that referenced this issue Feb 1, 2015
@alex-zuy alex-zuy new Check UselessSuperCtorCallCheck implemeted. Fixes #186 eb01445
@romani romani closed this in 16e829e Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment