javeme commented on code in PR #2143:
URL: 
https://github.com/apache/incubator-hugegraph/pull/2143#discussion_r1127832242


##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherClient.java:
##########
@@ -62,14 +68,14 @@ public CypherModel submitQuery(String cypherQuery,@Nullable 
Map<String, String>
         }
 
         RequestMessage request = createRequest(cypherQuery);
-        CypherModel res = null;
+        CypherModel res;
 
         try {
             List<Object> list = this.doQueryList(client, request);
             res = CypherModel.dataOf(request.getRequestId().toString(), list);
         } catch (Exception e) {
-            LOG.error(String.format("Failed to submit cypher-query: [ %s ], 
cause by:"
-                    , cypherQuery), e);
+            LOG.error(String.format("Failed to submit cypher-query: [ %s ], 
cause by:",

Review Comment:
   1. please check all the `String.format`, use "{}" instead
   2. `cause by` => `caused by`



##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherClient.java:
##########
@@ -81,21 +87,19 @@ public CypherModel submitQuery(String cypherQuery,@Nullable 
Map<String, String>
 
     private RequestMessage createRequest(String cypherQuery) {
         return RequestMessage.build(Tokens.OPS_EVAL)
-                .processor("cypher")
-                .add(Tokens.ARGS_GREMLIN, cypherQuery)
-                .create();
+                             .processor("cypher")
+                             .add(Tokens.ARGS_GREMLIN, cypherQuery)
+                             .create();
     }
 
     private List<Object> doQueryList(Client client, RequestMessage request)
-            throws ExecutionException, InterruptedException {
-
-        ResultSet results = null;
-        results = client.submitAsync(request).get();
+        throws ExecutionException, InterruptedException {
+        ResultSet results = client.submitAsync(request).get();
 
         Iterator<Result> iter = results.iterator();
         List<Object> list = new LinkedList<>();
 
-        for (; iter.hasNext(); ) {
+        while (iter.hasNext()) {

Review Comment:
   prefer to use ArrayList instead of LinkedList



##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/gremlin/CypherAPI.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.api.gremlin;
+
+import org.opencypher.gremlin.translation.TranslationFacade;
+import org.slf4j.Logger;
+
+import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
+import org.apache.hugegraph.util.E;
+import org.apache.hugegraph.util.Log;
+import com.codahale.metrics.annotation.Timed;
+
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.inject.Singleton;
+import jakarta.ws.rs.Consumes;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.Produces;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Context;
+import jakarta.ws.rs.core.HttpHeaders;
+import jakarta.ws.rs.core.Response;
+
+//@Path("graphs/{graph}/cypher")

Review Comment:
   expected comment?



##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherManager.java:
##########
@@ -91,17 +91,17 @@ private static File getConfigFile(String configurationFile) 
{
         if (!systemFile.exists()) {
             final ClassLoader currentClassLoader = 
Thread.currentThread().getContextClassLoader();
             final URL resource = 
currentClassLoader.getResource(configurationFile);
+            assert resource != null;
             final File resourceFile = new File(resource.getFile());
 
             if (!resourceFile.exists()) {
-                throw new 
IllegalArgumentException(String.format("Configuration file at %s does not exist"
-                    , configurationFile));
+                throw new 
IllegalArgumentException(String.format("Configuration file at %s does " +

Review Comment:
   ditto



##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherClient.java:
##########
@@ -136,10 +144,9 @@ public int hashCode() {
 
     @Override
     public String toString() {
-        final StringBuffer sb = new StringBuffer("CypherClient{");
-        sb.append("userName='").append(userName).append('\'');
-        sb.append(", token='").append(token).append('\'');
-        sb.append('}');
+        final StringBuilder sb = new StringBuilder("CypherClient{");
+        sb.append("userName='").append(userName).append('\'')
+          .append(", token='").append(token).append('\'').append('}');

Review Comment:
   the style checker requires at least 4 spaces indentation, please rename sb 
to builder



##########
hugegraph-api/src/main/java/org/apache/hugegraph/api/cypher/CypherManager.java:
##########
@@ -79,7 +79,7 @@ private static YAMLConfiguration loadYaml(String 
configurationFile) {
             yaml.read(reader);
         } catch (Exception e) {
             throw new RuntimeException(String.format("Failed to load 
configuration file," +
-                " the file at %s.", configurationFile), e);
+                                                     " the file at %s.", 
configurationFile), e);

Review Comment:
   `%s` => `'%s'`



-- 
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: dev-unsubscr...@hugegraph.apache.org

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

Reply via email to