@Test public void test_external_repositories() { GoRulesDefinition rulesDefinition = new GoRulesDefinition(true); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository golintRepository = context.repository("external_golint"); RulesDefinition.Repository govetRepository = context.repository("external_govet"); assertThat(context.repositories()).hasSize(3); assertThat(golintRepository.name()).isEqualTo("Golint"); assertThat(govetRepository.name()).isEqualTo("go vet"); assertThat(golintRepository.language()).isEqualTo("go"); assertThat(govetRepository.language()).isEqualTo("go"); assertThat(golintRepository.isExternal()).isEqualTo(true); assertThat(govetRepository.isExternal()).isEqualTo(true); assertThat(golintRepository.rules().size()).isEqualTo(18); assertThat(ExternalKeyUtils.GO_LINT_KEYS.size()).isEqualTo(18); assertThat(govetRepository.rules().size()).isEqualTo(21); assertThat(ExternalKeyUtils.GO_VET_KEYS.size()).isEqualTo(21); List<String> govetKeysWithoutDefinition = ExternalKeyUtils.GO_VET_KEYS.stream() .map(x -> x.key) .filter(key -> govetRepository.rule(key) == null) .collect(Collectors.toList()); assertThat(govetKeysWithoutDefinition).isEmpty(); List<String> golintKeysWithoutDefinition = ExternalKeyUtils.GO_LINT_KEYS.stream() .map(x -> x.key) .filter(key -> golintRepository.rule(key) == null) .collect(Collectors.toList()); assertThat(golintKeysWithoutDefinition).isEmpty(); }
@Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, GoLanguage.KEY) .setName("SonarAnalyzer"); RuleMetadataLoader metadataLoader = new RuleMetadataLoader(GoPlugin.RESOURCE_FOLDER); List<Class> checks = GoCheckList.checks(); metadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.GO); repository.done(); if (externalIssuesSupported) { AbstractReportSensor.createExternalRuleRepository(context, GoVetReportSensor.LINTER_ID, GoVetReportSensor.LINTER_NAME); AbstractReportSensor.createExternalRuleRepository(context, GoLintReportSensor.LINTER_ID, GoLintReportSensor.LINTER_NAME); } }
GoRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, GoLanguage.KEY) .setName("SonarAnalyzer"); RuleMetadataLoader metadataLoader = new RuleMetadataLoader(GoPlugin.RESOURCE_FOLDER); List<Class> checks = GoCheckList.checks(); metadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.GO); repository.done(); if (externalIssuesSupported) { AbstractReportSensor.createExternalRuleRepository(context, GoVetReportSensor.LINTER_ID, GoVetReportSensor.LINTER_NAME); AbstractReportSensor.createExternalRuleRepository(context, GoLintReportSensor.LINTER_ID, GoLintReportSensor.LINTER_NAME); } } }
GoRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, GoLanguage.KEY) .setName("SonarAnalyzer"); RuleMetadataLoader metadataLoader = new RuleMetadataLoader(GoPlugin.RESOURCE_FOLDER); List<Class> checks = GoCheckList.checks(); metadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.GO); repository.done(); if (externalIssuesSupported) { AbstractReportSensor.createExternalRuleRepository(context, GoVetReportSensor.LINTER_ID, GoVetReportSensor.LINTER_NAME); AbstractReportSensor.createExternalRuleRepository(context, GoLintReportSensor.LINTER_ID, GoLintReportSensor.LINTER_NAME); } } GoRulesDefinition(boolean externalIssuesSupported); }
GoRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, GoLanguage.KEY) .setName("SonarAnalyzer"); RuleMetadataLoader metadataLoader = new RuleMetadataLoader(GoPlugin.RESOURCE_FOLDER); List<Class> checks = GoCheckList.checks(); metadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.GO); repository.done(); if (externalIssuesSupported) { AbstractReportSensor.createExternalRuleRepository(context, GoVetReportSensor.LINTER_ID, GoVetReportSensor.LINTER_NAME); AbstractReportSensor.createExternalRuleRepository(context, GoLintReportSensor.LINTER_ID, GoLintReportSensor.LINTER_NAME); } } GoRulesDefinition(boolean externalIssuesSupported); @Override void define(Context context); }
GoRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context.createRepository(REPOSITORY_KEY, GoLanguage.KEY) .setName("SonarAnalyzer"); RuleMetadataLoader metadataLoader = new RuleMetadataLoader(GoPlugin.RESOURCE_FOLDER); List<Class> checks = GoCheckList.checks(); metadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.GO); repository.done(); if (externalIssuesSupported) { AbstractReportSensor.createExternalRuleRepository(context, GoVetReportSensor.LINTER_ID, GoVetReportSensor.LINTER_NAME); AbstractReportSensor.createExternalRuleRepository(context, GoLintReportSensor.LINTER_ID, GoLintReportSensor.LINTER_NAME); } } GoRulesDefinition(boolean externalIssuesSupported); @Override void define(Context context); static final String REPOSITORY_KEY; }