@Test public void test_with_external_rules() { CssRulesDefinition rulesDefinition = new CssRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); assertThat(context.repositories()).hasSize(2); RulesDefinition.Repository mainRepository = context.repository("css"); RulesDefinition.Repository externalRepository = context.repository("external_stylelint"); assertThat(externalRepository.name()).isEqualTo("stylelint"); assertThat(externalRepository.language()).isEqualTo("css"); assertThat(externalRepository.isExternal()).isEqualTo(true); assertThat(externalRepository.rules()).hasSize(170); assertThat(mainRepository.name()).isEqualTo("SonarAnalyzer"); assertThat(mainRepository.language()).isEqualTo("css"); assertThat(mainRepository.isExternal()).isEqualTo(false); assertThat(mainRepository.rules()).hasSize(CssRules.getRuleClasses().size()); }
@Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, CssLanguage.KEY) .setName(RULE_REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER + REPOSITORY_KEY, PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CssRules.getRuleClasses()); repository.done(); StylelintReportSensor.getStylelintRuleLoader().createExternalRuleRepository(context); }
CssRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, CssLanguage.KEY) .setName(RULE_REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER + REPOSITORY_KEY, PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CssRules.getRuleClasses()); repository.done(); StylelintReportSensor.getStylelintRuleLoader().createExternalRuleRepository(context); } }
CssRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, CssLanguage.KEY) .setName(RULE_REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER + REPOSITORY_KEY, PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CssRules.getRuleClasses()); repository.done(); StylelintReportSensor.getStylelintRuleLoader().createExternalRuleRepository(context); }  }
CssRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, CssLanguage.KEY) .setName(RULE_REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER + REPOSITORY_KEY, PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CssRules.getRuleClasses()); repository.done(); StylelintReportSensor.getStylelintRuleLoader().createExternalRuleRepository(context); }  @Override void define(Context context); }
CssRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(REPOSITORY_KEY, CssLanguage.KEY) .setName(RULE_REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER + REPOSITORY_KEY, PROFILE_PATH); ruleMetadataLoader.addRulesByAnnotatedClass(repository, CssRules.getRuleClasses()); repository.done(); StylelintReportSensor.getStylelintRuleLoader().createExternalRuleRepository(context); }  @Override void define(Context context); static final String REPOSITORY_KEY; static final String RULE_REPOSITORY_NAME; static final String RESOURCE_FOLDER; }