squid:MaximumInheritanceDepth to many parents counting wrong in SonarLint 2.6 for Eclipse

2,276 views
Skip to first unread message

Matthias Kolley

unread,
Feb 23, 2017, 2:46:27 AM2/23/17
to SonarLint
I get the issue squid:MaximumInheritanceDepth for one of my classes.
SonarLint tells me This class has 6 parents which is greater than 5 authorized.
I looked through my class and only found 5 Parents.
So i wrote an example.

public TestClass{

public abstract class Parent1 {

       
int value = 0;

       
public int getValue() {
           
return value;
       
}
   
}

   
public abstract class Parent2 extends Parent1 {

   
}

   
public abstract class Parent3 extends Parent2 {

   
}

   
public abstract class Parent4 extends Parent3 {

   
}

   
public abstract class Parent5 extends Parent4 {

   
}

   
public class MyObject extends Parent5 {

   
}
}

And as you will see: SonarLint complains about the class "MyObject" to have 6 parents which is greater than 5 authorized. But obviously MyObject only has 5 Parents.
Am I wrong? Or is this really counted the wrong way?

Nicolas Peru

unread,
Feb 23, 2017, 7:44:39 AM2/23/17
to Matthias Kolley, SonarLint
Hi Matthias, 

Don't forget that Parent1 extends Object. So this is where the 6th parent is counted.

Cheers, 

--
You received this message because you are subscribed to the Google Groups "SonarLint" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarlint+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarlint/a63f782a-8f54-4bb5-8a1b-1b9b0de0d132%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Nicolas PERU | SonarSource
Senior Developer
http://sonarsource.com

Matthias Kolley

unread,
Feb 23, 2017, 8:12:54 AM2/23/17
to SonarLint, matthia...@googlemail.com
Oh right. Thank you very much :D
Sorry that i missed that ;)
So definitely correct counting.
Reply all
Reply to author
Forward
0 new messages