elharo commented on code in PR #184:
URL: https://github.com/apache/maven-shared-jar/pull/184#discussion_r4234279844
##########
src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java:
##########
@@ -22,7 +22,8 @@
import java.util.List;
/**
- * Gathered Maven information about the JAR file. Stores both
assumed/validated values and potential values.
+ * Maven coordinates and descriptive metadata identified for a JAR. The fields
contain validated or unambiguous values;
Review Comment:
run-on sentence. Split into two instead of using semicolons
##########
src/main/java/org/apache/maven/shared/jar/identification/JarIdentificationAnalysis.java:
##########
@@ -80,53 +80,44 @@ public JarIdentification analyze(JarAnalyzer jarAnalyzer) {
private void normalize(JarIdentification taxon) {
if (StringUtils.isEmpty(taxon.getGroupId())) {
- taxon.setGroupId(pickSmallest(taxon.getPotentialGroupIds()));
+ taxon.setGroupId(pickUnambiguous(taxon.getPotentialGroupIds()));
}
if (StringUtils.isEmpty(taxon.getArtifactId())) {
- taxon.setArtifactId(pickLargest(taxon.getPotentialArtifactIds()));
+
taxon.setArtifactId(pickUnambiguous(taxon.getPotentialArtifactIds()));
}
if (StringUtils.isEmpty(taxon.getVersion())) {
- taxon.setVersion(pickSmallest(taxon.getPotentialVersions()));
+ taxon.setVersion(pickUnambiguous(taxon.getPotentialVersions()));
}
if (StringUtils.isEmpty(taxon.getName())) {
- taxon.setName(pickLargest(taxon.getPotentialNames()));
+ taxon.setName(pickUnambiguous(taxon.getPotentialNames()));
}
if (StringUtils.isEmpty(taxon.getVendor())) {
- taxon.setVendor(pickLargest(taxon.getPotentialVendors()));
+ taxon.setVendor(pickUnambiguous(taxon.getPotentialVendors()));
}
}
- private String pickSmallest(List<String> list) {
- String smallest = null;
-
- int size = Integer.MAX_VALUE;
- for (String val : list) {
- if (val != null && !val.isEmpty()) {
- if (val.length() < size) {
- smallest = val;
- size = val.length();
- }
+ /**
+ * Returns the value when there is at most one distinct non-empty
candidate, or {@code null} when candidates
Review Comment:
I'm not sure this is right. Shouldn't it pick correctly from a list instead
of giving up? The current version always picks something.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]