@Test public void rules() { RulesDefinition rulesDefinition = new RubyRulesDefinition(SonarRuntimeImpl.forSonarQube(Version.create(7,2), SonarQubeSide.SERVER)); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("ruby"); assertThat(repository.name()).isEqualTo("SonarAnalyzer"); assertThat(repository.language()).isEqualTo("ruby"); Rule rule = repository.rule("S1135"); assertThat(rule).isNotNull(); assertThat(rule.name()).isEqualTo("Track uses of \"TODO\" tags"); assertThat(rule.debtRemediationFunction()).isNull(); assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL); Rule ruleWithConfig = repository.rule("S100"); Param param = ruleWithConfig.param("format"); assertThat(param.defaultValue()).isEqualTo("^(@{0,2}[\\da-z_]+[!?=]?)|([*+-/%=!><~]+)|(\\[]=?)$"); }
@Override public void define(Context context) { NewRepository repository = context .createRepository(RubyPlugin.RUBY_REPOSITORY_KEY, RubyPlugin.RUBY_LANGUAGE_KEY) .setName(RubyPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, RubyProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = RubyCheckList.checks(); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.RUBY); repository.done(); }
RubyRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(RubyPlugin.RUBY_REPOSITORY_KEY, RubyPlugin.RUBY_LANGUAGE_KEY) .setName(RubyPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, RubyProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = RubyCheckList.checks(); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.RUBY); repository.done(); } }
RubyRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(RubyPlugin.RUBY_REPOSITORY_KEY, RubyPlugin.RUBY_LANGUAGE_KEY) .setName(RubyPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, RubyProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = RubyCheckList.checks(); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.RUBY); repository.done(); } RubyRulesDefinition(SonarRuntime sonarRuntime); }
RubyRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(RubyPlugin.RUBY_REPOSITORY_KEY, RubyPlugin.RUBY_LANGUAGE_KEY) .setName(RubyPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, RubyProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = RubyCheckList.checks(); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.RUBY); repository.done(); } RubyRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context); }
RubyRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(RubyPlugin.RUBY_REPOSITORY_KEY, RubyPlugin.RUBY_LANGUAGE_KEY) .setName(RubyPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, RubyProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = RubyCheckList.checks(); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.RUBY); repository.done(); } RubyRulesDefinition(SonarRuntime sonarRuntime); @Override void define(Context context);  }