Custom Java Rule: Retrieve Complete Type Hierarchy

In an IssuableSubscriptionVisitor I can access the direct super class with org.sonar.plugins.java.api.tree.ClassTree.superClass(). Is it possible to get the full type hierarchy, i.e. recursively retrieve a list of all super classes until java.lang.Object was reached?

Hello @martinschemel

You can easily build this list thanks to the semantic API. Example here.

By the way, when working on custom rules, if you feel that the rule you are thinking about would make sense to everyone, it would be nice if you consider discussing it in this forum. Then, if it makes senes, we will definitely consider putting it in the Java analyzer directly.

Best,
Quentin

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.