apupier commented on code in PR #21086:
URL: https://github.com/apache/camel/pull/21086#discussion_r2732497649


##########
core/camel-console/src/main/java/org/apache/camel/impl/console/BrowseDevConsole.java:
##########
@@ -156,71 +159,43 @@ protected JsonObject doCallJson(Map<String, Object> 
options) {
         JsonArray arr = new JsonArray();
 
         String filter = (String) options.get(FILTER);
-        String lim = (String) options.get(LIMIT);
-        String tail = (String) options.get(TAIL);
-        final int pos = tail == null ? 0 : Integer.parseInt(tail);
-        final int max = lim == null ? limit : Integer.parseInt(lim);
-        boolean freshSize = "true".equals(options.getOrDefault(FRESH_SIZE, 
"false"));
-        boolean dump = "true".equals(options.getOrDefault(DUMP, "true"));
-        boolean includeBody = "true".equals(options.getOrDefault(INCLUDE_BODY, 
"true"));
-        int maxChars = Integer.parseInt((String) 
options.getOrDefault(BODY_MAX_CHARS, "" + bodyMaxChars));
+        final int pos = parseIntOption(options, TAIL, 0);
+        final int max = parseIntOption(options, LIMIT, limit);
+        boolean freshSize = parseBooleanOption(options, FRESH_SIZE, false);
+        boolean dump = parseBooleanOption(options, DUMP, true);
+        boolean includeBody = parseBooleanOption(options, INCLUDE_BODY, true);
+        int maxChars = parseIntOption(options, BODY_MAX_CHARS, bodyMaxChars);
 
         Collection<Endpoint> endpoints = new 
TreeSet<>(Comparator.comparing(Endpoint::getEndpointUri));
         endpoints.addAll(getCamelContext().getEndpoints());
         for (Endpoint endpoint : endpoints) {
-            if (endpoint instanceof BrowsableEndpoint be
-                    && (filter == null || 
PatternHelper.matchPattern(endpoint.getEndpointUri(), filter))) {
-                if (dump) {
-                    List<Exchange> list = freshSize ? 
be.getExchanges(Integer.MAX_VALUE, null) : be.getExchanges(max, null);
-                    int queueSize = list != null ? list.size() : 0;
-                    int begin = 0;
-                    if (list != null && pos > 0) {
-                        begin = Math.max(0, list.size() - pos);
-                        list = list.subList(begin, list.size());
-                    }
-                    if (list != null) {
-                        JsonObject jo = new JsonObject();
-                        jo.put("endpointUri", endpoint.getEndpointUri());
-                        jo.put("queueSize", queueSize);
-                        jo.put("limit", max);
-                        jo.put("position", begin);
-                        if (!list.isEmpty()) {
-                            long ts = 
list.get(0).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L, long.class);
-                            if (ts > 0) {
-                                jo.put("firstTimestamp", ts);
-                            }
-                            if (list.size() > 1) {
-                                ts = list.get(list.size() - 
1).getMessage().getHeader(Exchange.MESSAGE_TIMESTAMP, 0L,
-                                        long.class);
-                                if (ts > 0) {
-                                    jo.put("lastTimestamp", ts);
-                                }
-                            }
-                        }
-                        arr.add(jo);
-                        JsonArray arr2 = new JsonArray();
-                        for (Exchange e : list) {
-                            
arr2.add(MessageHelper.dumpAsJSonObject(e.getMessage(), false, false, 
includeBody, true, true, true,
-                                    maxChars));
-                        }
-                        if (!arr2.isEmpty()) {
-                            jo.put("messages", arr2);
-                        }
-                    }
-                } else {
-                    BrowsableEndpoint.BrowseStatus status = 
be.getBrowseStatus(Integer.MAX_VALUE);

Review Comment:
   it is exchanging sonar warnign about cyclomatic complexity to too many break 
or continue statement



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