I am looking to write a custom java rule to enforce that a test class name follows a regex pattern, but also contains a valid class name from the main scope. For example, the class in main scope:
package com.test;
public class ABC {
...
}
And the rule file:
public class RandomTest { // Noncompliant
}
public class ABCTest { // Compliant
}
(All test class files ending with Test.java
must match CLASSINMAINSCOPETest.java
. Files that don’t end in Test.java
wouldn’t be matched and don’t need this restriction)
I’ve been playing around and I am able to run rules on test scope, but I am unable to check or access semantic information from the main scope. Any help or insight will be greatly appreciated. Thanks!