CPD Results
The following document contains the results of PMD's CPD 6.55.0.
Duplications
File |
Line |
org/apache/maven/plugin/PluginParameterExpressionEvaluator.java |
308 |
org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4.java |
188 |
value = project.getProperties().getProperty(expression);
}
}
if (value instanceof String) {
// TODO without #, this could just be an evaluate call...
String val = (String) value;
int exprStartDelimiter = val.indexOf("${");
if (exprStartDelimiter >= 0) {
if (exprStartDelimiter > 0) {
value = val.substring(0, exprStartDelimiter) + evaluate(val.substring(exprStartDelimiter));
} else {
value = evaluate(val.substring(exprStartDelimiter));
}
}
}
return value;
}
private static boolean isTypeCompatible(Class<?> type, Object value) {
if (type.isInstance(value)) {
return true;
}
// likely Boolean -> boolean, Short -> int etc. conversions, it's not the problem case we try to avoid
return ((type.isPrimitive() || type.getName().startsWith("java.lang."))
&& value.getClass().getName().startsWith("java.lang."));
}
private String stripTokens(String expr) {
if (expr.startsWith("${") && (expr.indexOf('}') == expr.length() - 1)) {
expr = expr.substring(2, expr.length() - 1);
}
return expr;
}
@Override
public File alignToBaseDirectory(File file) {
// TODO Copied from the DefaultInterpolator. We likely want to resurrect the PathTranslator or at least a
// similar component for re-usage
if (file != null) {
if (file.isAbsolute()) {
// path was already absolute, just normalize file separator and we're done
} else if (file.getPath().startsWith(File.separator)) {
// drive-relative Windows path, don't align with project directory but with drive root
file = file.getAbsoluteFile();
} else {
// an ordinary relative path, align with project directory
file = new File(new File(basedir, file.getPath()).toURI().normalize()).getAbsoluteFile(); |
File |
Line |
org/apache/maven/plugin/PluginParameterExpressionEvaluator.java |
117 |
org/apache/maven/plugin/PluginParameterExpressionEvaluatorV4.java |
87 |
basedir = System.getProperty("user.dir");
}
this.basedir = basedir;
}
@Override
public Object evaluate(String expr) throws ExpressionEvaluationException {
return evaluate(expr, null);
}
@Override
@SuppressWarnings("checkstyle:methodlength")
public Object evaluate(String expr, Class<?> type) throws ExpressionEvaluationException {
Object value = null;
if (expr == null) {
return null;
}
String expression = stripTokens(expr);
if (expression.equals(expr)) {
int index = expr.indexOf("${");
if (index >= 0) {
int lastIndex = expr.indexOf('}', index);
if (lastIndex >= 0) {
String retVal = expr.substring(0, index);
if ((index > 0) && (expr.charAt(index - 1) == '$')) {
retVal += expr.substring(index + 1, lastIndex + 1);
} else {
Object subResult = evaluate(expr.substring(index, lastIndex + 1));
if (subResult != null) {
retVal += subResult;
} else {
retVal += "$" + expr.substring(index + 1, lastIndex + 1);
}
}
retVal += evaluate(expr.substring(lastIndex + 1));
return retVal;
}
}
// Was not an expression
return expression.replace("$$", "$");
} |
File |
Line |
org/apache/maven/artifact/factory/DefaultArtifactFactory.java |
149 |
org/apache/maven/bridge/MavenRepositorySystem.java |
486 |
private Artifact createArtifact(
String groupId,
String artifactId,
VersionRange versionRange,
String type,
String classifier,
String scope,
String inheritedScope,
boolean optional) {
String desiredScope = Artifact.SCOPE_RUNTIME;
if (inheritedScope == null) {
desiredScope = scope;
} else if (Artifact.SCOPE_TEST.equals(scope) || Artifact.SCOPE_PROVIDED.equals(scope)) {
return null;
} else if (Artifact.SCOPE_COMPILE.equals(scope) && Artifact.SCOPE_COMPILE.equals(inheritedScope)) {
// added to retain compile artifactScope. Remove if you want compile inherited as runtime
desiredScope = Artifact.SCOPE_COMPILE;
}
if (Artifact.SCOPE_TEST.equals(inheritedScope)) {
desiredScope = Artifact.SCOPE_TEST;
}
if (Artifact.SCOPE_PROVIDED.equals(inheritedScope)) {
desiredScope = Artifact.SCOPE_PROVIDED;
}
if (Artifact.SCOPE_SYSTEM.equals(scope)) {
// system scopes come through unchanged...
desiredScope = Artifact.SCOPE_SYSTEM;
}
ArtifactHandler handler = artifactHandlerManager.getArtifactHandler(type);
return new DefaultArtifact(
groupId, artifactId, versionRange, desiredScope, type, classifier, handler, optional);
} |
File |
Line |
org/apache/maven/plugin/prefix/NoPluginFoundForPrefixException.java |
38 |
org/apache/maven/plugin/version/PluginVersionResolutionException.java |
76 |
}
private static String format(LocalRepository localRepository, List<RemoteRepository> remoteRepositories) {
StringBuilder repos = new StringBuilder("[");
if (localRepository != null) {
repos.append(localRepository.getId())
.append(" (")
.append(localRepository.getBasedir())
.append(")");
}
if (remoteRepositories != null && !remoteRepositories.isEmpty()) {
for (RemoteRepository repository : remoteRepositories) {
repos.append(", ");
if (repository != null) {
repos.append(repository.getId())
.append(" (")
.append(repository.getUrl())
.append(")");
}
}
}
repos.append("]");
return repos.toString();
}
} |
File |
Line |
org/apache/maven/internal/impl/DefaultSettingsBuilder.java |
123 |
org/apache/maven/internal/impl/DefaultToolchainsBuilder.java |
110 |
MappedBuilderProblem(SettingsProblem problem) {
this.problem = problem;
}
@Override
public String getSource() {
return problem.getSource();
}
@Override
public int getLineNumber() {
return problem.getLineNumber();
}
@Override
public int getColumnNumber() {
return problem.getColumnNumber();
}
@Override
public String getLocation() {
return problem.getLocation();
}
@Override
public Exception getException() {
return problem.getException();
}
@Override
public String getMessage() {
return problem.getMessage();
}
@Override
public Severity getSeverity() {
return Severity.valueOf(problem.getSeverity().name());
}
}
} |