@Test public void rules() { RulesDefinition rulesDefinition = new ScalaRulesDefinition(SonarRuntimeImpl.forSonarQube(Version.create(7,2), SonarQubeSide.SERVER)); RulesDefinition.Context context = new RulesDefinition.Context(); rulesDefinition.define(context); RulesDefinition.Repository repository = context.repository("scala"); assertThat(repository.name()).isEqualTo("SonarAnalyzer"); assertThat(repository.language()).isEqualTo("scala"); RulesDefinition.Rule rule = repository.rule("ParsingError"); assertThat(rule).isNotNull(); assertThat(rule.name()).isEqualTo("Scala parser failure"); assertThat(rule.type()).isEqualTo(RuleType.CODE_SMELL); }
@Override public void define(RulesDefinition.Context context) { NewRepository repository = context .createRepository(ScalaPlugin.SCALA_REPOSITORY_KEY, ScalaPlugin.SCALA_LANGUAGE_KEY) .setName(ScalaPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, ScalaProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = new ArrayList<>(ScalaCheckList.checks()); checks.add(CommentedCodeCheck.class); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.SCALA); repository.done(); }
ScalaRulesDefinition implements RulesDefinition { @Override public void define(RulesDefinition.Context context) { NewRepository repository = context .createRepository(ScalaPlugin.SCALA_REPOSITORY_KEY, ScalaPlugin.SCALA_LANGUAGE_KEY) .setName(ScalaPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, ScalaProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = new ArrayList<>(ScalaCheckList.checks()); checks.add(CommentedCodeCheck.class); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.SCALA); repository.done(); } }
ScalaRulesDefinition implements RulesDefinition { @Override public void define(RulesDefinition.Context context) { NewRepository repository = context .createRepository(ScalaPlugin.SCALA_REPOSITORY_KEY, ScalaPlugin.SCALA_LANGUAGE_KEY) .setName(ScalaPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, ScalaProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = new ArrayList<>(ScalaCheckList.checks()); checks.add(CommentedCodeCheck.class); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.SCALA); repository.done(); } ScalaRulesDefinition(SonarRuntime sonarRuntime); }
ScalaRulesDefinition implements RulesDefinition { @Override public void define(RulesDefinition.Context context) { NewRepository repository = context .createRepository(ScalaPlugin.SCALA_REPOSITORY_KEY, ScalaPlugin.SCALA_LANGUAGE_KEY) .setName(ScalaPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, ScalaProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = new ArrayList<>(ScalaCheckList.checks()); checks.add(CommentedCodeCheck.class); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.SCALA); repository.done(); } ScalaRulesDefinition(SonarRuntime sonarRuntime); @Override void define(RulesDefinition.Context context); }
ScalaRulesDefinition implements RulesDefinition { @Override public void define(RulesDefinition.Context context) { NewRepository repository = context .createRepository(ScalaPlugin.SCALA_REPOSITORY_KEY, ScalaPlugin.SCALA_LANGUAGE_KEY) .setName(ScalaPlugin.REPOSITORY_NAME); RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(RESOURCE_FOLDER, ScalaProfileDefinition.PATH_TO_JSON, sonarRuntime); List<Class> checks = new ArrayList<>(ScalaCheckList.checks()); checks.add(CommentedCodeCheck.class); ruleMetadataLoader.addRulesByAnnotatedClass(repository, checks); RulesDefinitionUtils.setDefaultValuesForParameters(repository, checks, Language.SCALA); repository.done(); } ScalaRulesDefinition(SonarRuntime sonarRuntime); @Override void define(RulesDefinition.Context context);  }