You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by "cschneider (via GitHub)" <gi...@apache.org> on 2024/03/19 09:46:13 UTC

[PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

cschneider opened a new pull request, #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22

   (no comment)


-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22#issuecomment-2006615464

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22)
   
   


-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22#issuecomment-2006581105

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_accepted_issues&view=list)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&resolved=false&inNewCodePeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-distribution-journal-messages&pullRequest=22)
   
   


-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

Posted by "cschneider (via GitHub)" <gi...@apache.org>.
cschneider commented on code in PR #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22#discussion_r1530057396


##########
src/main/java/org/apache/sling/distribution/journal/messages/PackageMessage.java:
##########
@@ -92,31 +97,36 @@ public String toString() {
             out.append(pkgBinary.length);
         }
         out.append(", paths=");
-        out.append(abbreviate(paths));
+        out.append(printList(paths, abbreviate));
         out.append(", deepPaths=");
-        out.append(abbreviate(deepPaths));
+        out.append(printList(deepPaths, abbreviate));
         out.append(", metadata=");
         out.append(metadata);
         out.append(")");
         return out.toString();
     }
 
-    static String abbreviate(List<String> list) {
+    static String printList(List<String> list, boolean abbreviate) {
         if (list == null) {
             return null;
         }
-        Iterator<String> iter = list.iterator();
-        StringBuilder abbr = new StringBuilder();
-        abbr.append("[");
-        if (iter.hasNext()) {
-            abbr.append(iter.next());
-        }
-        if (iter.hasNext()) {
-            abbr.append(", ... ");
-            abbr.append(list.size() - 1);
-            abbr.append(" more");
+        if (abbreviate) {
+            Iterator<String> iter = list.iterator();
+            StringBuilder abbr = new StringBuilder();
+            abbr.append("[");
+            if (iter.hasNext()) {
+                abbr.append(iter.next());
+            }
+            if (iter.hasNext()) {
+                abbr.append(", ... ");
+                abbr.append(list.size() - 1);
+                abbr.append(" more");
+            }
+            abbr.append("]");
+            return abbr.toString();
+        } else {

Review Comment:
   I reversed the if. Now it looks nicer.



-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

Posted by "jose-correia (via GitHub)" <gi...@apache.org>.
jose-correia commented on code in PR #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22#discussion_r1530040704


##########
src/main/java/org/apache/sling/distribution/journal/messages/PackageMessage.java:
##########
@@ -92,31 +97,36 @@ public String toString() {
             out.append(pkgBinary.length);
         }
         out.append(", paths=");
-        out.append(abbreviate(paths));
+        out.append(printList(paths, abbreviate));
         out.append(", deepPaths=");
-        out.append(abbreviate(deepPaths));
+        out.append(printList(deepPaths, abbreviate));
         out.append(", metadata=");
         out.append(metadata);
         out.append(")");
         return out.toString();
     }
 
-    static String abbreviate(List<String> list) {
+    static String printList(List<String> list, boolean abbreviate) {
         if (list == null) {
             return null;
         }
-        Iterator<String> iter = list.iterator();
-        StringBuilder abbr = new StringBuilder();
-        abbr.append("[");
-        if (iter.hasNext()) {
-            abbr.append(iter.next());
-        }
-        if (iter.hasNext()) {
-            abbr.append(", ... ");
-            abbr.append(list.size() - 1);
-            abbr.append(" more");
+        if (abbreviate) {
+            Iterator<String> iter = list.iterator();
+            StringBuilder abbr = new StringBuilder();
+            abbr.append("[");
+            if (iter.hasNext()) {
+                abbr.append(iter.next());
+            }
+            if (iter.hasNext()) {
+                abbr.append(", ... ");
+                abbr.append(list.size() - 1);
+                abbr.append(" more");
+            }
+            abbr.append("]");
+            return abbr.toString();
+        } else {

Review Comment:
   redundant else



-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GRANITE-50556 - Add toString with with option to abbreviate [sling-org-apache-sling-distribution-journal-messages]

Posted by "cschneider (via GitHub)" <gi...@apache.org>.
cschneider merged PR #22:
URL: https://github.com/apache/sling-org-apache-sling-distribution-journal-messages/pull/22


-- 
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: commits-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org