Java Code Examples for net.sourceforge.pmd.RuleSet#applies()

The following examples show how to use net.sourceforge.pmd.RuleSet#applies() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java    From diff-check with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static Set<Language> getApplicableLanguages(PMDConfiguration configuration, RuleSets ruleSets) {
    Set<Language> languages = new HashSet<>();
    LanguageVersionDiscoverer discoverer = configuration.getLanguageVersionDiscoverer();

    for (Rule rule : ruleSets.getAllRules()) {
        Language language = rule.getLanguage();
        if (languages.contains(language)) {
            continue;
        }
        LanguageVersion version = discoverer.getDefaultLanguageVersion(language);
        if (RuleSet.applies(rule, version)) {
            languages.add(language);
            if (LOG.isLoggable(Level.FINE)) {
                LOG.fine("Using " + language.getShortName() + " version: " + version.getShortName());
            }
        }
    }
    return languages;
}
 
Example 2
Source File: PmdProcessor.java    From sputnik with Apache License 2.0 6 votes vote down vote up
/**
 * Paste from PMD
 */
private static Set<Language> getApplicableLanguages(PMDConfiguration configuration, RuleSets ruleSets) {
    Set<Language> languages = new HashSet<>();
    LanguageVersionDiscoverer discoverer = configuration.getLanguageVersionDiscoverer();

    for (Rule rule : ruleSets.getAllRules()) {
        Language language = rule.getLanguage();
        if (languages.contains(language))
            continue;
        LanguageVersion version = discoverer.getDefaultLanguageVersion(language);
        if (RuleSet.applies(rule, version)) {
            languages.add(language);
            log.debug("Using {} version: {}", language.getShortName(), version.getShortName());
        }
    }
    return languages;
}