-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SONARJAVA-4446 Check if the parent class or implemented interface symbols of the test class are known. #4956
Conversation
ce3965a
to
1d1b1c7
Compare
@@ -21,6 +21,18 @@ | |||
import com.googlecode.zohhak.api.TestWith; | |||
import com.googlecode.zohhak.api.runners.ZohhakRunner; | |||
|
|||
class SubclassTest extends ParentTestClass { // Compliant, we cannot know what is in ParentTestClass so we don't raise issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we change the name so it suggests that the class is not defined, for example, UndefinedParentTestClass
?
} | ||
|
||
abstract class ResolvedParent {} | ||
class Subclass4Test extends ResolvedParent {} // Noncompliant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a good reason to put this new block at the beginning of the file. Could we move it towards the end?
@@ -78,7 +79,16 @@ private void resetAnnotationCache() { | |||
} | |||
|
|||
private void checkClass(ClassTree classTree) { | |||
if (!ModifiersUtils.hasModifier(classTree.modifiers(), Modifier.ABSTRACT)) { | |||
boolean knownParent = Optional.ofNullable(classTree.superClass()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more typical way of doing this would be to define private static knownParent(...)
and use if in if-then. Same for knownImplementedInterfaces
. You could even put this new check into one method.
Quality Gate passedIssues Measures |
SONARJAVA-4446
If any symbol is not known, do not raise an issue to avoid false positives.