@Test public void test() { GoRulesDefinition rulesDefinition = new GoRulesDefinition(false); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); assertThat(context.repositories()).hasSize(1); RulesDefinition.Repository goRepository = context.repository("go"); assertThat(goRepository.name()).isEqualTo("SonarAnalyzer"); assertThat(goRepository.language()).isEqualTo("go"); assertThat(goRepository.rules()).hasSize(GoCheckList.checks().size()); RulesDefinition.Rule rule = goRepository.rule("S4663"); assertThat(rule).isNotNull(); assertThat(rule.name()).isEqualTo("Multi-line comments should not be empty"); assertThat(rule.debtRemediationFunction().type()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE); assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL); }
@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; }