private List<Class> getChecks() { ImmutableList.Builder<Class> checksBuilder = ImmutableList.<Class>builder().addAll(CheckList.getChecks()); if (isDebugEnabled) { checksBuilder.addAll(CheckList.getDebugChecks()); } return checksBuilder.build(); }
@Override public RulesProfile createProfile(ValidationMessages messages) { AnnotationBasedProfileBuilder annotationBasedProfileBuilder = new AnnotationBasedProfileBuilder(ruleFinder); return annotationBasedProfileBuilder.build(CheckList.REPOSITORY_KEY, "Sonar way", Java.KEY, CheckList.getChecks(), messages); } }
private static Map<String, String> legacyKeys() { Map<String, String> result = new HashMap<>(); for (Class checkClass : CheckList.getChecks()) { org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(checkClass, org.sonar.check.Rule.class); String key = ruleAnnotation.key(); org.sonar.java.RspecKey rspecKeyAnnotation = AnnotationUtils.getAnnotation(checkClass, org.sonar.java.RspecKey.class); String rspecKey = key; if(rspecKeyAnnotation != null) { rspecKey = rspecKeyAnnotation.value(); } result.put(rspecKey, key); } return result; }
@Override public void define(Context context) { NewRepository repository = context .createRepository(CheckList.REPOSITORY_KEY, Java.KEY) .setName("SonarQube"); AnnotationBasedRulesDefinition.load(repository, Java.KEY, CheckList.getChecks()); for (NewRule rule : repository.rules()) { //FIXME: set internal key to key to ensure rule templates works properly : should be removed when SONAR-6162 is fixed. rule.setInternalKey(rule.key()); } repository.done(); } }