@Test public void should_exclude_junit_rules() { PmdRulesDefinition definition = new PmdRulesDefinition(); RulesDefinition.Context context = new RulesDefinition.Context(); definition.define(context); RulesDefinition.Repository repository = context.repository(PmdConstants.REPOSITORY_KEY); for (Rule rule : repository.rules()) { assertThat(rule.key()).excludes("JUnitStaticSuite"); } }
@Override public void define(Context context) { NewRepository repository = context .createRepository(PmdConstants.REPOSITORY_KEY, Java.KEY) .setName(PmdConstants.REPOSITORY_NAME); extractRulesData(repository, "/org/sonar/plugins/pmd/rules.xml", "/org/sonar/l10n/pmd/rules/pmd"); extractRulesData(repository, "/org/sonar/plugins/pmd/rules-p3c.xml", "/org/sonar/l10n/pmd/rules/pmd-p3c"); repository.done(); NewRepository xmlRepository = context .createRepository(PmdConstants.XML_REPOSITORY_KEY, Xml.KEY) .setName(PmdConstants.XML_REPOSITORY_NAME); extractRulesData(xmlRepository, "/org/sonar/plugins/pmd/rules-xml.xml", "/org/sonar/l10n/pmd/rules/pmd-xml"); xmlRepository.done(); }
PmdRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(PmdConstants.REPOSITORY_KEY, Java.KEY) .setName(PmdConstants.REPOSITORY_NAME); extractRulesData(repository, "/org/sonar/plugins/pmd/rules.xml", "/org/sonar/l10n/pmd/rules/pmd"); extractRulesData(repository, "/org/sonar/plugins/pmd/rules-p3c.xml", "/org/sonar/l10n/pmd/rules/pmd-p3c"); repository.done(); NewRepository xmlRepository = context .createRepository(PmdConstants.XML_REPOSITORY_KEY, Xml.KEY) .setName(PmdConstants.XML_REPOSITORY_NAME); extractRulesData(xmlRepository, "/org/sonar/plugins/pmd/rules-xml.xml", "/org/sonar/l10n/pmd/rules/pmd-xml"); xmlRepository.done(); } }
PmdRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(PmdConstants.REPOSITORY_KEY, Java.KEY) .setName(PmdConstants.REPOSITORY_NAME); extractRulesData(repository, "/org/sonar/plugins/pmd/rules.xml", "/org/sonar/l10n/pmd/rules/pmd"); extractRulesData(repository, "/org/sonar/plugins/pmd/rules-p3c.xml", "/org/sonar/l10n/pmd/rules/pmd-p3c"); repository.done(); NewRepository xmlRepository = context .createRepository(PmdConstants.XML_REPOSITORY_KEY, Xml.KEY) .setName(PmdConstants.XML_REPOSITORY_NAME); extractRulesData(xmlRepository, "/org/sonar/plugins/pmd/rules-xml.xml", "/org/sonar/l10n/pmd/rules/pmd-xml"); xmlRepository.done(); } PmdRulesDefinition(); }
PmdRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(PmdConstants.REPOSITORY_KEY, Java.KEY) .setName(PmdConstants.REPOSITORY_NAME); extractRulesData(repository, "/org/sonar/plugins/pmd/rules.xml", "/org/sonar/l10n/pmd/rules/pmd"); extractRulesData(repository, "/org/sonar/plugins/pmd/rules-p3c.xml", "/org/sonar/l10n/pmd/rules/pmd-p3c"); repository.done(); NewRepository xmlRepository = context .createRepository(PmdConstants.XML_REPOSITORY_KEY, Xml.KEY) .setName(PmdConstants.XML_REPOSITORY_NAME); extractRulesData(xmlRepository, "/org/sonar/plugins/pmd/rules-xml.xml", "/org/sonar/l10n/pmd/rules/pmd-xml"); xmlRepository.done(); } PmdRulesDefinition(); @Override void define(Context context); }
PmdRulesDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(PmdConstants.REPOSITORY_KEY, Java.KEY) .setName(PmdConstants.REPOSITORY_NAME); extractRulesData(repository, "/org/sonar/plugins/pmd/rules.xml", "/org/sonar/l10n/pmd/rules/pmd"); extractRulesData(repository, "/org/sonar/plugins/pmd/rules-p3c.xml", "/org/sonar/l10n/pmd/rules/pmd-p3c"); repository.done(); NewRepository xmlRepository = context .createRepository(PmdConstants.XML_REPOSITORY_KEY, Xml.KEY) .setName(PmdConstants.XML_REPOSITORY_NAME); extractRulesData(xmlRepository, "/org/sonar/plugins/pmd/rules-xml.xml", "/org/sonar/l10n/pmd/rules/pmd-xml"); xmlRepository.done(); } PmdRulesDefinition(); @Override void define(Context context);  }