use of org.sonar.java.RspecKey in project sonar-java by SonarSource.
the class CheckVerifier method ruleKey.
private static String ruleKey(AnalyzerMessage issue) {
String ruleKey;
RspecKey rspecKeyAnnotation = AnnotationUtils.getAnnotation(issue.getCheck().getClass(), RspecKey.class);
if (rspecKeyAnnotation != null) {
ruleKey = rspecKeyAnnotation.value();
} else {
Rule ruleAnnotation = AnnotationUtils.getAnnotation(issue.getCheck().getClass(), Rule.class);
if (ruleAnnotation != null) {
ruleKey = ruleAnnotation.key();
} else {
Fail.fail("Rules should be annotated with '@Rule(key = \"...\")' annotation (org.sonar.check.Rule).");
// unreachable
return null;
}
}
return ruleKey;
}
use of org.sonar.java.RspecKey in project sonar-java by SonarSource.
the class CheckListTest method getKey.
private static String getKey(Class cls, Rule ruleAnnotation) {
String key = ruleAnnotation.key();
RspecKey rspecKeyAnnotation = AnnotationUtils.getAnnotation(cls, RspecKey.class);
if (rspecKeyAnnotation != null) {
return rspecKeyAnnotation.value();
}
return key;
}