Search in sources :

Example 1 with GargoylePMDConfiguration

use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDConfiguration in project Gargoyle by callakrsos.

the class PMDCheckedListComposite method transformParametersIntoConfiguration.

public GargoylePMDConfiguration transformParametersIntoConfiguration(GargoylePMDParameters params) {
    // if (null == params.getSourceDir() && null == params.getUri() && null
    // == params.getFileListPath()
    // && null == params.getSourceText()) {
    // throw new IllegalArgumentException(
    // "Please provide a parameter for source root directory (-dir or -d),
    // database URI (-uri or -u), or file list path (-filelist).");
    // }
    GargoylePMDConfiguration configuration = new GargoylePMDConfiguration();
    configuration.setInputPaths(params.getSourceDir());
    // configuration.setInputFilePath(params.getFileListPath());
    // configuration.setInputUri(params.getUri());
    configuration.setReportFormat(REPORT_FILE_FORMAT);
    configuration.setSourceFileName(params.getSourceFileName());
    configuration.setSourceText(params.getSourceText());
    // configuration.setBenchmark(params.isBenchmark());
    configuration.setDebug(params.isDebug());
    // configuration.setMinimumPriority(params.getMinimumPriority());
    configuration.setReportFile(params.getReportfile());
    configuration.setReportProperties(params.getProperties());
    // configuration.setReportShortNames(params.isShortnames());
    String language = params.getLanguage();
    // String RESULTSET = new File(String.format(RULESETS_FILE_FORMAT,
    // "java")).getAbsolutePath();
    // if (null != language) {
    // RESULTSET = new File(String.format(RULESETS_FILE_FORMAT,
    // language)).getAbsolutePath();
    // }
    configuration.setRuleSets(getRuleSets(language));
    // configuration.setRuleSetFactoryCompatibilityEnabled(true);
    configuration.setShowSuppressedViolations(params.isShowsuppressed());
    configuration.setSourceEncoding("UTF-8");
    // configuration.setStressTest(params.isStress());
    // configuration.setSuppressMarker(params.getSuppressmarker());
    configuration.setThreads(1);
    // configuration.setFailOnViolation(params.isFailOnViolation());
    LanguageVersion languageVersion = LanguageRegistry.findLanguageVersionByTerseName(language + " " + params.getVersion());
    if (languageVersion != null) {
        configuration.getLanguageVersionDiscoverer().setDefaultLanguageVersion(languageVersion);
    }
    try {
        configuration.prependClasspath(params.getAuxclasspath());
    } catch (IOException e) {
        throw new IllegalArgumentException("Invalid auxiliary classpath: " + e.getMessage(), e);
    }
    return configuration;
}
Also used : GargoylePMDConfiguration(com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDConfiguration) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) IOException(java.io.IOException)

Example 2 with GargoylePMDConfiguration

use of com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDConfiguration in project Gargoyle by callakrsos.

the class PMDCheckComposite method transformParametersIntoConfiguration.

public GargoylePMDConfiguration transformParametersIntoConfiguration(GargoylePMDParameters params) {
    //		if (null == params.getSourceDir() && null == params.getUri() && null == params.getFileListPath()
    //				&& null == params.getSourceText()) {
    //			throw new IllegalArgumentException(
    //					"Please provide a parameter for source root directory (-dir or -d), database URI (-uri or -u), or file list path (-filelist).");
    //		}
    GargoylePMDConfiguration configuration = new GargoylePMDConfiguration();
    configuration.setInputPaths(params.getSourceDir());
    //		configuration.setInputFilePath(params.getFileListPath());
    //		configuration.setInputUri(params.getUri());
    configuration.setReportFormat(REPORT_FILE_FORMAT);
    configuration.setSourceFileName(params.getSourceFileName());
    configuration.setSourceText(params.getSourceText());
    //		configuration.setBenchmark(params.isBenchmark());
    configuration.setDebug(params.isDebug());
    //		configuration.setMinimumPriority(params.getMinimumPriority());
    configuration.setReportFile(params.getReportfile());
    configuration.setReportProperties(params.getProperties());
    //		configuration.setReportShortNames(params.isShortnames());
    configuration.setRuleSets(RESULTSET);
    configuration.setRuleSetFactoryCompatibilityEnabled(true);
    configuration.setShowSuppressedViolations(params.isShowsuppressed());
    configuration.setSourceEncoding("UTF-8");
    //	        configuration.setStressTest(params.isStress());
    configuration.setSuppressMarker(params.getSuppressmarker());
    //		configuration.setThreads(1);
    configuration.setFailOnViolation(params.isFailOnViolation());
    LanguageVersion languageVersion = LanguageRegistry.findLanguageVersionByTerseName(params.getLanguage() + " " + params.getVersion());
    if (languageVersion != null) {
        configuration.getLanguageVersionDiscoverer().setDefaultLanguageVersion(languageVersion);
    }
    try {
        configuration.prependClasspath(params.getAuxclasspath());
    } catch (IOException e) {
        throw new IllegalArgumentException("Invalid auxiliary classpath: " + e.getMessage(), e);
    }
    return configuration;
}
Also used : GargoylePMDConfiguration(com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDConfiguration) LanguageVersion(net.sourceforge.pmd.lang.LanguageVersion) IOException(java.io.IOException)

Aggregations

GargoylePMDConfiguration (com.kyj.fx.voeditor.visual.framework.pmd.GargoylePMDConfiguration)2 IOException (java.io.IOException)2 LanguageVersion (net.sourceforge.pmd.lang.LanguageVersion)2