elharo commented on code in PR #184:
URL: https://github.com/apache/maven-shared-jar/pull/184#discussion_r4229530428


##########
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 only non-empty candidate. Potential values do not carry 
source or confidence information, so they

Review Comment:
   This describes what the bug was, not what the code does. Fix. 



##########
src/main/java/org/apache/maven/shared/jar/identification/JarIdentification.java:
##########
@@ -22,7 +22,9 @@
 import java.util.List;
 
 /**
- * Gathered Maven information about the JAR file. Stores both 
assumed/validated values and potential values.
+ * Gathered Maven information about the JAR file. Stores both 
assumed/validated values and potential values. When no

Review Comment:
   This is very hard to follow. Rewrite.



-- 
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]

Reply via email to