pmd: adding changes suggested by Ryan Gustavson

This commit is contained in:
Romain PELISSE
2012-11-14 22:05:52 +01:00
parent a887700c8f
commit 7bc5810f7a
2 changed files with 9 additions and 18 deletions

View File

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Properties;
import net.sourceforge.pmd.PMD;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageVersion;
import net.sourceforge.pmd.renderers.Renderer;
import net.sourceforge.pmd.renderers.RendererFactory;
@ -104,13 +105,9 @@ public class PMDCommandLineInterface {
}
private static String supportedVersions() {
String supportedVersion = "Languages and version suported:" + PMD.EOL;
for ( LanguageVersion version : LanguageVersion.values() ) {
supportedVersion += version.getName() + ", ";
}
supportedVersion += PMD.EOL;
supportedVersion += "Note that some language are not supported by PMD - only by CPD" + PMD.EOL;
return supportedVersion;
return "Languages and version suported:" + PMD.EOL +
Language.commaSeparatedTerseNames(Language.findWithRuleSupport()) + PMD.EOL +
"Note that some language are not supported by PMD - only by CPD" + PMD.EOL;
}
/**

View File

@ -4,12 +4,14 @@ import java.util.Properties;
import net.sourceforge.pmd.PMDConfiguration;
import net.sourceforge.pmd.RulePriority;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageVersion;
import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.validators.PositiveInteger;
public class PMDParameters {
@ -31,7 +33,7 @@ public class PMDParameters {
@Parameter(names= {"-encoding", "-e"} , description = "specifies the character set encoding of the source code files PMD is reading (i.e., UTF-8)")
private String encoding = "UTF-8";
@Parameter(names = {"-threads", "-t"}, description = "set the number of threads used by PMD", validateWith=PositiveIntegerValidator.class)
@Parameter(names = {"-threads", "-t"}, description = "set the number of threads used by PMD", validateWith=PositiveInteger.class)
private Integer threads = 1;
@Parameter(names = {"-benchmark", "-b"}, description = "Benchmark mode - output a benchmark report upon completion; default to System.err")
@ -59,10 +61,10 @@ public class PMDParameters {
private String reportfile = null;
@Parameter(names = {"-version","-v"}, description = "specify version of a language PMD should use")
private String version = "1.7";
private String version = Language.getDefaultLanguage().getDefaultVersion().getVersion();
@Parameter(names = {"-language", "-l"}, description = "specify version of a language PMD should use")
private String language = "java";
private String language = Language.getDefaultLanguage().getTerseName();
@Parameter(names = "auxclasspath", description = "specifies the classpath for libraries used by the source code (used by type resolution)\n(alternatively, a 'file://' URL to a text file containing path elements on consecutive lines")
private String auxclasspath;
@ -84,14 +86,6 @@ public class PMDParameters {
}
}
class PositiveIntegerValidator implements IParameterValidator {
public void validate(String name, String value) throws ParameterException {
if ( Integer.valueOf(value) < 0 )
throw new ParameterException("Parameter " + name + " should be positive (found " + value +")");
}
}
class RulePriorityConverter implements IStringConverter<RulePriority> {
public int validate(String value) throws ParameterException {