Search in sources :

Example 1 with RspecKey

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;
}
Also used : RspecKey(org.sonar.java.RspecKey) Rule(org.sonar.check.Rule)

Example 2 with RspecKey

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;
}
Also used : RspecKey(org.sonar.java.RspecKey)

Aggregations

RspecKey (org.sonar.java.RspecKey)2 Rule (org.sonar.check.Rule)1